|After you telnet in to your DreamHost account, you will be presented with a '$' character (which could be different if you've changed the shell for your account). This is what is known as a prompt - a place for you to type commands. In a command line interface, this means the same thing as having an open window does in a graphical interface: it's waiting for you to do something.
Note: A good rundown of Unix commands can also be found here:
Some common tasks you might need to know (click on the task to visit that section):
Finding Out Where You Are (pwd)
First, you may want to know which directory you're in. To do this, you run the pwd command, which shows where you are. From your prompt, you would type pwd and hit return.
In response, it will give you what is known as a pathname. If you have just telnetted into your account, most likely it is something like /home/fred (where fred is your username). This means that you are in the fred subdirectory of the homedirectory. The fred directory is known as the root directory of your account.
Listing Directory Contents (ls)
Now, let's say you want to know what is inside of a given directory. To do this, type ls and hit return. This will give you a short listing of the contents of your current directory (remember, you can see what directory you are in by using the pwd command).
You can get a more descriptive list of your directory contents by typing in ls -al, which gives you the permissions for each item, the owner, and various other pieces of information.
Changing Directories (cd)
You can change from your current directory in several ways:
- If you wish to change into a directory within your current directory, type in cd dirname and then hit return, where dirname is the name of the directory you wish to change into.
- If you decide you wish to go back a directory, just type cd .. and hit return. This will take you back a step.
- You can also change into any directory with the cd command by providing a full pathname of the directory you wish to go to. So, if you wanted to change into your home directory from any location on the server, you would type cd /home/fred, assuming your username is fred.
Deleting Files (rm)
To delete files, you use the rm command. For example, if you have a file in your current directory named testfile, you would delete it by typing rm testfile then hitting return. You can also delete files anywhere on the system by providing a full path to the filename, assuming you have the correct permissions to do so. Note that this operation is not reversible, so make sure you really want to delete the file in question.
Deleting Directories (rmdir)
The rmdir command allows you to delete directories, just as you have done with files. To delete a directory, type in rmdir dirname and hit return (assuming the directory is called dirname). As with rm and cd, you can provide a full pathname to the file. Note that you cannot delete a directory unless it is empty with this command, although you can do it with a variation of the rm command. Simply type rm -r dirname instead. Note that both of these actions will delete the directory, and cannot be undone.
Running A Program
There are a few different ways to run a program on the server. Generally, you should simply type in the full pathname of the program and hit return. If you are in the same directory as the executable itself, you can simply type in ./progname and hit return (assuming it is called progname). Some utilities are set up so that they can be run from anywhere, and only require that you type in their name and hit return. In fact, all of the above commands are actually programs residing on the server.
Listing Running Processes (ps)
The ps command allows you to see which executable programs you are currently running. Typing in this command and hitting return gives you a readout with various details, such as the name of the program, the process ID, and how long the process has been running.
Killing A Running Process (kill)
The kill command allows you to terminate a running process. Using the ps command explained above, find the process ID (PID) of the process you wish to kill, and then type in kill 1234 (where 1234 is the PID of the process). This will terminate the process.
Reading The Manual (man)
When you need help with a given command, you can run the man program. It provides a way to get help with all sorts of different programs and utilities on the server. To use it, type in man command (where command is the name of the command you need help with). For example, man ls would give you some detailed help on using the ls command. Although man can be somewhat cryptic and may contain far more information than you really need, it is very complete, and often proves valuable. Many utilities, including the ones mentioned above, have special features that can only be discovered by viewing their man page.
Many programs have a built in help feature, which you can access by using the --help flag. For example, typing in ls --help will give you help with the ls command. Often, this provides a less detailed but easier to understand display than the man command.
Getting The Date And Time (date, cal)
One somewhat handy feature that you can use is the date function. If you type in date from the command line and hit return, you will be presented with the current date and time. There are many ways to customize the formatting of this display, which you can find by typing in date --help instead. A similar utility, used by typing in cal and hitting return, provides you with a calendar for the current month. Typing in cal -y extends the command to provide a calendar for the entire year.
Changing Permissions (chmod)
To change read, write, and execute permissions for a given file or directory, you must use the chmod command. This command allows you to set permissions for a given file, and is often used when writing CGIs for use with your web site. For full details on many ways to use this command, you should visit the following web site:
Generally, most CGI scripts should by set to mode 755, which you can do by typing in chmod 755 filename.cgi, assuming the file is called filename.cgi and is in the same directory.
Moving or Renaming Files/Directories
To move or rename files or directories, you should use the mv command. To move a file or directory from one directory to the other, you should type in mv source destination and hit return, where source is the file you wish to move, and destination is the directory to which you are moving it (usually an absolute to relative pathname). Renaming a file/directory is the same process, except you provide a different file or directory name for the destination.
Using A Text Editor (pico, vi, emacs)
For most people, the use of the pico text editor is sufficient for most tasks To use it, just type in pico filename (where filename is the name or path to a file you wish to open) and hit return. This will allow you to use pico, an easy-to-use text editor. We recommend this to most of our users.
Others prefer more advanced text editors, such as emacs and vi. Although more difficult to master, these editors are powerful once you do learn how to use them. To open a document with these editors, type in emacs filename or vi filename, where filename is the file you wish to open.
Getting Information On A Domain (whois)
You can instantly get information on a given domain name by using the whois command. This allows you to see who is registered to a given domain, when it was created, who to contact at that domain, etc. This is also a useful way to see if a domain you have registered has been registered by Internic yet. To use it, simply type in whois domain (where domain is the domain name you are checking on, ie dreamhost.com) and hit return.
Various Net Services (lynx, telnet, ftp, gopher)
A command line based web browser is available for your use called lynx. Although it is obviously devoid of any graphics display, many swear by the speed in which lynx allows you to go from site to site. To use lynx, simply type in lynx http://www.sitename.com (where the URL is to a site you wish to visit) and hit return.
You can also telnet in to another server from your shell account by typing in telnet hostname, where hostnam is the name of the server you are connecting to. FTP and Gopher (for those few gopher sites still left out there) work the same way, but with the ftp and gopher commands, respectively.
Last updated: Nov 08, 2002.
User Post (2003-07-07 18:02:10 by rogerhc)
File size or disk usage -- du [somedirectory | somefile] -- Tells you the Kilobite size of somefile or somedir (recursively for dirs, totaled at end). The unit of measure is Kilobite. Thus 1000 means 1 Megabite. See -- man du -- for more.