Unix operating system provides powerful environment for program development. A user of a UNIX system communicates with the operating system through the commands entered at a shell prompt. The commands allow to manipulate files, edit, compile, execute and debug programs as well as communicate locally or over the network.
UNIX has a tree like file system. Each directory may contain multiple files and multiple sub-directories. A path to a file is specified by stating names of all subdirectories separated by a slash "/" leading to that file. A path may be given with respect to the current directory or the root directory. The latter begins with a slash "/". The parent directory can be specified by "..". Each user has a home directory. The home directory can be specified as "~".
Multiple files can be specified by using wild-card symbols. "*" denotes any string of characters of any length whereas "?" denotes any single character.
- ls Lists contents of the current directory.
- ls D Lists particular directory D.
- ls -l Lists the directory in long format.
- cd D Change current directory to D.
- cd Return to the home directory.
- cd .. Go to the parent directory.
- mkdir D Create directory D.
- rmdir D Remove directory D.
Each file has several access flags. The flags determine if the file is accessible for reading (r) writing (w) or executing (x). Three sets of these flags are present. One for the user himself (u), another for other users (o), and the third for user's group (g).
- cp F1 F2 Copy file F1 into F2.
- ln -s F1 F2 Make F1 synonym (symbolic link) to F2.
- mv F1 F2 Move file F1 into F2.
- rm F Remove file F1.
- cat F1 F2>F3 Concatenate file F1 and F2 into F3.
The directories also have the same flags. Their meaning however is the following: r - permit listing, w and x - permit changing or removing, x - permit accessing files by name.
- chmod set+flags F Add access flags on file F. (For instance: chmod u+wx F - permit writing and executing F).
- chmod set-flags F Remove access flags on file F. (For instance: chmod u-w F - disallow writing into F).
- umask flags Set default flags for newly created files.
- df List mounted file systems and their usage.
- du List space usage of current directory.
Every user can execute multiple executable programs -- jobs -- processes. A process can be running in the foreground, taking input from standard input devices and producing output to standard output devices. It can also be running in the background, for instance to perform prolonged computation. When in the latter state, a process don't have to communicate with standard input output devices thus freeing them for some foreground process.
To start some executable program it suffices to type the name of the file storing that program at the shell prompt. It is possible to redirect standard input and/or output of the programs so that they use some files instead of keyboard and the monitor:
- jobs List jobs.
- bg J Put a foreground job J into the background.
- fg J Put a background job J into the foreground.
- kill J Kill the job J.
- [ctr]-z Usually stops current job.
The commands entered at the shell prompt are remembered and can be recalled by special commands.
- P < F Redirect standard input of P to the file F.
- P >> F Append standard output of P into the file F.
- P > F Redirect standard output of P into the file F.
- P 2> F Redirect standard error of P into the file F.
- P1 | P2 Pipe the standard output of P1 into standard input of P2.
To terminate session of work with the operating system, a user should execute the command: logout.
- history Display history of commands.
- !N Execute Nth command from the history list.
- !! Execute last command.
It is possible to use another Unix computer (host) remotely.
- rlogin H Login into host H.
- logout Exit from the remote system.
It is possible to communicate to other users locally or over the network. The address of the user U working on a computer H is U@H.
- finger U Show some info on user U.
- talk U Try to talk to a user U ([ctr]-d to quit).
- mail U Mail to user U. Allows to type a message which can be finished by typing single "." in the beginning of a new line.
- mail List received messages. The following commands can be typed at the mail's prompt: ? Help on using mail. h List messages. d N Delete message #N. s N F Append message #N to file F. r N Respond to a message N. q Exit mail.
Most Unix commands and application programs have their manual pages with plenty of helpful information.
- man -k W Find info on keyword W in the manuals.
- man N W Display info on the topic W from the manual N.
- find D O Find file recursively in directory D, where the options O can be -type T Where T is f when searching files or d when searching subdirectories. -name N Name of the file or the directory. -print Display the results of the search. For example: find . -type file -name a.out -print
- grep S F Search for a string S in files specified by F.
- lpr F Print file F.
- lpr -Plp F Print file F on printer lp.
- lpq -Plp Show queue on printer lp.
- gcc F.c Compile F.c. Produces executable a.out if successful.
- gcc -g F.c Compile with debug info.
- gdb a.out Debug a.out.
- date Display current date and time.
- mach Display processor type of the host (mc68020,sparc,...)
- tty Display symbolic name of the terminal.
- passwd Change the password.
- chsh Change shell.
Multiple files can be packed and compressed together into a single file. Most common of such archives have name extension .tar.gz. Tape archiver tar is responsible for concatenating a group of files together and compressor gzip is responsible for compressing the resulting single file.
- gzip F Pack a file F into F.gz.
- gzip -d F.gz Unpack F.gz.
- tar cvf F.tar D Creates archive F.tar by archiving files in D recursively including in all subdirectories.
- tar xvf F Unpack .tar archive.
- script F Starts new shell where every console output goes to file F. Execute command: exit to stop.
- more F View file F.
- clear Clear the screen.
- emacs F Edit a file F.