Reading Files and Shell Navigation Tips

Reading Files and Shell Navigation Tips

To be an Ubuntu power user, you must learn the command line. This is the most powerful part of Ubuntu that you can do almost everything from the terminal without the GUI.

In this tutorial we are going to learn how to use the basic shell commands to read files and navigate the shell.

This is a step-by-step tutorial on how to use the basic shell commands to read files and navigate the shell on Ubuntu. To follow this tutorial, you need to have the following requirements:

• A computer with Ubuntu operating system installed.
• Basic knowledge of Ubuntu terminal. With basic I mean, how to open a terminal on Ubuntu and how to execute commands.

First open the terminal of your Ubuntu operating system. You can open your terminal by pressing Control, Alt and T at the same time. You can also go to the Unity dashboard and search by the keyword “Terminal” and click on the terminal. Or you can right click on the Desktop and click on “Open Terminal”.

Reading files with ‘cat’:

When you run and configure Ubuntu, you will always need to read different configuration files. These configuration files are text files. So you can use ‘cat’ command to read them.

To read the file /etc/passwd with cat, run the following command,

“cat /etc/passwd”


It’s a long output.

Shell auto completion with TAB:

The Ubuntu shells can auto complete commands for you. You can write part of a command and press TAB to get the full command. If more than one command matches, then all of them will be shown.

For example, let’s say we want to see the ip address the old fashion way using ‘ifconfig’ command. Just type “ifc” and press TAB and see what happens.


Once the TAB is pressed:


Nice feature of shell, isn’t it?

Shell auto completion works for files and folders as well.

The “” for shell:

At times you may have to work with some files that contains space in their name. Like, “New York.doc”, “Las Vegas.jpg” etc. You can’t type spaces between filenames on Ubuntu when you work with them in shell. But if you put them inside double quotes, you can.

let’s read a file with ‘cat’ command that contains space in filename.

“cat ~/Desktop/Read Me.txt”

An error as expected.


To fix this, let’s put “Read Me.txt” in quote and see what happens.

cat ~/Desktop/”Read Me.txt”


Great it’s worked!

The \ character in shell:

We can also escape the space in filename with backslash character. So we can run the following command and it would work the same way,

“cat ~/Desktop/Read\ Me.txt”


The && and the shell:

If you need to run two command at once, but only if the first command is successful, then you use &&.

For example, let’s run the following command and see what happens,
“sleep 30 && echo Hello World”

This command will sleep for 30 seconds and then print “Hello World” on the screen after the sleep command is complete.