10 Essential Linux Bash Commands for Beginners

If you’ve just started out using Linux, you’ve probably heard about how powerful the command line can be. Indeed, it is powerful, but only if you know the commands to type into it. In this guide, we’ll run through the top 10 most essential commands that you need to learn right off the bat.

Bash is the default shell on all Linux distributions (or at least 99% of them), and you can access it by opening up a terminal on your system. Some Linux servers only have a terminal and lack a desktop environment entirely. You can imagine how important it is to know a few commands in that case.

Even with a desktop environment such as GNOME, KDE, etc, you’ll only unleash the true potential of Linux by mastering the command line. Knowing these 10 essential commands will put you on track for doing exactly that.

Essential Linux Commands

1. pwd

The pwd command stands for “print working directory” and tells you what directory you are currently in. It will show the full path to your current directory and it’s not necessary to supply any options to the command.


pwd command in a Linux terminal, returning the full path of present directory

2. cd

The cd command stands for “change directory” and is used to navigate to different places on a Linux system. All you need to do is tell cd the path to the directory you wish to change into.

cd /path/to/some/directory

Linux terminal showing the cd and pwd command

3. ls

The ls command is short for “list” and is used for listing a directory’s contents.


Linux terminal showing cd and ls command

By itself, ls will list your current directory’s files. But you can also supply a path without having to navigate there first.

ls /path/to/some/directory

To see more information about the files, rather than simply listing them, you can append the -l option. This will show some extra info like the owner of the file, the last time it was modified, and the permissions on it.

Linux terminal showing ls -l command output

To see hidden files, you can use the -a option. Feel free to combine this with the -l flag as well, if you want.

ls -al

4. mv

We know how to change into directories and see what files are there, but how about moving the files? That’s where the mv command comes in. It can be used for both files and directories. You can supply it with as little as two arguments: the file you want to move and where to move it to.

This command will move some_file.txt to the ddt user’s desktop:

mv some_file.txt /home/ddt/Desktop

You can also move multiple files at once:

mv file1.txt file2.txt file3.txt /home/ddt/Desktop

The mv command is also used to just rename files:

mv unpublished.txt published.txt

5. cat

Short for “concatenate,” the cat command is used to read files. It can also read multiple files at once and concatenate the output, hence the name.

cat some_file.txt

Linux terminal showing the cat command on a text file

Supply as many arguments as you want:

cat some_file.txt some_other_file.txt

Running the cat command on multiple files at once

Or it can be easier to just use a wildcard:

cat *.txt

6. cp

The cp command is used to copy files or directories.

To copy a file to a different directory:

cp /dir1/file.txt /dir2

If you want to copy a directory and all its contents, you’ll need to include the -r (recursive) option.

cp -r /dir1 /dir2

7. rm

Short for “remove,” the rm command can delete files from your system.

rm file.txt

If you want to delete a directory, you’ll need to include the -r (recursive) option. If the directory isn’t empty, you’ll also need the -f (force) option, which tells rm to attempt to remove the file or directory no matter what.

rm -rf /path/to/directory

8. nano

Nano is a text editor. It’s one of several editors that are usually included on Linux installations by default. The vi editor and Emacs are also popular choices. However, nano is very user friendly and a good choice for beginners.

nano my_document.txt

Nano text editor on Linux

Nano’s controls are listed at the bottom. The ^ means the Ctrl key on your keyboard. So, to exit a file, just use Ctrl + X. You’ll be asked if you want to save your changes if you made any.

9. grep

The grep command is used to search files or terminal output for a pattern you specify. It’s probably easier to explain it through examples.

To search all the text documents in /directory1 for text string “Daily Dose”:

grep "Daily Dose" /directory1/*.txt

Grep command searching for text string

The output from grep indicates that our text string was found inside my_file.txt.

It’s common to pipe standard output into grep. For example, let’s use ls piped to grep to check for .txt documents inside directory1:

ls -l /directory1 | grep txt

ls command piped to grep to look for certain file type

grep has a lot of useful options. One of the most common is -i, which tells grep that the supplied pattern is case insensitive.

10. top

The top command will show you a lot of useful information about your system – CPU and RAM usage, which processes are running, how long your system has been powered on, and more.


top command on Linux

Many distributions also come with the more useful htop command, which is the same thing but much easier to interpret.


htop command on Linux

You can exit either program at any time by pressing “q” on your keyboard. Both have the ability to kill processes and do other things. See the bottom of htop‘s window to see what keys to use to perform various functions.

Closing Thoughts

These commands should be enough to get you started with the Linux terminal, though we’ve barely scraped the surface of what’s possible. Some of these commands have a lot of options, which you can read about on the man pages. For example, to view the man page for ls:

man ls

After mastering these basics, there will be many more commands to learn.

Leave a Reply

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