UNIX Tips & Notes Will Polik DOS-like commands: ls DIR cp COPY rm DEL cd CD rmdir RD mkdir MD mv MOVE ls options: -a all files (-A is all files except . and ..) -l long format -F indicate directory (/), executable (*), socket (=), symbolic link (@) -d list directory name only, not contents -C list filenames in column format (-x in row format) Changing file ownership: chown chgrp Changing file permissions: chmod [ugoa][+-=][rwx] chmod u+x gives execute access to user for executing scripts, etc. chmod u+t sets sticky bit access so that users may delete files which they own only, even though others have directory write access chmod +x makes a script executable by all Getting information: pwd print working directory who show users on system w show users on system and what they are doing who am i show user of current shell/window printenv show environment strings aliases show defined aliases Printing a file: lp sends file to line printer pr | lp formats a file and then prints it viewing a man page: man view a man page apropos search for appropriate man pages man -t print a man page man -d display specific man file (*.z, *.Z or *.#) Showing an killing processes: ps -l show processes (owned by the current process) in long format ps -u -l show all processes owned by user Using tar: tar tvf list files in tar file tar xvf extracts files in filename.tar relative to current directory (from root, add o option) tar cvf tar a directory and its contents Copying directory trees: mkdir cd tar cpvf - . | (cd ; tar xf -) Using gzip/gunzip: gzip -l Using tar and gzip/gunzip: gunzip -c | tar tf - list filenames in zipped tar file gunzip -c | tar xvf - extract files in zipped tar file (from root: add o option, sudo before each command) Compiling a Fortran program: f77 -o make Moving a foreground job into background: ^Z to suspend current job BG to move most recently suspended job into background jobs to view status of jobs Saving program output: script saves a typescript of session into file; session ends with exit command Finding files: find -name "" find files named below directory find -mtime -1 find files modified less than 1 day ago find -mmin -5 find files modified less than 5 minutes ago find -newer "" find files newer than Finding text strings: find . -name "*" -exec grep "string" {} /dev/null \; find string in any file below current directory Dispaying installation information (IRIX): versions display subsystems versions list display files Becoming another user: su become superuser, inheriting current environment su - become superuser, simulating login su become (no password prompt if superuser) login login as exec login login as Translating seconds since 1900 to a readable date perl -e '@c = localtime(123456789); print join("-",1+$c[4],$c[3],1900+$c[5])," ",join(":", $c[2], $c[3]),"\n";'