Listing and Moving Files and Directories

mv – MoVe – move file(s) from one location to another, same as cp except it removes files afterwards

rm – ReMove – delete files – example: “rm *.o”

cd – Change Directory – example “cd /tmp”

mkdir, rmdir – MaKe DIRectory and ReMove DIRectory

ln – LiNk – make a link to a file – two types of links, normal and symbolic – example: “ln -s original newlink”

Special Directories – ‘.’ is current, ‘..’ is current’s parent, ‘~’ is home, and ‘/’ is the root (or top) of all directories

Redirection and Shell Stuff

| – Pipe, one of UNIX’s best features, used to send output from one program to be input to another – example: “ls -l | grep uzi”

>, >>, < – Redirect output of a program to a file, append output to end of a file, and get input from a file – example: “./a.out < input > ouput”

*, ? – Wildcards – used to specify any number (including zero) of any character for ‘*’, and any one character for ‘?’ – example: “ls *.?”

$var – An environment variable, where “var” is the name and a value can be seen using “echo $var”

set, setenv – used to set environment varibles, depending on shells.

Managing File Permissions

Sample “ls -l /bin/ls” output: -rwxr-xr-x 1 root root 29980 Apr 23 1998 /bin/ls
– First ten characters are the file’s permissions. First is file type, ‘-‘ for normal, ‘d’ for directory, ‘l’ for symlink, etc.
– Three sets of three characters of “rwx”, or Read, Write, Execute permission – first for owner, then group owner, then everyone.
– Then we have number of links to file, owner of the file, group owner of file, file size, date it was last modified, and the file’s name.

chmod – Change a file’s mode or permissions – one way is to use octal numbering – example: “chmod 751 /bin/ls” for rwxr-x–x

chgrp – Change a file’s group – example: “chgrp users /bin/ls”

chown – Change a file’s owner – example: “chown uzi /bin/ls”

umask – Set default file permissions (generally, do the opposite, or “777 minus what you want”)