Doc Steve
Web Coding Service

Fully Accessible Web Code, Custom Written by Hand
Specializing in html, xml, css, and U.S.§508

Utility Pages

[ Utility Pages Home ]

Commands on UNIX Systems

Emacs is a full screen editor available on most all UNIX systems. This editor is extremely broad ranged, and includes its own file management and mail system; however, its commands are so arcane as to be totally obtuse. That notwithstanding, it is pretty much the UNIX standard for editors, so it may pay to become familiar with it; Emacs is also available for Windows.

Page Index
[ skip index ]
[ Conventions for this help ] [ Environment Control ] [ Output & Help ] [ Process Control ] [ Environment Status ] [ File Manipulation ] [ Compilers ] [ Odds & Ends ]

[ TOP ]

Conventions for this help:

When a command is given, such as emacs, follow the command with the carriage return, send, enter key, etc. When the command includes the following control keys, it is generally not necessary to press the enter key.

<CTL>- press the CONTROL key simultaneously with the second key.
<ESC> press the ESCAPE key, then press the second key.
(on a true UNIX terminal, the META key)

Terms such as "filename" and "directory" mean insert the name of the file or directory; thus,
<filename> enter filename name as appropriate
<directory> enter directory name as appropriate
<CR> press the "enter" (or analogous) key at this point
<command> enter a command name as appropriate
<name> enter a name as appropriate
<node> enter a computer node name (domain name, ip address) as appropriate
<variable> enter a variable name as appropriate
<value> enter a value as appropriate
<n> enter a number as appropriate
And so forth;
[] optional argument
... ongoing list

[ TOP ]

Environment Control

Your goal What you type
Change directory cd <directory>
Create new directory mkdir <directory>
Remove directory rmdir <directory>
Move file to directory mv <filename> [ <filename2 ... ] <directory>
Rename directory mv <directory> <directory2>
Change password passwd
Create command alias (csh/tcsh) alias <command> <name>
Create command alias (ksh/bash) alias <command>="<name>"
Remove command alias unalias <name1> [ <name2> ... ]
Login securely to remote node ssh <node>
End terminal session exit
Set environment variable to value (csh/tcsh) sentenv <variable> <value>
set environment variable to value (ksh/bash) export <variable>="<value>"

[ TOP ]

Output & Help

Your goal What you type
Output file to line printer lpr -P <printer> <filename>
lp -d <printer> <filename>
Save terminal session script [ <filename> ]
Stop saving terminal session exit
Unix manual entry for a command man <command>

[ TOP ]

Process Control

Your goal What you type
Interrupt processes CTL-c
Stop screen scrolling CTL-s
Resume screen output CTL-q
Sleep for n seconds sleep <n>
Print list of jobs jobs
Kill job <n> kill % <n>
Print process status stats ps
Remove process <n> kill -9 <n>
Suspend current process CTL-z
Suspend background job n stop %n
Run commamd in background <command&>
Resume background job n bg [ %<n> ]
Resume foreground job n fg [ %n ]
Exit from shell exit

[ TOP ]

Environment Status

Your goal What you type
List files in directory ls [ <arg> ] [ <directory> ] [ <filename> ] [ ... ] [ more ]
Display command aliases alias [ <name> ]
Print environment values printenv [ <name> ]
Display disk quota quota
Print date & time date
List logged in users who
Display current user whoami
Output user information finger [ <username> ]
Change finger information chfn
Print working directory pwd
Display recent commands history
Submit recent command n ! <n>
Show disk space available on the system df
show how much disk space is being used up by folders du

Additional Notes: ls


ls "ListS" files. To list files in detail, the following options (among many others) are available:

ls -l  [ <filename> ]

The "-l" option provides a general "long" listing, with details on each file.

ls -Aog  [ ... ]
ls -Aogrt  [ ... ] (by reverse time)

The "Aog" option provides a similar but somewhat cleaner format than "l" and also displays files beginning with "." (but not the "." and ".." directory listings).

[ TOP ]

File Manipulation

Your goal What you type
start "Emacs" fullscreen editor emacs [ <filename> ] [ more ]
start "Vi" fullscreen editor vi [ <filename> ] [ more ]
start Text editor ed [ <filename> ]
List file contents by screen more <filename>
less <filename>
Rename (move) file mv <filename> <filename>
Copy one file to another cp <filename> [ <directory> ]<filename>
Delete (remove) file rm <filename>
Output lines that match pattern from file grep '<pattern>' <filename> [ more ]
Line, word, & char count wc [ <filename> ]
Concatenate multiple files into single (target) file cat <filename> <filename> [ ... ] > <filename>
Change execution modes of file chmod <mode> <filename> [ more ]
List contents of file cat [ <filename> ]
Compare two files cmp <filename> <filename>
Alphabetically sort file sort <filename>
Split file into n-line pieces split [ -n ] <filename>
Lists file differences diff <filename> <filename>
Output beginning of file head
Output end of file tail

Additional Notes: vi, grep, chmod


vi - - the "VIsual editor" - - is a simple editor with maddeningly obscure commands.

First things first: To get out of the VI editor . . .

<ESC>:q<CR>       (to quit)      
<ESC>:x<CR>       (to save and exit)    
<ESC>:quit!<CR>   (quit with no save [abandon changes])

If you absolutely must use the VI editor, then:

<ESC>     switch to command mode
i         switch back to insert-text mode (type at will: arrow keys move cursor)

About command mode:

<ESC>     switches to command mode or may be thought of as a prefix to a command.

x         delete current cursor position (without the leading colon)
p         undelete
h,j,k,l   cursor left,down,up,right

grep "Gets REgular ExPressions" - - or something like that. At it's most basic, the syntax is

grep <regular expression> <target file>

Just about any matched pair may be used as the regular expression delimieter, so all of the following are legal:

grep /some pattern/ file.file
grep 'some pattern' file.file
grep \some pattern\ file.file   

grep options begin with a dash, which can be confusing (to the program) if the pattern begins with a dash, so these also works:

grep -e some pattern file.file
grep -e some --regexp=some pattern file.file  

There are scads of options: extensive help is at grep.


chmod "CHanges MODe" of the file. Modes are if the file can execute, and who has access to it. Basically, the syntax is as follows:

chmod owner/group/others

with a summing numeric code:

0 = no access
1 = execute access
2 = write access
4 = read access 


3 = write/execute access
5 = read/execute access
6 = read/write access
7 = read/write/execute access  

The numbers (1 to 7) are given for each grouping, thus

chmod 666 <filename> 

gives all categories of users read/write access

Alternatively, access may be set for all groups using single characters, r (read), w (write), and x (execute), +/- for on/off:

chmod +x <filename> --OR--
chmod -x <filename> --OR--
chmod +rw <filename> --OR--
chmod +rwx <filename> ...  

[ TOP ]


Your goal What you type
C compiler cc [ -o <filename> ] <filename>
Check C code for errors lint <filename>
Fortran77 compiler f77 [ -o <filename> ] <filename>
Pascal compiler pc [ -o <filename> ] <filename>

[ TOP ]

Odds & Ends

Your goal What you type
A simple calculator bc (arguments in one line, e.g., 8*2; exit with quit)

Document: http://

Made with Cascading Style Sheets  | Valid CSS!  | Valid XHTML 1.1!  | Level Triple-A conformance icon, W3C-WAI Web Content Accessibility Guidelines 1.0  | Bobby WorldWide Approved AAA

Contact DocSteve

Copyright © 2004
Steve Sconfienza, Ph.D.
All Rights Reserved