Quick notes on UNIX commands.
Unix provides shells that allow a user to interface with the "kernel" (lower level of the operating system). Unix shells are traditionally CLIs (Command Line Interface) where users can type to interface, but can be GUI (Graphical User Interface).
Here are some of the shells available for Unix, in rough historical order and complete with the original bad puns:
/bin/sh. By Steve Bourne at Bell Labs in 1978 for Unix 7. Bourne shell and its derivatives usually have a CLI prompt ending with $./bin/csh. By Bill Joy (creator of BSD UNIX) in 1979 for BSD. C shell and its derivatives usually have a CLI prompt ending with %./bin/ksh or /usr/bin/ksh. By Dave Korn in the early 1980s./usr/bin/bash, or /usr/local/bin/bash. By Brian Fox in 1987. Probably the most popular shell as of 2005. bash has even been ported to Windows by Cygwin.com. GNU.org/software/bash/ /bin/tcsh, /usr/bin/tcsh, or /usr/local/bin/tcsh. By Ken Greer in the 1970s.
In one sense X Windows System of Unix, the Window OS of Microsoft, and the Mac OS, are all GUI "shells". Apple/Mac uses AppleScript, but MacOS X uses bash. Microsoft Windows users will compare the Unix shell to DOS or the Windows CLI opened up via command.com or cmd.exe. Windows shell scripts are wsh. The DOS prompt usually ends with >.
STDIN. Standard Input is where data comes from --usually the keyboard.<. Redirects STDIN from a file. EG: This displays text from a file instead of STDIN:sort < source.txt
Displays the following on the monitor:
Hello world!
<<. Redirects STDIN until a predefined marker is reached. EG: This outputs to a file until the marker.cat > foo.txt << MYSTOP Hello world! Hello shoe! MYSTOP
STDOUT. Standard Output is where data goes out from ) --usually the monitor.>. Redirects STDOUT to a file. EG: This writes a line to a file instead of STDOUT:cat > newTarget.txt Hello world! ^D
>>. Redirects STDOUT to append to a file. EG: This appends a line to a file:cat >> oldTarget.txt Hello world again! ^D
STDERR. Standard Error is where error messages go to --usually the monitor.For a full directory of commands see http://linux.oreillynet.com/linux/cmd/.
Unix is not DOS! EG:
DIRECTORY COMMANDS cd Change the working directory find Find a file by name or by other characteristics mkdir Make a directory rmdir Remove a directory
FILE MANIPULATION COMMANDS cat Concatenate and display a file chmod Change the permissions mode of a file chown Change the owner and/or group of a file cp Copy a file diff Display differences between pairs of text files grep Search a file for a specific text string mv Move or rename a file rm Remove a file
DISPLAY COMMANDS date Print the date and time finger Display information about a user head Display the first few lines of a file less Browse a text file ls List the contents of a directory man Display a reference manual page more Display a text file pwd Display the working directory pathname tail Display the end of a file who Display who is on the system
PROCESS COMMANDS exit Terminate a process kill Terminate or send a signal to a process passwd Create or change a password ps Display the status of a process telnet Connect to a remote system using the Telnet protocol
COMMAND MODIFIERS < input. EG: sort < test.txt << here. EG: cat > foo.txt << MYSTOP > overwrite. EG: cat > newTarget.txt >> append. EG: cat >> oldTarget.txt | pipe. EG: cat student.txt|head - parameter EG: cat student.txt|head -5
COMMANDS IN ALPHABETICAL ORDER cal calendar -also m & year cat catenates/displays cd change directory chmod change access modes 4=r,2=w,1=x chown change the owner and/or group of a file clear clear screen cp copy date display date diff display differences between pairs of text files echo repeat input to output find search sys for filenames grep search files for text patterns head show first few lines of file kill terminate a running command less browse a text file ln create links/aliases ls -l list files -l=long format man manual more displays with scrolling, etc mkdir make directory mv move or rename passwd password change pwd print working directory (tree) rm remove files -r for nonempties rmdir remove directory strings search binaries for text patterns tail show last few lines of file wc count lines, words, characters who show who is logged on, am i=user
ERASE ^h BS 1 character KILL ^u NAK whole line NL ^j LF pass input EOF ^d EOT conclude input (^c ETX) STOP ^s DC3/XOF temporary stop START ^q DC1/XON resume (or any key) INTR Del DEL interrupt all (^c ETX) QUIT ^\ FS as INTR but saves copy as core EOL ^' NUL
/sbin/shutdown -r now Reboot the computer (alt-ctrl-del) /sbin/shutdown -h now Shutdown (halt) the computer
KEY REGULAR EXPRESSION ITEMS . 1 char * 1+ chars [<specific chars>] specific chars [a-z] small chars [^a-z] all chars but a-z ^ search at beg of lines $ search @end
Emacs and vi compete for the position of most common common text editor for UNIX. vi is a screen oriented text editor written by Bill Joy in 1976. See also Learning vi -- the "cheatsheet" technique [§].
General
vi file = opens/makes file in normal/edit/vi mode vi +n file = opens file at line n ZZ = :wq = quits & saves
Commands or ex mode.
<ENTER> = <ESC> = <DEL> = ^c = returns to normaedit/vi mode :q!<ENTER> = does not save then quits :w<ENTER> = saves then continues :wq<ENTER> = saves then quits :w file<ENTER> = saves to file :n,m w file<ENTER> = write lines n thru m to file :n,m w >> file<ENTER> = appends lines n thru m to file :r file<ENTER> = retrieves and inserts file at the cursor :n<ENTER> = nG= go to line n :e +n file<ENTER> = edit file at line n :set showmode<ENTER> = gives clue if in insert mode :s/oldText/newText<ENTER> = substitutes oldText with newText once in current line :s/oldText/newText/g<ENTER> = substitutes all occurrences in current line :n,ms/oldText/newText/g<ENTER> = substitutes from line n to m :%s/oldText/newText/g<ENTER> = substitutes in whole file :%s/oldText/newText/gc<ENTER> = and also ask for confirmation :!ExternalCommand<ENTER> = execute command. EG: :!ls or :!dir or !del file or !rm file :help<ENTER> = help window :q<ENTER> = quits help window :help command = get help on a command
From normal/edit/vi mode, move cursor:
h = left j = down (hooks down) k = up l = <SPACE> = right w = W = next word b = B = beginning of previous word e = E = end of next word 0 = <HOME> = start of line $ = <END> = end of line ^ = 1st char of line + = <ENTER> = 1st char next line - = 1st char previous line G = go to start of last line nG = go to start nth line ^g = show current file & line # ^<HOME> = go to start of file ^<END> = go to end of file H = go to head of screen M = go to middle of screen L = go to last of screen ^f = scroll forward ^b = scroll backward z<ENTER> = current line becomes head line of screen z. = current line becomes middle line of screen z- = current line becomes bottom line of screen nz<ENTER> = line n becomes head line of screen nz. = line n becomes middle line of screen nz- = line n becomes bottom line of screen /text<ENTER> = search for text ?/text<ENTER> = search backward for text /<ENTER> = repeat search forward ?<ENTER> = repeat search backward n = repeat search in same direction N = repeat search in opposite direction :ic<ENTER> = sets ignore case :set hls is = sets highlighting of all matches :nohlsearch = turns of highlighting of matches % = find matching ), ], or }. mx = marks x `x= go to x 'x= go to line of x `` = return to previous location ''=return to previous line
From normal/edit/vi mode, edit text:
itext<ENTER> = insert text before cursor Itext<ENTER> = insert text at start of line atext<ENTER> = append text after cursor Atext<ENTER> = append text at end of line otext<ENTER> = open a new line below the cursor for text Otext<ENTER> = open a new line above the cursor for text dObject = delete Object (such as: is w, e, $, ^, G) ndObject = dnObject = delete n Objects D = d$ = delete rest of line dd = delete entire line ndd= delete n lines u = undo last change U = restore line ^R = redo p = pastes/puts deleted or copied before cursor P = pastes/puts after cursor rx = replace current char with new char x Rtext<ESC> = replace starting at current char cObjectText<ESC> = change Object by inserting Text ncObjectText<ESC> = cnObjectText<ESC> = change/insert n Objects CText<ESC> = c$Text<ESC> = change/insert to end line ccText<ESC> = change/insert entire line J = joins 2 lines yy = copy current line x = delete under cursor X = delete before cursor xp = switches 2 chars ddp = switches 2 lines
From insert mode
Esc=Del=returns to edit/vi mode BS=^h=Dels last character ^w=Dels last word ^u=Dels whole line
Until 2003, Unix could run on 64 bit CPUs while Microsoft Windows could only run on 32 bit CPUs.
More than 50% of web servers are Unix-based Apache.org web servers. Microsoft's IIS web server comes in second.
Page Modified: (Hand noted: 2007-09-19 19:17:23Z) (Auto noted: 2007-11-17 06:37:41Z)