Phone :  +370 (5) 204-1903
Email: sales@1gbits.com

Basic Linux Command List

Linux has been around since the mid-90s and now has become the most widely used operating system in the whole world. You can find this OS on your smartphones, computers, servers, cars, home appliances and pretty much in everything.

Linux Tutorial Nov 13, 20 by Nisal N 19 min Read
Basic Linux Command List

This has become by far the most popular platforms on the planet. Linux is mostly used in servers and more than 90% of the internet today are powered by Linux servers.

It is an open-source and free software which makes it possible for anyone to make changes to the code and redistribute it under a different name. Some of the most famous Linux based operating systems are:

  • Ubuntu
  • Android
  • Fedora
  • FreeBSD
  • Debian
  • Kali Linux
  • CentOS
  • Red Hat Linux
  • openSUSE

Bottom line: Linux is everywhere! This means that the likelihood of you coming across a Linux interface is very high. A fun fact is that it is mostly used without a GUI (graphical user interface) and this results in absolute beginners to get lost going about it.

However, we researched and compiled a list of commands that will get you to master the Linux environment. We will have three sections which will have:

  1. Basic Linux commands
  2. Intermediate Linux commands
  3. Advanced Linux commands

Before we start our journey we need to get familiar with the “terminal” or “shell”.

What is Linux Shell?

In short, the user enters commands to the system, and the system will output the result. Most Linux distributions come with a CLI (Command-line interface), and you use the terminal/shell to input the commands.

Linux distros come with a GUI, but this tutorial is solely dedicated to beginners who want to familiarize with the Linux command line.

Now let’s open the terminal and let’s get started with the commands.

Note that the Linux shell is case sensitive so you should be careful when entering commands.

1. Basic Linux commands

1.     PWD command

The pwd command will show you the current working directory (also known as a folder) you are working. It will show the absolute path with all the directories.

An example when you type in pwd command: the result will be /root/folder1

 pwd command

2.     LS command

The ls command is used to show all the content inside a directory. The default settings will show the contents of the current directory.

If you want to see the content in other folders, you should type the folder path after ls. For example, ls/root/folder1/books to view the files inside the books folder. After the ls command, you should enter the file's absolute path (as seen in the example above).

The ls command has many variations:

ls –R  List all files in subdirectories

ls –a  List hidden files

ls -al List detailed information of files and directories (permissions, size, owner, etc.)

ls command

3.     CD command

The cd command is used to navigate between files and folders. You will need to type the full path or the directory's name (depends on your current directory).

There are some shortcuts to help you navigate quickly:

  • cd .. (with two dots) to move one directory up
  • cd to go straight to the home folder
  • cd- (with a hyphen) to move to your previous directory

An example of cd command will be like cd folder1

cd command

4.     MKDIR command

You can use the mkdir command to create new directories. For example, to make a directory called pictures, you can type mkdir pictures.

Here are some tips on using the mkdir command:

To generate a new directory inside another directory. Use this format mkdir pictures/europe

Using to create directories in between two existing directories. Here's an example: mkdir –p pictures/trips/Europe

mkdir command

5.     RMDIR command

If you need to delete a directory, use the rmdir command. However, rmdir only allows you to delete empty directories.

An example: rmdir folder1

rmdir command

6.     RM command

You can use the rm command to delete files if you want to delete all the files in a directory using rm –r.

Here's an example. Let's say that in folder1 there is a text file named test.txt. To remove this file from folder1, enter rm test.txt

7.     TOUCH command

The touch command is used to create empty files directly from the command line. For example, touch docnew.txt will create a new text file with the name 'docnew'.

You can also create files in a different location by specifying the path: touch /home/1gbits/docs/mywebsite.html which will generate an HTML file under the docs directory.

touch command

8.     FIND command

The find command is used to search for files and directories. The find command is used to find files within a given directory.

An example is: find docnew.txt

find command

9.  MV command

The mv command has two functions:

To move a file, you can type mv test.txt /home/1gbits/document As shown in the example, you should set the name of the file that needs to be moved and set the path.

To rename files, you can use mv file1.txt file5.txt The name of the file will be changed to file5.txt.

Here's an example:

mv command

10.  NANO command

The nano command is used to create and edit text files. This is an easy to use command line text editor which includes all the basic functionalities of a regular text editor. Let me show you how to create a file using the nano command:

nano test

Enter the text inside the editor and exit to save the file. 

11.  SUDO command

The sudo command will let you perform tasks that require root privileges. However, it is not advised to use this command for daily usage because it will be hard to make it right if an error is made.

12.  HISTORY command

Once you start using the Linux working environment daily, you will soon notice that you can run 100s of different commands every day. To know about all the Linux terminal commands that you have entered, you can enter history command to review all the commands you've entered before.

13.  APT-GET command

You can use apt to work with packages in the Linux command line. Apt-get is used to install packages and requires root privileges. You can use the sudo command with it. Here are some examples of using the apt-get command.

To install the text editor Jed, you can type in sudo apt-get install jed

To update your current repository, you can type in sudo apt-get update

To upgrade the system, type sudo apt-get upgrade

14.  CAT command

Cat (short for concatenate) is one of the most frequently used commands in Linux. This is used to list the contents of a file on the standard output. For example, cat testdoc.txt will open the file and display the contents.

Here are other ways to use the cat command:

cat > filename creates a new file

cat filename1 filename2>filename3 joins two files (1 and 2) and stores the output of them in a new file (3)

to convert a file to upper or lower case use, cat filename | tr a-z A-Z >output.txt

15.  CP command

The cp command is used to copy files between two places through the use of the command line. The command takes two arguments; the first is the file's location that needs to be copied, and the second is the destination of the file where the file should be copied. Here's an example.

There is a file named my.txt in the current directory. You want to move this file to a folder called personal. Type this command cp my.txt /home/user/personal/

Note the spaces used in the command.

16.  ZIP, UNZIP command

Use the zip command to compress files into a zip archive and use the unzip command to extract the zipped files from a zip archive.

17.  MAN command

There are many Linux commands, and, naturally, we don't remember what each of them does. In such situations, the man command comes to help. It shows the manual pages of the command. For example, man ls shows the manual pages of the ls command.

No matter command, with the man command, you can know everything about each of them.

man command

18.  WHATIS command

whatis command in Linux is used to get a one-line manual page description. In Linux, each manual page has some description within it. So this command search for the manual pages' names and show the manual page description of the specified filename or argument.

Here's an example: whatis -help which will display a help message with one-line explanations.

2. Intermediate Linux Commands

1.  ECHO command

The echo command is used to move data into a file. A simple example of how this command works will be like this. Imagine you wish to move the text "I like the Linux command line" into a file called interests.txt; then the corresponding command will be echo I like the Linux command like >> interests.txt

2.  DIFF command

The diff command compares the content of two files line by line. This is useful when you need to make program alterations, instead of writing the entire code again.

An example would be diff code1.txt code2.txt

3.  JOBS command

The jobs command will display all currently running jobs along with their status. A job is a process that is started by the shell.

4.  KILL command

Just like in Windows, when we encounter an unresponsive program, we end the task from the taskbar. You can terminate these kinds of programs from Linux using the kill command.

There's quite a range of using the kill command which can be checked using the kill –l command.

Even though there is a list of 64 different commands, the most common ones are SIGTERM (15) and SIGKILL (9).

  • SIGTERM (15) — requests a program to stop running and gives it some time to save all of its progress. If you don't specify the signal when entering the kill command, this signal will be used.
  • SIGKILL (9) — forces programs to stop immediately. Unsaved progress will be lost.

Knowing the kill command is not enough to terminate the process without the PID number (process identification number). TO find out the PID, run the command ps ux

An example of terminating a process will look like this: kill -{kill number} PID

This command kill -9 2020 will terminate the process 2020.

5.  WGET command

If you want to download something from the internet, you can do that using the Linux command line. Use the wget command followed by the download link.

An example is shown below, where I downloaded the content of 1gbits.com, which will be saved as an HTML file. wget https://www.1gbits.com


6.  PING command

Like in windows, you can use the ping command to check the connectivity status to a server. Here's an example where we checked if our system can connect to 1gbits.com and the response time. Note that the pinging will not stop automatically so to cancel it, simple use ctrl+z to cancel.

ping 1gbits.com

7.  WHEREIS command

The whereis command in Linux is used to locate the binary, source, and manual page files for a command. This command will search for files in the restricted set of locations (man page directories, binary file directories, library directories). The most common usage of this command is to find the executable files of a program, configuration files and the man pages. 

The syntax is fairly simple: you type whereis followed by the name of the program.

For example whereis netstat will show the netstat executable and the location of the man page.

8.  SERVICE command

The service command lets you run System V init scripts. The available syntax of using the service command is as follows:


service --status-all

service --help | -h | --version

To use the service command is not complicated at all. Let me give some simple examples (you will need root privileges):

To run a script: service sshd start

To stop an already running script: service sshd stop

To restart an already-running service: service sshd restart

9.  ALIAS command

The command alias lets you create 'aliases' for your most commonly used commands. Aliases are like custom made shortcuts to represent a command. 

To view all the default set of aliases, type in alias

To create a temporary alias is to enter the name you wish to use followed by a '=' sign and quote the command you wish to alias. 

The syntax is as follows:

alias yourname="The custom command"

An example of using alias is as follows:

alias sus="cd /home/test/Downloads"

10.  DF command

The df command is used to display information related to the file systems total space and available space. 

Most common options for using the df command are as follows:

a –all: includes pseudo, duplicate and inaccessible file systems.
B –block-size=SIZE: scales sizes by SIZE before printing them.
h –human-readable: print sizes in the power of 1024
H –si: print sizes in the power of 1000
i –inodes: list inode information instead of block usage
l –local: limit listing to local file systems
P –portability: use POSIX output format

Here's an example of using the df command to display all file system information:

df -a

11.  PASSWD command

passwd command in Linux is used to change the user account passwords. The root user reserves the privilege to change the password for any user on the system, while a normal user can only change the account password for his or her own account.

To change your password, enter passwd

12.  LPR command

The Linux command lpr submits files for printing. The lpr command transmits and manages print jobs.

When using the lpr command, you can use the following options:

  • E: Forces encryption when connecting to the server.
  • P destinationPrints files to the named printer.
  • # copiesSets the number of copies to print from 1 to 100.
  • C nameSets the job name.
  • J nameSets the job name.
  • T nameSets the job name.
  • l: Specifies that the print file is already formatted for the destination and should be sent without filtering. This option is equivalent to -oraw.
  • o optionSets a job option.
  • p: Specifies that the print file should be formatted with a shaded header with the date, time, job name, and page number. This option is equivalent to -oprettyprint and is only useful when printing text files.
  • r: Specifies that the named print files should be deleted after printing them.

13.  CMP command

cmp command in Linux/UNIX is used to compare two files. It will compare byte by byte and will help you to find out whether the two files are identical or not.

  • When CMP is used, it reports the location of the first mismatch to the screen if the difference is found and if no difference is found the files compared are identical.
  • CMP displays no message and simply returns the prompt if the files compared are identical.

3. Advanced Linux Commands

1.  IFCONFIG command

Ifconfig stands for "interface configuration." It is used to view and change the configuration of the network interfaces on your system. Running the ifconfig command with no arguments will display information about all network interfaces currently in operation.

2.  CHOWN command

When it comes to the Linux infrastructure, all files are owned by a specific user. In the complete list of Linux commands the chown command enables you to change or transfer a file's ownership to a particular user.

Let me try to give you an example. Imagine a user named john, and the root user wants to provide the ownership of the file data.txt to john. The command will be as follows: chown john data.txt. The ownership of the file will be under the user john.

3.  TOP command

Like the Windows task manager, the topcommand will display a list of running processes and how much CPU each process uses. This is very useful to monitor system resource usage.

4.  USERADD, USERDEL command

Linux is a multi-user system, which means that more than one user can use the same system simultaneously. To show how adding a user follow the screenshots that are shown below.

Adding a user max can be done by entering useradd max

To check if the user is added, you can enter the following: cat /etc/passwd

The user is created. Now to delete the user max, we can use the command userdel max Once deleted, check the list of users and you will no longer see the user max.

5.     GREP command

The grep command lets you search for all the text in a given file. For example, grep dummy testdoc.txt will search for the word "dummy" in the notepad file. Lines that contain the searched word will be displayed highlighted.

grep command

6.  HEAD command

The head command will make your life much easier when going through documents. This command is used to view the first lines of any text file. By default, it will show the first ten lines of text.

The format will look something like this: head testdoc.txt

head command

7.  TAIL command

This one has a similar function to the head command, but instead of showing the first lines, the tail command will display the last ten lines of a text file.

8.  GCC command

GCC stands for GNU Compiler Collections which is used to compile mainly C and C++ language. It can also be used to compile Objective C and Objective C++. 

Syntax of gcc command is gcc [-c|-S|-E] [-std=standard]

Let's go through an example of using the gcc command.

gcc source.c

This will compile the source.c file and give the output file as a.out file which is the default name of output file given by gcc compiler, which can be executed using ./a.out


There are many more commands that are out there, but we believe that with these simple codes you can start getting familiar with the world of Linux. Here some tips:

You can use the clear command to clear the terminal

Enter TAB can be used to fill the rest of the text of the command. For example, after you type cd doc and press TAB, it will automatically fill it as cd documents

you can close the terminal by typing in exit

You can turn the computer ON and reboot the computer by using the sudo halt and sudo reboot

If you liked this article let us know in the comments below and if we are missing some basic commands let us know.

author img

Nisal N

Computers has always fascinated me since I was a kid and here we are. I love travelling for 2 reasons: the first one to see a new part of the world and second (the most important one) to experience the rich culture hidden among the country and people. I'm pretty good at cooking but very poor when it comes to baking.

Leave A Comment