Wednesday, May 8, 2013

Quick Linux (4): File System (Important Directors, Permissions (1))


File System
ls - a #hidden files (shell config files in home, files starting with dot)
ls . or .. #. references working directory and .. parent
pwd #working directory 

less ~/.bashrc #tilde references home directory
less ~sam/.bashrc #references sam's home directory if you have access

mkdir -p #create a directory, -p to create multiple dirs in one command 
rmdir -f #removes dir, -f recursively delete sub directories and files

mv file subdir/ #move file from one dir to another
mv dir anotherdir #move one dir to another

Important Directories:
/               Root
/root           Root home
/bin            Command binaries
/sbin           Essential system binaries (utilities for system administration)
/boot           Static files of the boot loader
/dev            Device files with udev containing active devices
/home           Users home directories (MAC OS X uses /Users)
/lib            Shared libraries 
/lib/modules    Loadable kernal modules
/mnt            Mount point for temporarily mounting filesystems
/opt            Optional software
/sys            Device pesudofilesystem
/tmp            Temporary files

etc:
/etc            Machine-local system configuration files (includes /etc/passwd)
/etc/opt        Configuration files for add-on software packages kept in /opt
/etc/X11        Machine-local system configuration files for X Windows System

usr:
/usr            Includes subdirectories that contain information used by the system 
/usr/bin        Standard utilities not used in single user mode or recovery?
/usr/games      Games
/usr/lib        Libraries
/usr/local      Added files to system? what about /opt?
/usr/sbin       Mon-essential binaries 
/usr/share      architecture independent data
/usr/share/doc  documentation
/usr/share/info GNU info
/usr/share/man  Online manuals
/usr/src        Source Code

var:
/var            Variable data (log files)
/var/log        Log files
/var/spool      Spooled application data 


Access Permissions:
ls -l #display file permissions

Example: 
drwxr-xr-x  3 nemo  staff  102 May  8 14:23 another
-rw-r--r--  1 nemo  staff    0 May  8 14:56 test.txt

from left to right
1) type of file (- file, d dir)
2) access (owner/group/others)
3) ACL flag? (null in the example)
4) links to the file (1)
5) owner (nemo)
6) file group (staff)
7) size in bytes (0)
8) date created/modified (May  8 14:56)
9) name of the file (test.txt)

chmod #change access permission: a (all users) o (other users) g (group) u (user/owner) r (read) x (execute) w (write) +- (add/remove)

You can use numerics instead, 4 (read), 2 (write), 1 (execute) 
chmod 755 file #gives all to owner, read/execute to the rest

No comments:

Post a Comment