UNIX Commands Basic (Version 010999) #################################### Connect: -------- ssh [host] Secure telnet to host telnet [host] Connect to host (Ports: 25 (SMTP), 110 (POP3), 21 (FTP), 20 (FTP data) ) rlogin -l [username] Connect to host with username ftp -i [host] File transfer with host (-i (don't prompt when using mget), hash (status)) for ftp commands see below: File transfer & Mail) ftptool / xftp X-window based FTP prgram get (get file from ftp), mget (get multiple files), put (upload file) mput (put multiple files) talk [username@host] Talk to username at host passwd / yppasswd Change password xhost +/- hostname Allow host to open X-Window on local machine (setenv DISPLAY host:0.0) exit Log out from ssh, telnet, rlogin quit Log out from ftp Mail: ----- mailx Read mails mailx -s [subject] [user] Send mail to user ("." (finish) q (quit), x (quit without changing), n (next), d (delete), r (reply), h (display mails) ) Mail for powerusers: -------------------- telnet host 25 SMTP (helo (authorize), mail from: (snd address), rcpt to: (rec address), data (mail body), "." (finish) ) telnet host 110 POP3 (user [username], pass [password], uidl (listmails), retr [n] Connect info: ------------- who Who is connected w Similar to who just displays more info, like processes and load finger [-l @host] Display info about logged on users finger [user] Display info about user rusers Scans the whole remote network for connected users whoami Display my user name Jobs: ----- jobs List jobs running in the background ps List current processes (ps -aef | grep $USER) Suspend kill [pid] / Kill a process (use pid returned by ps) fg [num] Send to foreground (use num returned by jobs) bg Send to background Returns num to use when calling fg comm & Execute command in background Stop output Continue Directories: ------------ pwd Print current working directory cd [dirname] Change to directory dirname (cd without dirname wil go to your home directory, cd .. moves one directory up, cd ~username moves you to username's homedir) mkdir [dirname] Make directory dirname rmdir [dirname] Remove the directory dirname Files: ------ ls -l List files (-a (list invisible files), -d (don't list contents of a folder), -R (recursively subdir listing) ) mv [old] [new] Move or rename a file or directory (no -r needed) cp [-r file] Copy file (-r (copy directory) ) rm [-rf file] Remove file (-f (don't prompt user), -r (remove directory) ) chmod [o+r file] Change access for file {u=rw,og+r,a-w} chmod [ugo] 4=r 6=rw 5=rx 7=rwx {644=rw_r__r__} umask [x] Sets the default permissions new files will have. It is recommendes to set it to 22 or 77 Without param=disp with=set {27=rwxr_x__ 77=rwx______} more [file] Type file (b=back, v=VI, /[string] (search for string) ) cat [file1 file2] > targetfile Concatenate files split -b [bytes file] Split file to packets with size bytes find [path] -name ['name'] Searches for files wich match name exactly but you can use 'name*' for example to look for file witch start with name volcheck Mount floppy, content will become visible in /floppy/floppy0 eject After leaving the /floppy/floppy0 directory ejetct the disk fdformat Format a floppy fddisk -fmt -f /dev/rfd0a Format a floppy mformat a: Format a floppy for DOS mcopy [unixfile a:dosfile] Copy to a dos disk or the other way round mdel [a:dosfile] Delete a msdos file dos2unix [file] Convert file to unix unix2dos [file] Convert file to dos perl -p -i.old -e 's/\r/\n/g' [files] Replaces returns with linefeeds (convert from mac to unix or dos to unix) diff [file1] [file2] Compares two files touch [filename] Creates a new empty file named filename Programming: ------------ make Build source code cc C Compiler gcc [file.c] C Compiler g++ [file.C] C++ Compiler cxx C++ Compiler adb / dbx Debugger javac [file.java] JAVA-Compiler pc Pascal compiler Comprimation: ------------- gzip [file] Compress file (.gz) gunzip [file] Decompress file (.gz) tar -cvf [targetfile.tar] [source] Create archive (.tar) from multiple source files tar -xvf [file] Unpack archive (.tar) tar -tvf [file] List archive (.tar) doesn't expand the archive compress [file] Compress file (.Z) uncompress [file] Decompress file (.Z) Printing: --------- lpr [-P[printer] file] Print file on printer (-K2 (double sided), -#2 (two copies) ) lp [-d[printer] file] Print file on printer (-K2 (double sided), -n2 (two copies) ) lpq List queue lprm [job-ID] Remove job from queue mpage -[num] -h [file] | lpr Print num pages on one page with header (-h option) lpstat -a List all available printers a2ps Convert text files to ps (nicely formated) Special: -------- man [comm] Get info about command (-k keyword) apropos [expr] Get info about related commands where [comm] Show path of command grep -e [expr] [file] Filters out lines containing expr (-i (not case sensitive), -c (count only), -v (inverse) ) nslookup Resolve domain names (server [dnsserver] (specify damain e.g: trevano.ch) lynx Text based version of netscape (g (go), q (quit), left (back), enter (follow link), Search: http://www2.infoseek.com) [comm] > [file] Write output of com to file [comm] >> [file] Append output of command to file [comm] < [file] Content of file => input of command [comm1] | [comm2] Output of command1 => input of command2 alias [alias comm] Define alias for long commands perl -p -i.old -e 's/oldstring/newstrin/g' *.txt Search and replace of a string in multiple files clear Clear screen Navigation inside more, man, ... -------------------------------- Moves one page down b Moves one page up Moves one line down q Quit VI: --- Command mode i Insert I Insert at beginning of a line a Insert after A Insert at the end of the line o Insert a line below O Insert a line above J Connect this and the next line r Change char R Overwrite x Delete char [n]x Delete n characters (starting at cursor position) dw Delete word dd Delete line D Delete rest of line gq Reformat lines (useful with indent for example) h / l Move left / right j / k Move down / up w,b Move cursor one word 0 Jump to beginning of line $ Jump to end of line gg Go to top G Go to bottom :[n] Goto line n H Home L End M Middle p Paste below (copy: yy cut: dd) P Paste above (copy: yy cut: dd) u Undo ctrl + r Redo ctrl + f Page down ctrl + b Page up :/[string] Search for string :?[string] Search backwards :%s/[old]/[new]/g Replace all strings old with new :5,10s/[old]/[new]/g Same as above but only lines 5-10 !! Execute command and insert output :! Execute command :w [file-name] Save (file-name only needed when new file) :w! Force save (needed when file owned by you but readonly) :n Edit next file :q Exit :x Save and exit X-Windows Programs: ------------------- xterm / dtterm Terminal xmailtool / mailtool Mail emacs / textedit Word processor xcalc Calculator xv Graphic viewer and converter xlock Lock up Shell scripts: -------------- starts with: #!/bin/sh, contains command lines, must have x-permission, start with ./Scriptname, *=any string (except .), ?=any char, [a-d]=any char from a to d (lower case), be carefull with special chars &=\& Alta-Vista: ----------- Standard: <+> = AND = OR Advanced: AND OR NEAR URL () * (e.g: apple* AND ((quicktime OR video) NEAR 3.0) ) The following stuff is for users inside the ethz.ch or switch domain only!!! ============================================================================ Switch-Services: ---------------- Gateways: Dokumentation siehe: http://www.switch.ch/switch/mail/ SMS number@sms.switch.ch Pager number@pager.switch.ch Fax number@fax.switch.ch Telefonbuch http://www.switch.ch/switch/info/etv.html telnet://etv@etv.switch.ch/ http://switch111.switch.ch/111/ By Boris Lutz