Required Unix commands: Help commands (to see the manual): To find out the syntax and options for xxx: man xxx -- To redo a command: use up-arrow to see recent cmds -- Quota commands: How to determine your quota (in disk space and files): quota -v -- Directory commands: To create a new directory: mkdir hw1 To remove a directory: Remove the files in it first. rmdir hw1 To move to a child directory: cd hw1 To move to the parent of a directory: cd .. To move to your home directory: cd ~ or: cd ~z123456 To move to a sibling directory (i.e., directory moves can be stacked to any degree desired): Assuming you are in ~/hw1, you can move to ~/hw2 via cd ../hw2 To find out what directory you are in (print working directory): pwd Note: . = current directory -- File listing commands: To list all the files in the current directory in alphabetical order: ls -Als | less To list all the files in the current directory in reverse date/time order: ls -Alst | less To find out all the options for 'ls' so you can pick your favorites: man ls "| less" pipes the output of ls into the file reader "less". -- 'less' file lister commands: space = page forward b = page back /xxx = search forward for xxx man less = learn all the 'less' commands -- File maintenance commands: Within a diretory: To copy a file: cp -i -p file1.txt file2.txt To remove (delete) a file: rm -i file1.txt To rename a file: mv -i file1.txt file2.txt From one directory to another (some examples): From the viewpoint of the parent directory: cp -i -p hw1/file1.txt hw2/file2.txt From the viewpoint of one of the sibling directories: cp -i -p file1.txt ../hw2/file2.txt If you don't want to change the name, you can omit it: cp -i -p hw1/file1.txt hw2 ** However, if hw2 does not exist, you will create a new file in the current directory instead! cp -i -p file1.txt ../hw2 -- Protection commands: File protections are uuugggwww where u = user, g = group, w = world 4's position = read 2's position = update 1's position = execute (for a file), descend into it (for a directory) chmod 600 file1.txt = I can read and update my file chmod 644 file1.txt = I can read and update, other people can only read chmod 700 dir1 = I have full use of my directory chmod 711 dir1 = I can use my directory, you can descend into it chmod 755 dir1 = I can use my directory, you can see what's in it -- emacs editor commands: emacs pgm1.cc - start editor C-x C-c = exit (will prompt for save) C-x C-s = save -- Sample makefile (in fib1 directory): fib1: fib1.o g++ -Wall -o fib1 fib1.o fib1.o: fib1.cc g++ -Wall -c fib1.cc clean: -rm *.o fib1 To compile and link: make fib1 To run: ./fib1 To clean up before submitting: make clean To submit: ---------- Additional useful Unix commands: - cat -n -v -e -t - cat |less - diff - I/O redirection - I/O redirection with >> for append - I/O redirection with &> or >>& - piping - csh alias - csh history - .cshrc - set noclobber - od options - limit coresize 0 - touch core; chmod 000 core