<<

terminal commands

Whoami, Where, When, What the bleep am I doing now? # bla # bla #date; ; ; cal 2006 bla #^D Ctrl+D close the terminal! #blabla Nothings happen…..

Navigating and Searching the System #pwd pwd ( working ) Where You Are # pwd -- # /usr/bin cd (change directory) Moving to Different a space is here! # cd .. Directories # cd home ! # /bin -name -print Searching Directories for # find /bin -name ‘*ls*’ -print Matching Files

Reading Directories and Files [Ctrl+D, Ctrl+U, Ctrl+H] ls (list directory) # ls # ls -F # ls -aF Listing Directories with # ls -l the ls # ls /usr/bin # ls /usr/bin a* # ls > f1 create the file f1 # f1 cat (concatenate file) Listing and Combining # date >f2 Files with the cat # cat f1 f2 > f12 # cat f12 # ls –l /bin > f1 create the file f1 Browsing Files with the using your cursor # f1 less or keys or ^B or ^F. # f1 #head -2 f1 bla, bla, bla head and # tail f1 # temp Creating Directories with # mkdir temp2 temp3 temp4 the mkdir # mkdir temp/child

Prof. Cezar Bruma Whoami_UNIX_FEDORA.doc printed 10/29/2006 UNIX terminal commands

# mkdir temp5/child Woops!!! …. # temp2 Woops!!! … # rmdir temp5 Try temp5. Removing Directories # rmdir temp5/ child with the rmdir This is tricky # rmdir temp* dangerous… Why? # ls /bin > f1 create the file f1 # f1 deleting f1

# ls > f1; date > f2; rm f1 f2 Deleting Files with the rm This is tricky # ls > f1; date > f2; rm f? dangerous… Why? This is tricky more # ls > f1; date > f2; rm f* dangerous… Why? # ls > f1; f1 f2 f1 will be f2 Renaming Files with the # mkdir temp; mv temp temp1 temp will be temp1 mv # ls > f1; date > f2; f1 f2 f1 remains Copying with the cp # mkdir temp; cp temp temp1 temp remains # ls>f1; ls –l; +x f1;ls -l Changing attribute with for files # chmod g-x f1; ls -l chmod

# mkdir t; ls –l;chmod –x t; ls –l for directories is the boss! # ls > f1; cp f1 t Woops…. # ls > f1; -s f1 f2 symbolic is Creating Symbolic Links merely a pathname, with the ln # ls -l f* or , to the original file. # date # ln –s /bin/date ddd # ddd # ls /bin | head Pipe # ls /bin | tail output | input # ls /bin | # -cvf - ./ | -9c > arhiv.tgz packaged Creating Archives with # gunzip - arhiv.tgz | tar -xvf - packaged the tar and gzip/ungzip # gunzip -c arhiv.tgz | tar -tvf - view

Using the The shell provides the interface to so you can run programs. # cat /etc/ | student csh, , ,rsh,.. my using SHELL # builtins for tcsh # alias

Prof. Cezar Bruma Whoami_UNIX_FEDORA.doc printed 10/29/2006 UNIX terminal commands

# cat > bob The computer waiting… date ls To end, Ctrl+C cal or Cntr+D ^D # cat bob # bob Woops …. # ./bob Woops …. # chmod +x bob # ./bob This is ! Script command!

Vi editor (universal UNIX editor) ADVICE1: If you do not know what to do click on Esc key! Then on u key (this is undo key). Till this advice will be the wrong one! ADVICE2: Think and try, NOT try and think. l one character right h one character left j one line down k one line up x delete character delete line i insert text (insert mode) a append text Esc Return to command mode :wq and quit :q! quit without changes Try a few more commands u Æ undo Ctrl+f Æ forward :/abba Æ search abba G Æ end file 3x Æ delete 3 characters Ctrl+b Æ backward 0 Æ line begin wd Æ delete a word Ctrl+D Æ 1/2 forward 7G Æ go to line 7 :! Æ write only Exercises (home work) Command What is it? Comments # ls --help # ls -a ls –a versus ls ? # ls –rt ls –rt versus ls – # ls –s /bin # ls –srtF /bin # cal 2006 # cal 2006 > f1; wc f1 # cal 2006 | grep A a script command with a lot of commands and play it. This is the fun part of the UNIX! # cal > f1 Use and write a file like f1 and name it f2 # f1 f2 You must receive … nothing on output. diff (difference)

Prof. Cezar Bruma Whoami_UNIX_FEDORA.doc printed 10/29/2006 UNIX terminal commands

Prof. Cezar Bruma Whoami_UNIX_FEDORA.doc printed 10/29/2006