Linux Commands | Linux Commands Cheat Sheet

profile abhishek

First of all, I am glad about your interest in Linux, and I am going to presume that you have heard about Linux. In this blog, I am going to give you a little overview of the Linux operating system and cover common commands that must be known to every Linux user and in the end, I mentioned a downloadable full Linux command cheat sheet.

What is Linux

Linux is an operating system similar to other operating systems like windows and mac. The main difference between Linux operating system and other operating systems is that Linux is an open-source operating system which means that it is released under a license that allows other users to view its source code and make specific changes according to their requirements.

Difference between Unix and Linux 

Linux is a Unix-like operating system as it has several features similar to Unix. Before Linux and Windows, the computer world was dominated by Unix.

Linux Operating System

Linux operating system or any other operating system manages the communication between software and hardware. Linux operating system comprised of some components that work on top of the hardware.

Linux architecture

Linux Kernal

Linux kernel is the core component of the Linux operating system which manages the CPU, memory and all the peripheral devices include Mouse, Keyboard, Printer, Monitor, etc. Linux kernel work on the lowest level of the operating system (OS).

Shell

Linux shell is a command-line interface that allows users to execute commands or in other words, Linux Shell provides a text interface that allows users to control the computer by executing commands in it. The shell can also be referred to as, terminal, console, command prompts, etc

Applications

Applications are user interactive programs used to handle specific tasks which are typically used by users as a tool. Common examples of applications in the Linux operating system are Firefox, LibreOffice, GIMP, Document Viewer, Visual Studio Code, Audacity, etc

Linux Distributions

There are several Linux Distributions, available for users according to their preferences.

  • Ubuntu Linux
  • Red Hat Enterprise Linux
  • Kali Linux
  • Linux Mint
  • Debian
  • Fedora
  • Arch Linux

Note- If you want to install kali Linux, you simply refer to this article on How to Install Kali Linux [Step by Step Installation Guide]

Linux Shell

Linux shell is a command-line interface that allows users to run commands in order to carry out some specific tasks.

So as this blog is about Linux Commands, I am using the Ubuntu operating system which is one of the best eco-friendly operating system in Linux distribution, you can also use any other Linux distribution as your wish.

As we already discussed, we need a command-line interface in order to run commands. So let's Launch Terminal by pressing ctrl+alt+T or you can search it in applications, once it comes up, we should see something like this

Linux Shell

As you can see above picture it's a shell prompt that is ready to take input in the form of commands. While it may vary in appearance depending on the distribution, it will usually include your username@machinename, in my case username is abhishek and the machine name is techofide followed by a dollar sign ( $ ).

Linux Commands

The Linux commands are the utility of the Linux operating system to carried out specific tasks. These tasks can be done by executing commands. These commands are executed on the Linux terminal.

Let's try some basic commands -

date command in Linux

date command in Linux is used to display the system date and time. date command is also used to set the date and time of the system.

date

cal command in Linux

cal command in Linux is a calendar command which is used to see the calendar of a specific month or a whole year.

cal

date command in linux

echo command in Linux

echo command in Linux is used to display lines of text/string that are passed as an argument. This is a built-in command that is mostly used in shell scripts and batch files to output status text to the screen or a file.

echo [option(s)] [string(s)]

echo command in linux

Note- echo $USER displays the username of the current login user.

exit command in Linux

exit command in Linux is used to exit the shell where it is currently running.

exit

Tip- You can also exit the shell by pressing ctr+D

Note- It is difficult to grab all commands without the knowledge of the use of particular command so to make it more convenient and understandable to all users, commands are further distinguished in the particular sections related to their type and use.

Linux File Commands

Linux File Commands are used to manage files and directories. I listed out some most important Linux File Commands below

pwd command in Linux

pwd stands for print working directory. The pwd command in Linux is used to print the location of the current working directory.

pwd

pwd command in linux

ls command in Linux 

ls stands for list. The ls command in Linux is used to display a list of files and folders of a directory.

ls

ls command in linux

Tip- ls -a command is used to display the list of hidden files and folders of a directory.

cd command in Linux 

cd stands for change directory (folder). The cd command in Linux is used to change the current directory.

cd <directory name> 

cd command in linux

mkdir command in Linux

mkdir stands for make directory. The mkdir command in Linux is used to create a new directory.

mkdir <directory name> 

mkdir command in linux

Note- In the above picture as you can see, I create a directory using the mkdir command with directory name test.

rmdir command in Linux

rmdir stands for remove directory. The rmdir command in Linux is used to remove an empty directory.

rmdir <directory name> 

rmdir command in linux

Note- In the above picture as you can see, I remove a directory using the rmdir command with directory name techofide.

touch command in Linux

The touch command in Linux is used to create empty files.

touch <file name>  

touch command in linux

Note- In the above picture as you can see, filename test.txt is created using touch command.

cat command in Linux

The cat command in Linux is a multi-purpose utility in the Linux system. It can be used to create a file, display the content of the file, copy the content of one file to another file, and more.

cat <file name>  

cat command in linux

Note- In the above picture, as you can see, cat command is used to display the content of the file named test.txt

cp command in Linux

cp stands for copy. The cp command in Linux is used to copy a file or directory.

cp <file name> <destination path>  

copy command in linux

Note- In the above picture, as you can see, I use the cp command to copy the file test.txt into another directory test1

rm command in Linux

The rm command is used to remove a file.

rm <file name> 

rm command in linux

Note- In the above picture, as you can see, I use the rm command to remove the file test.txt.

Tip: rm -r command is used to remove the directory as well as files contained in that directory.

mv command in Linux

The mv command in Linux is used to move a file or a directory from one location to another location.

mv <file name> <directory path>  

mv command in linux

Note- In the above picture, as you can see, I use the mv command to move the file test.txt into directory test1

tail command in Linux 

The tail command in Linux displays the last N number of lines contents of the file, by default, it prints the last 10 lines of the file.

tail -n <num> <file>

Note- where n is the number of lines that you want to print as per the given file.

head command in Linux 

The head command in Linux displays the first N lines contents of the file, by default, it prints the last 10 lines of the file.

head -n <num> <file>

tail command in linux

Note- Here in the above image by using the tail and head command to print the last and first two lines of the file demo.txt where n is the number of lines that you want to print as per the given file.

Linux User Commands

Linux User Commands are used to manage Users and Groups. I listed out some most important Linux User Commands below

sudo command in Linux

sudo stands for superuser do. The sudo command in Linux allows users to run programs with administrative privileges.

adduser Command in Linux

The adduser command in Linux is used to add a user to a Linux system. The adduser command is run with sudo as a prefix because creating a new user is an administrative task so it requires a user must have superuser or sudo privileges in order to run this command.

Note: Do remember that the adduser command in Linux executed by the superuser or sudo user.

sudo adduser <username>  

adduser command in linux

Note- In the above picture, as you can see, I use adduser command to create a user name alex.

su Command in Linux

su stands for switch user. The su command in Linux used to execute commands with access or privileges to another user account without changing the current working directory or the user environment.

su <username>  

su command in linux

Note- In the above picture, as you can see, I use su command to switch the username alex.

id Command in Linux

The id command in Linux is used to display the user ID (UID) and group ID (GID).

id

id command in linux

Note- In the above picture, as you can see, I use the id command to display user id (uid) and user group id (gid)

passwd Command in Linux

The passwd command in Linux is used to create and change the user pasword.

passwd <username>  

passwd command in linux

Note- In the above picture, I use the passwd command with username alex in order to change the password.

groupadd Command in Linux

The groupadd command in Linux is used to create a user group.

groupadd <group name>

groupadd command in linux

Note- In the above picture, I use groupadd command to create the group Devops.

Linux Network Commands

Linux Network Commands are used to manage system networks. I listed out some most important Linux Network Commands below

ping command in Linux

The ping command in Linux is used to test the reachability of the host machine.

ping <destination>    
ping hostname command in linux
ping using hostname
ping command in linux
ping using ip address

ifconfig command in Linux

Ifconfig stands for Interface Configuration. The ifconfig command in Linux is used for displaying network configuration information and also used to set up network interfaces as required.

ifconfig

ifconfig command in linux

ip command in linux

ip stands for internet protocol and ip command in Linux is used to assign an address to a network interface. The ip command is mostly used by Linux administrators to configure network interfaces.

ip a 

ip command in linux

ssh command in Linux

ssh stands for secure shell and ssh command in Linux is used to create a remote connection to another machine through the ssh protocol.

ssh username@hostname

scp command in Linux 

scp stands for secure copy and scp command in the Linux system is used to copy or transfer files between the local host and the remote host or between two remote hosts.

scp linuxcommand.pdf username@196.x.x.x:

telnet command in Linux

The telnet command in Linux is used to create a remote connection with a remote system over a TCP/IP network.

telnet hostname/IP address  

netstat command in Linux

Netstat command in Linux is used to list out all the network connections on a system.

netstat

netstat command in linux

Linux Process Commands

Linux Process Commands are used to manage the system processes. I listed out some most important Linux Process Commands below

ps command in Linux

ps stands for process status and the ps command in Linux is used to list the currently running processes along with their process ids.

ps

ps command in linux

top command in Linux

The top is a command-line utility tool and the top command in Linux is used to show the real-time dynamic view of system running processes of the system.

top

top command in linux

pidof command in Linux

pid can be denoted as a process id and pidof command in Linux is a command-line utility that allows you to find the process ID of a running program.

pidof bash

pidof command in linux

kill command in Linux

kill command in Linux, is used to terminate or kill processes manually. kill command sends a signal to a process that terminates or kills the process.

kill <processid>

Linux System Information Commands

Linux System Information Commands are used to display system information and configurations. I listed out some most important Linux System Information Commands below

uname command in Linux

uname command in Linux is used to print the processor architecture, the system hostname, and the version of the kernel running on the system.

uname -a 

uname command in linux

lshw command in Linux

lshw command in Linux is used to display detailed information about your hardware components such as CPU, disks, memory, USB controllers, etc.

lshw

lshw command in linux

Note- Do remember that the lshw command in Linux executed by the superuser or sudo user.

lscpu commnand in Linux

The lscpu command in Linux display information about your CPU architecture such as the number of CPUs, cores, CPU family model, CPU caches, threads, etc

lscpu

lscpu command in linux

lsblk command in Linux

lsblk command in Linux is used to display information about block devices which are storage devices such as hard disks, flash drives, etc.

lsblk

lsblk command in linux

lsusb command in Linux

The lsusb command in Linux is used to display information about USB controllers and all the other devices that are connected to them.

lsusb

lsusb command in linux

Linux Searching Commands

Linux Searching Commands are used to search for files, files contents, and directories. I listed out some most important Linux Searching Commands below

find command in Linux 

The find command in Linux is used to search for files and directories in a directory.

find [options] [path] [expression]

find command in linux

Note- As you can see in the above picture, I use the find command to search for a text file in /home/abhishek.

grep command in Linux

The grep stands for global regular expression print and grep command in Linux is used for searching the content from a file. Linux users mostly use grep command with pipe ( | ) operator.

grep "<searchword>" <file>

grep command in linux

Linux Commands Tips and Tricks

Below mentioned Linux Commands Tips and Tricks are very useful and helpful to ease the execution of commands.

help command in Linux

Suppose you get stuck with some command or don't know the syntax, Linux provides the utility of help command which prints detailed documentation of any particular command.

[command] --help

help command in linux

man command in Linux

man command in Linux is used to display the user manual of any command, which includes NAME, SYNOPSIS, DESCRIPTION, OPTIONS, etc

man [command]

man command in linux

Note- As you can see in the above image, which is the manual page of the find command.

Use of tab key

The tab key is the most used key in the command-line interface. Whenever you are entering the paths or filenames in the command line tab key is very useful that autocompletes the required path or file name for you.

Use of arrow keys

The arrow keys in the command line keep the history of the most recent commands you executed. By pressing the arrow up key, you can see the last commands you executed and the down key will move forward in history towards the most recent commands.

history command in Linux

history command in Linux displays a list of all recent commands you executed.

history

history command in linux

Tip- If you want to delete your bash history use the history -c command.

Shotcut to home folder

Suppose you are in some file or folder path /var/lib/python and you directly want to move towards the home folder, you can use ~ character along with cd where cd means change directory.

cd ~

shortcut command in linux

Tip- In case you forget your user name you can use whoami command in Linux which will display your username.

Linux Commands Cheat Sheet

In the above sections, I have discussed some important commands in detail that frequently used in Linux but in case if you are more curious to learn each command with advanced use cases, I have made a detailed commands sheet of each and every command including Advanced command options, file permission commands, etc

You can directly download this Linux commands Cheat Sheet by clicking on the below download button

Linux command cheat sheet

Conclusion

Now we understand that what is Linux with Linux commands in all formats. I hope that you had run and practice all the commands that I mentioned in the blog and moreover you also downloaded the Linux command cheat sheet that will help you a lot to push your knowledge from basics to advanced.

Thanks for reading this article, if you have any query you can leave a comment below.

Want to be an Ethical Hacker but don't know where to start? Don't worry here is the step by step process that you have to follow So click on How to become an Ethical Hacker

Related Blogs

Also, Read 

Subscribe Us

* indicates required

abhishek

I am a passionate software developer, providing solutions to make industry more robust. readmore