This is an old revision of the document!
UNIX Command Reference
The command prompt in UNIX is called the shell. Here is a list of common UNIX commands which will work across many different versions of UNIX with discrepancies in Example/Notes.
Command | Description | Examples | Notes | ||||
as | ASsembler | as input.s | |||||
cc | C Compiler | cc input.c | Creates an executable named a.out by default | ||||
cd | Change working Directory | cd /usr/local/games | on Version 6 this command is chdir | ||||
df | Disk Free | df | Displays summary of free disk space. May take time to complete on some systems | ||||
ed | EDitor | ed filename | ED is the standard (line) text editor | ||||
echo | Echo | echo ${HOME} | Prints the value assigned to the variable HOME | ||||
env | ENVironment settings | env | Displays the shell environment settings (see set)) | ||||
ld | Link Loader | ld inputfile | |||||
ls | LiSt directory | ls -l | provides a long LiSting | ||||
man | MANual | man ls | On some systems, displays online manual pages. Try “man man” to learn more about “man.” | ||||
ps | Process Status | ps -a or ps -l | prints All or Long Process Status | ||||
pwd | Present Working Directory | pwd | Prints the working directory | ||||
set | SET or display shell parameters | set | Sets or displays the shell environment settings (see env) | ||||
vi | VIsual editor | vi filename | vi is a screen editor |
On some systems typing games will print a list of games.
directory | description | ||
/ | This is the top level or root directory | ||
/bin | common user programs are here (type echo ${PATH} to see more | ||
/etc | This is the system directory | ||
/lib | System library files | ||
/usr | “Unix System Resources” or “USeR” directory, depending on who you ask - contains additional binaries, libraries, manpages | ||
/usr/games or /usr/local/games | Usually contains the standard UNIX games |
Useful UNIX References
The UNIX Programmer's Manual (7th Edition) is an excellent overview for using UNIX for software development.
man.cat-v.org provides HTML-ized versions of man pages for many historical UNIX systems.
Old Unix XRef gives a very nice cross-indexed look at the 2.11BSD UNIX source code, if you're interested in seeing how the system is constructed from the kernel on up, or if you're interested in hacking the kernel source yourself.
Using the C Compiler
This wiki cannot provide an extensive tutorial for the C language, but we'll provide an example or two to get you started. The C Programming Language is the classic reference for this (and belongs on every UNIX hacker's bookshelf) and should apply to all of the UNIX systems we have online (although some may also support the later ANSI C specification(s) as well.
Use the editor of your choice to create the source file. We'll use ed here, as it's common to all UNIX systems, but vi may be a more friendly choice.
$ ed hello.c ?hello.c a int main(argc, argv) int argc; char** argv; { printf("Hello, world!\n"); return 0; } . w 98 q $
You should now have a file on disk named “hello.c”:
$ ls -l hello.c -rw-rw-rw- 1 user user 98 Apr 9 02:36 hello.c $
This new C source file can be compiled into an executable using cc. The simple syntax for this is:
$ cc hello.c $
This produces an output file named a.out. You can run this directly:
$ ./a.out Hello, world! $
Optionally, you can use the “-o” compiler flag to specify the output filename:
$ cc -o hello hello.c $
Which will produce an output file named hello.
$ ./hello Hello, world!