Linux has hundreds of commands available, but to get around the system, view and edit text files we only need a handful. We’ll take a look here at the basic commands that are essential in setting up the dedicated server (download a free copy of Linux to test drive it).

Notice the convention of the $ sign in the examples given. This means that you are logged in to your Linux server and at the command prompt. From this point, simply type in the command and press enter. Anything in square brackets represents an instance that you’ll substitute with an appropriate value – so for instance [username] will be substituted with your username.

Linux Commands: Navigating

$ pwd

Use this command to find out where you are in the directory structure. When you log on to Linux, your starting directory is always your home directory, so you’ll be in /home/[your username] as any other user than root, or /root if you’re logged in as root. But, this can be useful if you ever lose track!

$ cd [directory]

A workhorse command, this is used to change the current directory. The directory named can be relative to the current directory, or absolute. To move relatively, using .. will move you up one level, or typing a directory name will move you into a subdirectory of the current. So, for example, if you’re in the directory /home/[username] and want to move to the directory /etc, you can do it in a couple of ways. If you type:

$ cd ..

You’ll be moved up one directory, so you’ll now be in the /home directory. Repeat the command, and you’ll be in the root (/) directory. Then, type:

$ cd etc

Now, you’ll be in the /etc directory. However, this is a bit cumbersome, but absolute addressing can achieve the same move in one step by simply preceding the address with a forward slash /. When you do this, the directory typed will be treated as relative to the root directory. So, from the example above, to move from /home/[username] directly to the /etc folder, enter:

$cd /etc

This will move the current directory to the /etc directory in one step. To move back, use:

$ cd /home/[username]

You can also use the following with cd:

$ cd ../../

Moves up two directories, and you can extend this as far back as required.

$ cd –

Moves to the previous working directory.

$ cd

Using cd without an argument moves the working directory straight to the user’s home directory. (Note: the cd command is synonymous with the chdir command.)

$ ls

This is the list command, so that you can view the contents of a directory including all files and subdirectories. If you don’t specify a directory then the current directory is assumed, but you can give an argument to a relative or absolute location.

$ ls /home/[username]

In this case the directory specified has its contents listed. The directory reference can be absolute or relative.

Pin It on Pinterest

Share This

Share This

Share this post with your friends!