home  UNIX SPECIFIC  : tech-unixbasics 
Web and Email Hosting
More Information about our Web and Email Hosting Solution. Linux Web HostingWindows

Unix & Linux Basics

Note: Unless you have prior experience with Unix, we suggest you read the IC Tech. 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:

bash-2.04$

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.

Cd

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 ~.

Cp

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.

Grep

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 *.

Ls

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:

Mkdir

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

Mv

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

Pwd

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.

Rm

To delete* a file, type rm filename.

Rmdir

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

Related Items

Email and Web Hosting by Internet Connection 2004-2007 ©
Contact IC Support via AIM!  Our SN is ICSupportDesk