Affordable Web Hosting with Excellent Customer Support internet connection free month hosting

Linux and Unix Basics

Note: Unless you have prior experience with Unix, we suggest you read the ICTech. Ref. Document Your Account's Command Line Interface before experimenting with any of the commands and exercises described below.

The Interface

The command line interface you'll use to administer your server is called a shell. The default shell in use on Internet Connection servers is BASH, the Bourne Again Shell. It's called this because the earliest shell still in use, SH, is known as the Bourne shell. Internet Connection uses BASH because it features job control, command line editing, history lists, automatic signals, substitution, arrays and more! For more information on BASH go here.

If you have ever used MS-DOS, Unix's command line interface will probably seem familiar; in fact, some of the commands are similar. If you have never used a command line interface before, there's no need to worry: all you will need to do is type some instructions (called commands) after a prompt, hit enter, and the computer will carry them out.

After logging in you should see something like this:


This is the prompt; it serves no purpose other than to let you know the computer is ready and waiting to process any instruction you give it.

To execute an instruction, you type the necessary command along with any required parameters and optional switches, and hit return. A parameter is a word you type after the command, such as a file name, that is required to perform the command. For instance, if you give the command telling the system to create a directory, you have to supply a name for the new directory. A switch is a character preceded by a dash that is typed after the command and before any parameters that affects the way the instruction will be carried out. For instance, if you wanted to list all the files in a directory in reverse alphabetical order you would type -r after the list command, which is ls, to get ls -r.

Obtaining Help Using Manual Pages

Unix can appear very intimidating to novices, however, one of the side-effects of being such a mature operating system is that a large amount of documentation has been written for and about it. Perhaps the most important command to know is that which accesses this extensive help system, man. For example, to get help on the list command ls you would type man ls. Man pages are somewhat difficult to read because they are written for users with some UNIX experience, but they are extremely useful in that they provide a list of all parameters required for a command as well as all available switches.

Manual pages are just one of the ways to find out information, you can run a cross-search against all of the manual pages using the parameter 'apropos' (think of it as "what is appropriate) and on GNUish systems like Linux, you can also use the info tool to "browse" documentation.

Furthermore, you may see a brief description of usage and a list of available switches for most commands by typing commandname --help.

Some Useful Commands

At any time when you are logged into your shell, one directory is the current or "working" directory. The commands below will show you how to manage files and navigate the directory structure.


To move from one directory to another type cd directoryname. To move up to a parent directory, type cd ../. To return to your home directory, type cd ~.


To copy a file simple type cp filename newfilename. This can be done within the current directory or in a different directory by specifying the path along with the new file name. For example, to copy a file named chicken.gif from your current directory to a subdirectory named images, you would type cp chicken.gif images/mychicken.gif. Alternatively, you could have simply typed cp chicken.gif images to copy chicken.gif to the images folder without changing its name.


To search inside files for a specific word or phrase use grep text-to-look-for filename(s). If you wanted to look inside all the files in a directory you would use grep text-to-look-for *.


You can get a list of the contents of a directory by using the ls command. There are many helpful switches you can use in conjunction with ls:
  • To see all files in a directory, including those whose names begin with a period (which are usually not displayed) type the ls command with an a switch, as in ls -a.
  • To see long file listings with sizes, dates, etc., type the ls command with a -l switch, as in ls -l.
  • To help distinguish between file and directory names while using ls, use the -F switch to append a forward slash to subdirectory names.


To create a new directory in the current directory, type mkdir newdirectoryname.


To move a file from its current location to a new location type mv filename newfilename.

Example: To move a file named chicken.gif from your root directory to a directory beneath webshare called "images", the command would be mv chicken.gif webshare/images/chicken.gif


Another command useful when navigating the directory structure is pwd, which stands for "print working directory". Simply type this at the prompt and you'll be told what directory you're currently in.


To delete* a file, type rm filename.


To delete* an empty directory, type rmdir directoryname. Note: UNIX will not delete a directory that has files in it.

*Warning: By default, UNIX will not ask you to confirm the deletion of a file or directory, nor will you ever be able to recover a file or directory once it has been deleted. To turn on the prompting feature for deleting files and directories, use the interactive switch, -i. For example, to delete a file named test with prompting you would type, rm -i test.

  Tips and Tricks
  • File-naming Limitations - A UNIX file or directory name can have as many as 256 characters, but cannot contain the following characters: [ ] ( ) $ % & @ ! * ? { } ^ ~ ` ; ' " #
    Also, it would be wise not to use characters that are "special" to other operating systems, for instance: \ : ? < > | cannot be used in naming files for windows machines.
  • Multiple Switches - You can type a command with more than one switch at a time. When you do, put all the switches together after one dash. For example, to see an extended listing of all the files and folders in the current directory, you should type ls -Al.
  • Tab completion - To speed up typing out commands and file/directory names you can take advantage of the shell's tab-completion function. Simply type in the first few letters of the directory or file name and then hit the Tab key on your keyboard.
  • Wild Cards - Another time-saving trick is the use of wildcards. The asterisk character may be used as a wildcard in parameters. For example, ls *.txt will list all files that end in the extension .txt.

Related Items