Unix cheat sheet

This is a very simplified and rough introduction to using a terminal on a unix machine. The unix command line interface is a very powerful environment and there is much more to it than described here.

This document describes:
  1. Some useful concepts
  2. A brief overview of the command line shell
  3. Directories and the file system
  4. Working with files
  5. Reading the contents of text files
  6. Invoking executables
  7. Redirection and pipes
  8. Permissions and access

1. Some useful concepts

This is a a brief overview of some useful concepts in unix
  1. The Shell: Although Unix has a graphical interface called X Windows, it's often easier and quicker to run programs by typing commands into a terminal window. Access to unix from other operating systems is usually conducted through a terminal client e.g. Putty for windows.
  2. Users: All programs are run as a specific user, so you have to log into the system as that user with a password
  3. Files and processes: Everything is a file or a process and the input and output from files and processes can be sent to each other (see pipes and redirection).
  4. Permissions: All files, directories and programs have access permissions. A user cannot see the contents of a file or run a program unless the permissions allow

2. A brief overview of the command line shell

This is what is run when you open a terminal window. It provides a lot of information and tools to help you run programs


3. Directories and the file system

The shell logs you into a directory in the file system. There are some rules for  about the file system.
Here are some useful command to assist getting around the filesystem:

4. Working with files

Files reside in directories and can contain text or binary information. Files be created, copied, moved, renamed and deleted with the following commands.

5. Reading the contents of text files

The contents of text files (but not binary files) can be read quite easily through the terminal.

6. Invoking executables

Some files can be marked as executable which means they can run as programs and perform tasks.

7. Redirection and pipes

Most unix processes write their output to the standard output (the terminal screen) and take their input from standard input (they keyboard). There is also a standard error which also the usually the terminal screen. These inputs and outputs can be redirected to files. Unfortunately the details of redirection can vary slightly depending on which shell program is being executed.
Pipes '|' allow processes to direct output and directly to other files. Pipes can be put together to allow complex "pipelines" of commands to be put together

8. File system permissions

File system permissions ensure that file contents or executables can only be examined or invoked by users with the correct authorisation. They can often also be a source of problems when using data or programs created by others where you can't access a file or directory due to the permissions set.