Navigating Linux


Introduction to Navigating Linux

Navigating Linux from the command line becomes second nature if you have a Linux server. Linux is an Open Source operating system, and having your own Linux server is a must for many hobbyists. You can get your own Virtual Private Server for as little as $5 per month at Linode.

With a VPS, you can set up your own web server, SQL Database server, etc. for home automation. By using Linux, you will usually save a lot of cash vs. other operating systems. Getting around Linux might be a little intimidating at first though from the command line.

Once you learn some basic commands, however, you will become much more comfortable.

The purpose of this post is simply to show how to navigate through directories in Linux to view the contents. I will have other posts on certain administrative tasks.

Connecting to the VPS

One way to connect to a VPS is with PUTTY. Putty has a graphical interface to connect you to the terminal on your server. Once PUTTY is installed, simply enter your hostname and port number. In these examples, we will use SSH (secure shell). Undeniably, SSH is a more secure method to connect to the terminal of your server than other protocols, such as Telnet.

If you already have Linux installed on your PC, simply go to a terminal. At this point, simply type “ssh user@hostname.com -p 22”. Replace the “22” with the port number of your server. Although the default port number is 22, some administrators will change this. This reduces brute force attacks on the server.

su Command

The “su” command allows you to become the root user. The root user is the main administrator on the server. As root, you have the authority to do almost anything you want. Although this makes life a little easier, be very careful when logged in as root. I might become root user when inittially setting up a server. After the server is set up, I will use the sudo command to run common maintenance commands instead. The sudo command allows certain users to execute commands as root simply by typing sudo before the command you wish to run.

Notice the command prompt has a $ when you are a standard user. You will see a # at the command prompt when you are a root user.

pwd Command

The pwd command will “print working directory”. This will show you the directory that you are currently in. In Linux, your directory simply starts with “/”. “/” is similar to “C:” for those of you who have worked with Windows.

ls Command

“ls” is the “List” command. This will show you the contents of a directory (folder). A directory might contain other directories, as well as individual files.

Additionally, by typing “ls -al”, you will see more information about each file and directory. You will see hidden files and folders as well. When the first character on a line is “d”, we know this is a directory.

cd Command

Finally, the “cd” command is how we change directories. This is essential for Navigating Linux. By typing “cd directoryname”, you will enter that directory. When you type “cd ..” You will exit that directory, and enter the directory that is one level higher.

For example. Let’s say /home/ricky/ contains a folder called “Downloads” To enter the Downloads directory, I will simply type “cd /home/ricky/Downloads” (space after cd). At this point, if I type ls, I will list the contents of the Downloads directory. If I type “cd ..” I will go up one directory. Then, if I type “ls”, I will see the contents of /home/ricky.

For other information on Linux, visit the Information Technology Category page!

— Ricky Bryce

Leave a comment

Your email address will not be published. Required fields are marked *