If you’re new to Linux, using the terminal can be a bit overwhelming. New Linux distributions like Linux Mint have great graphical interfaces, but the heart of Linux is the kernel and that means using the command line.

Even if you are a Windows user, you’ve probably had to open a command prompt window at some point in your life to perform a task. With the latest version of Windows, Windows 10, you can even install the Ubuntu Bash shell in Windows and run Linux commands directly from Windows!

Table of Contents

    In this article, I’m going to go over some really basic Linux commands that are common across pretty much all distributions of Linux. Since the bash shell is the most popular shell and the one I use also, I’ll be using that syntax for all the commands. Also, I’ll be mentioning some of the most useful arguments for each command, but there are many more which can be found in the man pages.

    1. ls (List Contents)

    In my opinion, the first command you should know is the ls command. This command lists the contents of the current working directory. If you just type ls and press Enter, you’ll get a very basic listing of files and folders in the current directory.

    7 Linux Commands Every Beginner Should Know image 1

    On most Linux distros, directories will be highlighted in a different color like green. Files will usually be the standard color of the shell prompt, which is grey in my case. Without any arguments, ls is kind of boring. If you use -a with ls, you’ll be able to see all hidden files.

    7 Linux Commands Every Beginner Should Know image 2

    Anything that starts with a dot is a hidden file or directory. The hidden directories all have a dark blue color, which is kind of hard to see. Another useful argument is the -l option as shown below.

    7 Linux Commands Every Beginner Should Know image 3

    This gives you a long listing of files and folders with a lot more information such as permissions, links, user, group, size and last modification date. If you’re not sure how to interpret the permissions, make sure to read my post on understanding Linux permissions.

    2. cd (Change Directory)

    Once you can list the contents of a directory, it’s useful to know how to switch to a different directory. By default, you’ll always start in your home directory when you open a bash shell. This is indicated by the tilde symbol (~) in the shell prompt.

    The cd command is how you change directories in Linux. There really isn’t a whole lot to learn with cd, but there are a couple of shortcuts. One good is simply typing cd and pressing enter. This will always get you back to the home directory no matter where you are.

    7 Linux Commands Every Beginner Should Know image 4

    Also, you can use an absolute path if you want to get into a directory that is not accessible via a relative path. In the example below, I have to use an absolute path starting at the root (/) to get to etc/ssh.

    7 Linux Commands Every Beginner Should Know image 5

    3. man (Help Pages)

    The man command is probably one of the most useful commands in Linux. Even advanced Linux users can’t remember every argument to a Linux command. The man pages will give you detailed info on all of the different arguments for a command.

    7 Linux Commands Every Beginner Should Know image 6

    The syntax is really simple also. It’s just man followed by the command you want to learn about. In the screenshot above, I did a man ls to learn more about the ls command. One useful argument to man is -k, which will allow you to search all commands using a keyword.

    7 Linux Commands Every Beginner Should Know image 7

    Above, I searched for the keyword zip and got back all commands that have the word zip in the command name or in the description. It’s a handy way to find commands you may not have otherwise known about.

    Along with man, you can use another command called info to get more examples of how to use a command. Just type info command to bring up the info page for that command.

    4. touch (Create File)

    If you want to quickly create a new file, the easiest way is to use the touch command. In reality, the touch command is used to change the time stamp on a file, but another use is to create a new file.

    7 Linux Commands Every Beginner Should Know image 8

    There are many ways to create files in Linux and later on you’ll probably never use touch to create a file, but in the beginning, it comes in very handy.

    7 Linux Commands Every Beginner Should Know image 9

    If a file already exists when using the touch command, it simply updates the last access and last modified timestamps for the file as shown above.

    5. cat (Concatenate Files & Print)

    Another useful command is the cat command. The main function of cat is to concatenate multiple files, but it can also be used to print the contents of a file to standard output (which is the screen).

    7 Linux Commands Every Beginner Should Know image 10

    You can use the -n argument to add line numbers to the output. If you use the -b option, it will only add line numbers to lines that are not blank. If you use cat on a file that is longer than the height of your terminal window, only the bottom of the file will be shown. You can pipe the output of cat to the less or the more command to view the contents of a file page by page.

    7 Linux Commands Every Beginner Should Know image 11

    6. mkdir (Make Directory)

    At some point, you’ll want to create directories to organize your data better and that’s where the mkdir command comes in. You can use relative or absolute paths for creating directories using this command.

    7 Linux Commands Every Beginner Should Know image 12

    In the example above, I’ve created two directories in my home directory using a relative path and an absolute path. If you need to create multiple hierarchical directories at once, you need to use the -p argument.

    7 Linux Commands Every Beginner Should Know image 13

    In the above example, I used the -p argument to create the Aseem, Data and Pictures directories all at once even though none of them existed.

    7. rm (Remove)

    The rm command is a powerful command that can be used to remove files and directories. The rm command can remove directories that have files and directories inside of them.

    7 Linux Commands Every Beginner Should Know image 14

    To remove a file, you just type in the file name. If you need to remove a directory that is not empty, you need to use the -r argument. It’s also a good idea to use the -i and -v arguments when using rm as it will ask you before deleting anything.

    7 Linux Commands Every Beginner Should Know image 15

    So those are seven really simple, yet common commands that you’ll need to know in Linux to get started. There are many more and I’ll be posting more beginner articles soon on more commands and how to use them. If you have any questions, post a comment. Enjoy!

    Leave a Reply

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