Do you want to learn the Linux commands? If yes, then you are in the right place. There are uncountable commands in Linux. Generally, we use some of the Linux commands from the Linux commands cheat sheet regularly to perform the common tasks.
pythonarray.com is a free Python tutorial website for people who want to learn Python, fast.
You can also learn Google Sheets Tips – New Google Spreadsheet Hacks, Tricks with Examples
Types of Linux Commands
All the Linux commands are categorized into 7 different types. They are Basic Linux commands, File permission commands, Environment variables commands, User management commands, Networking commands, Process commands, VI Editing commands, Other Commands.
We are giving a detailed explanation for each and every Linux command with their examples for easy learning in the below sections. Have a look at them and follow them. Check the actual description of each Linux command in their manual page.
Basic Linux Commands
It is used to list all files and directories of a directory. The ‘-l’ option gives the long listing format. Its syntax is $ ls [options] [file|dir]
Example: $ ls -l samplefile
It gives the lists files in subdirectories. List recursively directory tree and syntax is $ ls -R [options] [file|dir]
Example: $ ls -R samplefile
It lists all files including hidden files starting with’.’ Its syntax is $ ls -a [options] [file|dir]
It lists all files details and directories with detailed information like permissions, size, owner, etc. Syntax is $ ls -al [options] [file|dir]
This command will navigate to the home directory or change the directory. Its syntax is $ cd [directory]
Example: $ cd Directory1
It moves one level up. Syntax is $ cd . . [directory]
Use this command to change to a particular directory. Its syntax is $ cd [directory]
Example: $ cd directory1
This command will move to the root directory. Syntax is $ cd /
Create a new file using this command in Linux. Its syntax is $ cat filename.
Example: $ cat filename1
It displays the content in that particular file. The syntax is $ cat filename.
Example: $ cat filename1.
- cat file1 file2 file3 Command:
It combines two files namely file1 and file2 and stores the output in a new file called file3. Its syntax is $ cat file1 file2 file3.
Example: $ cat add multiply arithmetic.
- mv file “new file path” Command:
It moves the files to the new location. Syntax is $ mv file “new file path”.
Example: $ mv add “E:/Arithmeticopeartions/”.
- mv filename new_file_name Command:
It renames or changes the file name to a new file name. Syntax is $ mv filename new_file_name.
Example: $ mv add sum
sudo command allows a permitted user to run a command as root or another user. It runs commands in superuser mode. The syntax is $ sudo filename option
Example: $ sudo apt update
It is used to remove the files or directories. Syntax is $ rm filename or $ rm directory
Examples: $ rm sum and $ rm mydrive
It is used to view the online reference manual pages for the commands or programs. It provides the help information of any commands. Its syntax is $ man commandname
Example: $ man cd
It produces the list of previously used commands and gets the all past commands types in the current terminal session. The syntax is $ history
clear command is helpful to clear the terminal screen. The syntax is $ clear
- mkdir directoryname Command:
It creates a new directory in the present working directory or at any specific path. Syntax is $ mkdir directoryname
Example: $ mkdir new_directory
$ mkdir -p new_directory: Here -p option is used to override the already available directory.
It helps to remove/ delete the empty directories. Syntax is $ rmdir [directory_name]
Example: $ rmdir new_directory
It is helpful to rename files or directories. mv command also moves a file or a directory to another location in the directory structure. Its syntax is $ mv file1 file2
Example: $ mv add sum
It divides the file into x columns. Syntax is $ pr -x filename.
Example: $ pr -5 add
It is useful to assign a header to the file. Syntax is $ pr -h filename
Example: $ pr -h sum
This command denotes the file with the line numbers. Its syntax is $ pr -n file
Example: $ pr -n sum
It prints the c number of copies of a file. lp stands for a line printer. Its syntax is $ lpr c filename
Example: $ lpr 5 sum
It specifies the name of the printer. The syntax is $ lp -P
It is a powerful and free front end package manager for Debian/Ubuntu systems. It is used to install new software packages, remove available software packages, upgrade existing software packages, and upgrade the entire operating system. Its syntax is $ apt-get package
Example: $ sudo apt-get update
- mail -s ‘subject’ -c ‘cc-address’ -b ‘bcc-address’ ‘to-address’ Command:
It is a linux command used to send mail. Syntax is $ mail -s ‘subject’ -c ‘cc-address’ -b ‘bcc-address’ ‘to-address’
Example: $ mail -s ‘regarding_job’ -c ‘add@gmail.com’ -b ‘sum@gmail.com’ ‘arithmetic@gmail.com’
- mail -s “Subject” to-address < Filename Command:
It is used to send an email with an attachment. Its syntax is $ mail -s “Subject” to-address < Filename
Example: $ mail -s “Addition of Numbers” sum@gmail.com < Addition
File Permission Commands
Use this command to show file type and access permission of any particular file. Syntax is $ ls-l filename
Example: $ ls-l sum
It is used to give read permission to a file. The syntax is $ r filename.
Example: $ r sum
It gives write permission to the file. The syntax is $ w filename
Example: $ w sum
It is useful to provide execute permission to the file. Its syntax is $ x filename
Example: $ x sum
This command is used when you want to give no permission to a file. Syntax is $ -= filename
Example: $ -= file1
It is helpful to change the ownership of a file/directory. The syntax is $ chown user filename
Example: $ chown user file1
- Chown user:group filename Command:
It changes the user and group for a file or directory. Syntax is $ chown user:group filename
Example: $ chown user:group sum
Environment Variables Command
It displays the value of a variable or prints a text of the line. Its syntax is echo [option] [string]
Example: $ echo “Print this line” or $ echo $VARIABLE var1
It lists all environment variables. The syntax is $ env
- VARIABLE_NAME= variable_value Command:
It creates a new variable and assigns it a value. Syntax is $ VARIABLE_NAME= variable_value
Example: $ My_Variable= 10
It removes a variable. Syntax is $ Unset VARIABLE_NAME
Example: $ Unset My_Variable
- export Variable=value Command:
It is helpful to set the value of an environment variable. Syntax is $ export Variable=value
Example: $ export Variable1=90
User Management Commands of Linux
- sudo adduser username Command:
It is used to create a username. The syntax is $ sudo adduser username
Example: $ sudo dduser user1
- sudo passwd -l ‘username’ Command:
It is helpful to change the user password. Syntax is $ sudo passwd -l ‘username’
Example: $ sudo passwd -l ‘user1’
- sudo userdel -r ‘username’ Command:
This command is used to add and delete users on Linux. Syntax is $ sudo userdel -r ‘username’
Example: $ sudo userdel -r ‘user1’
It is a user information lookup command which provides details of all users logged in. The Syntax $ finger
It gives the login details of that particular user. Syntax $ finger username
Example: $ finger user1
Networking Commands
- SSH username@ip-address or hostname Command:
You can log in to a remote Linux machine using SSH. The syntax is $ SSH username@ip-address or hostname
Example: $ SSH user1@https:11//1001
- Ping hostname=”” or =”” Command:
It is used for analyzing the network and host connections. Syntax is $ Ping hostname=”” or =””
Example: $ Ping hostname=”host1″
It displays all files in the current directory of a remote computer. The syntax is $ dir
It changes the current directory to “dirname” on a remote computer. Syntax is $ cd “dirname”
Example: $ cd “E”
It is helpful to upload the file from local to the remote computer. The syntax is $ put file
Example: $ put sum
It is used to download the file from remote to the local computer. The syntax is $ get file
Example: $ get add
It is used to logout from that network. The syntax is $ quit
Process Commands
You can send a process to the background with this command. The syntax is $ bg processname
Example: $ bg process1
To run a stopped process in the foreground. The syntax is $ fg processname.
Example: $ fg process1
It gives the details of all active processes in the directory. The syntax is $ top
It produces the status of processes running for a user. The syntax is $ ps username
Example: $ ps user1
This command gives the status of a particular process. The syntax is $ ps PID processname
Example: $ ps PID process1
It gives the process id of a process. The syntax is $ pidof processname.
Example: $ pidof process1
It kills a process. The syntax is $ kill PID processname
Example: $ kill PID process1
It is used to start a process with the given priority. The syntax is $ nice processname.
Example: $ nice process
It is used to change the priority of an already running process. The syntax is $ renice processname
Example: $ renice process2
It provides free hard disk space on your system. The syntax is $ df
It gives free RAM space on your system. The syntax is $ free
VI Editing Commands
It inserts at the cursor i.e goes to insert mode. The syntax is $ i
It is used to write after the cursor in insert mode. The syntax is $ a
This command is used to write at the end of the line in insert mode. The syntax is $ A
It is helpful to terminate insert mode. The syntax is $ ESC.
It undoes the last change. The syntax is $ u.
It undoes all changes to the entire line. The syntax is $ U
It opens a new line in insert mode. The syntax is $ o
It deletes that particular line. The syntax is $ dd line number
Example: $ dd 25
This command deletes 3 lines. The syntax is $ 3dd line number
Example: $ 3dd 25
It deletes the contents of a line after the cursor. The syntax is $ D
It is used to delete the contents of a line after the cursor and insert new text. Press the ESC key to end the insertion. Syntax is $ C
Delete a word using this command. The syntax is $ dw
It is used to delete 4 words. The syntax is $ 4dw
It is used to change a word. Syntax is $ cw
It deletes the character at the cursor. Syntax is $ x
Replace the character. The syntax is $ r
It overwrites characters from cursor onward. The syntax is $ R
Substitute one character under the cursor and continue to insert. The syntax is $ s
Substitutes the entire line and starts to insert at the beginning of the line. The syntax is $ S
It is used to change the case of the individual character. Syntax is $ ~
Other Linux Commands
- adduser/addgroup Command:
adduser adds a user and addgroup adds groups to the system. The syntax is $ adduser username
Example: $ sudo adduser tech
agetty is a program that manages physical or virtual terminals and is invoked by init. It is the substitute for Linux getty.
Example: $ agetty -L 9600 ttyS1 vt100
It is a useful shell built-in command for creating shortcuts to a Linux command on a system.
Example: $ alias home’cd /home/drive/file1′
This is used to search and display a short man page description of a program/ command. The syntax is $ apropos commandname
Example: $ apropos rm
It is a powerful text-based interface to the Debian Linux/GNU package management system. The syntax is $ aptitude package
Example: $ sudo aptitude update
This command is used to display the machine architecture or hardware name. The syntax is $ arch
ARP stands for Address Resolution Protocol that maps IP network addresses of a network neighbor with the hardware (MAC) addresses in an IPv4 network.
Example: $ sudo arp-scan –interface=enp2s0 –localnet
It is used to schedule tasks to run in the forthcoming time. Syntax is $ at
Example: $ sudo echo “shutdown -h now” | at -m 15:20
This command is used to view jobs in at command queue. Syntax is $ atq
It is helpful to delete/remove jobs from the queue. $ atrm 2
Awk is a programming language created for text processing and used as a data extraction and reporting tool.
Example: $ awk ‘//{print}’/etc/hosts
It is similar to at command which is useful to schedule tasks to run in a future time. Syntax is $ batch
It helps to print the name of a file stripping of directories in absolute path. Syntax is $ basename filename
Example: $ basename samplefile
It is useful to compress or decompress the files. Syntax is $ bzip2 filename
Example: $ bzip2 -z filename #Compress
$ bzip2 -d filename.bz2 #Decompress
This command is used to print a calendar on the standard output. Syntax is $ cal
It is used to change the group ownership of a file. Syntax is $ chgrp new_group_name filename
Example: $ chgrp Product Multiplication.txt
It is used to change/ update file access permissions. Syntax is $ chmod permission filename
Example: $ chmod +x product.txt
This command is used to provide the checksum and byte count of the given input file. Syntax is $ cksum filename
Example: $ cksum product.txt
It compares byte by byte comparison of two files. Syntax is $ cmp file1 file2
Example: $ cmp sum add
It is used to compare two sorted files line by line. Syntax is $ comm file1 file2
Example: $ comm product multiplication
It copies files and directories from one location to another. Syntax is $ cp location1 location2
Example: $ cp /home/arithmetic/add /home/arithmetic/product/
It displays/ sets the system date and time. Syntax is $ date
Example: $ date –set=”20 Oct 2020 10:35:05″
The double advantage of this command is used to compare two files line by line and used to find the difference between two directories. Syntax is $ diff file1 file2
Example: $ diff sum add
It retrieves the hardware information of any linux system. Syntax is $ dmidecode
Example: $ sudo dmidecode –type system
It shows the disk space usage of files present in the directory as well as its subdirectories. The syntax is $ du directory
Example: $ du /home/arithmetic
eject command is used to eject removable media such as CD/DVD/ROM/floppy disk from the system. The syntax is $ eject disklocation
Example: $ eject /dev/cdrom
It is used to exit a shell. The syntax is $ exit
It is used to calculate an expression. The syntax is $ expr expression
Example: $ expr 15 * 5
It is used to display the prime factors of a number. The syntax is $ factor number
Example: $ factor 18
It searches for files in the directory and its subdirectories. The syntax is $ find directory filename
Example: $ find /home/add/ -name product.txt
It searches for a specified pattern in the file and displays the output as lines containing that pattern. The syntax is $ grep
Example: $ grep ‘linuxcent’ domain-list.txt
Shows all names of groups of a user. The syntax is $ groups
It helps to compress a file and replaces it with one having a .gz extension. The syntax is gzip filename
Example: $ gzip passwds.txt
It expands or restores files compressed with the gzip command. The syntax is $ gunzip gzfilename
Example: $ gunzip sum.gz
It is helpful to display the first 10 lines of the specified file or stdin to the screen. The syntax is $ head
This command is useful to print or set the system hostname. The syntax is $ hostname
Example: $ hostname New_hostname
It shows user & group information for the current user or specified user. The syntax is $ id username
Example: $ id linuxcent
It is used to configure Linux system network interfaces. The syntax is $ ifconfig
This command is used to set or view process I/O scheduling class and priority of the specified process. The syntax is $ ionice process
Example: $ ionice -c 3 rm /var/logs/syslog
iostat command is helpful to show the CPU and i/o statistics for devices and partitions. The syntax is $ iostat
It is used to display or manage devices, routing, policy routing, and tunnels. The syntax is $ ip addr
This is used to manage wireless devices and their configuration. The syntax is $ iw
Example: $ iw list
It kills a process with the help of its name. The syntax is $ killall processname
Example: $ killall process1
It is useful to manage Linux kernel modules. To list all currently loaded modules, type. Syntax is $ kmod
Example: $ kmod list
It displays a list of last logged in users. The syntax is $ last
This is used to create a soft link between files using -s flag. Syntax is $ ln -s file1 file2
Example: $ ln -s product multiplication
It is used to find a file with its name. The syntax is $ locate filename
Example: $ locate -b ‘add.txt’
It gives detailed information on the hardware configuration of the machine. The syntax is $ lshw
This Linux command displays the system’s CPU architecture information. The syntax is $ lscpu
It displays information related to files opened by processes. The syntax is $ lsof processname
Example: $ lsof -u add
It shows information: about USB buses in the system and devices connected to them. The syntax is $ lsusb
This command is used to compute and print the MD5 message digest of the file.
It enables to view through relatively lengthy text files one screenful at a time. The syntax is $ more filename
Example: $ more add
You can open a file using this nano command. The syntax is $ nano filename
Example: $ nano sum
It displays useful information such as routing tables, network connections, and others about Linux networking subsystems. Syntax is $ netstat
Example: $ netstat -a | more
It shows the number of processing units present to the current process. The syntax is $ nproc
This command is used to create/update passwords for user accounts. The syntax is $ passwd username
Example: $ passwd user1
It displays running processes as a tree that is rooted at either PID or init if PID is omitted. The syntax is $ pstree
This command is used to power-off, halt, or reboot a system. The syntax is $ reboot
It enables you to securely copy files between hosts on a network. Syntax is $ scp
Example: $ scp ~/names.txt root@192.168.56.10:/root/names.txt
It schedules a time for the system to be powered down. Its syntax is $ shutdown
Example: $ shutdown –poweroff
This command is used to pause or delay for a specific amount of time. The syntax is $ sleep
Example: $ check.sh; sleep 5; sudo apt update
This is used to sort lines of text in the specified files from stdin. The syntax is $ sort
Example: $ sort add.txt
It is used to split a large file into smaller pieces. The syntax is $ split filename
Example: $ split add
It is helpful to know the file system status. The syntax is $ state filename
Example: $ stat -f add.txt
It is used to switch to another user ID or become root during a login session. The syntax is $ su
This command shows the checksum and blocks counts for all files on the command line. The syntax is $ sum output filename
Example: $ sum output add.txt
It concentrates and displays files in reverse. It prints each file to the standard output, shows the last line first. The syntax is $ tac filename
Example: $ tac sum.txt
It displays the last 10 lines of each file. The syntax is $ tail filename
Example: $ tail sum.txt
talk is used to talk to another network user/ system. Use a login name to talk to the user on the same machine and use ‘use@host’ to talk to a user on another machine. The syntax is $ talk
Example: $ talk person [ttyname] or $ talk ‘user@host’ [ttyname]
This is used to read from standard input & prints to standard output and files.
Example: $ echo “Testing how tee command works” | tee file1
This command runs programs and summarizes system resource usage. The syntax is $ time
It changes file timestamps and it is used to create a file. The syntax is $ touch filename
It displays system information such as operating system, network node hostname kernel name, version, and release, etc. Syntax is $ uname
It displays or omits repeated lines from input. The syntax is $ uniq
It shows how long the system has been running, the number of logged on users, and system load averages. The syntax is $ uptime
This command is used to send/display a message to all users on the system. The syntax is $ wall “message”
Example: $ wall “This is Linux operating system”
This command displays the word, newline, and byte counts for each file. The syntax is $ wc filename
Example: $ wc add.txt
It searches & shows a short or one-line manual page description of the provided command name. The syntax is $ whatis wget
It shows details about users who are currently logged in. The syntax is $ who
This command is used to get the absolute path of the file which would be executed in the current environment. The syntax is $ which who
It helps to locate binary, source and manual files for commands. The syntax is $ whereis cat
This command is used to display a string repeatedly until when terminated or killed. The syntax is 4 yes
Example: $ yes “This is LinuxCent – Linux HowTos”
zcmp and zdiff minimal utilities used to compare compressed files. Syntax is $ zcmp filesnames, $ zdiff filesnames
Example: $ zcmp domain-list.txt.zip basic_passwords.txt.zip
$ zdiff domain-list.txt.zip basic_passwords.txt.zip
It is simple & easy to use utility used to package & compress files. Syntax is $ zip packagename
Example: $ zip inarchive.zip foo.c bar.c –out outarchive.zip
We have mentioned all the Linux commands in the Linux Commands Cheatsheet. Make use of these countless commands that you might feel helpful.
What are 5 Linux commands?
Linux File commands
- touch Command. The touch command is used to create empty files. …
- cat Command. The cat command is a multi-purpose utility in the Linux system. …
- rm Command. The rm command is used to remove a file.
- cp Command. The cp command is used to copy a file or directory.
- mv Command. …
- rename Command.
How do I see all commands in Linux?
In Linux, there is a very useful command to show you all of the last commands that have been recently used. The command is simply called history, but can also be accessed by looking at your . bash_history in your home folder. By default, the history command will show you the last five hundred commands you have entered.
What is Linux cheat sheet?
Basic Linux commands

How many commands are in Linux?
There are well over 100 Unix commands shared by the Linux kernel and other Unix-like operating systems.
What does F do in Linux?
Many Linux commands have an -f option, which stands for, you guessed it, force! Sometimes when you execute a command, it fails or prompts you for additional input. This may be an effort to protect the files you are trying to change or inform the user that a device is busy or a file already exists.
How do I get a list of commands?
You can open the Command Prompt by pressing ⊞ Win + R to open the Run box and typing cmd. Windows 8 users can also press ⊞ Win + X and select Command Prompt from the menu. Retrieve the list of commands.
How do you list all commands in Terminal?
Just tap the Tab key twice ( Tab Tab ). You’ll be prompted if you want to see all possible commands. Tap y and you’ll be presented with a list. You can do that same thing for individual commands to see all options for that specific command.
How do you write commands in Linux?
Linux operating system allows users to create commands and execute them over the command line. To create a command in Linux, the first step is to create a bash script for the command. The second step is to make the command executable. Here, bashrc means run the Bash file.
What does Linux dd command do?
dd is a command-line utility for Unix and Unix-like operating systems, the primary purpose of which is to convert and copy files. … As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data.
What is Yum in Linux?
YUM is the primary package management tool for installing, updating, removing, and managing software packages in Red Hat Enterprise Linux. YUM performs dependency resolution when installing, updating, and removing software packages. YUM can manage packages from installed repositories in the system or from
What is Sudo in Linux?
Sudo stands for either “substitute user do” or “super user do” and it allows you to elevate your current user account to have root privileges temporarily. This is different from “su” which is not temporary.
How use Linux command line?
On many systems, you can open a command window by pressing the Ctrl+Alt+t keys at the same time. You will also find yourself on the command line if you log into a Linux system using a tool like PuTTY. Once you get your command line window, you’ll find yourself sitting at a prompt.
What is Ubuntu command?
The latest LTS release is 20.04; it will be available till 2025. Ubuntu supports both Command Line Interface (CLI) and Graphical User Interface (GUI) to perform various tasks on the OS. CLI is the basic way to interact with systems hardware (processor/memory); you can perform all the tasks that GUI can perform.
Where is Linux command?
The whereis command in Linux is used to locate the binary, source, and manual page files for a command. This command searches for files in a restricted set of locations (binary file directories, man page directories, and library directories).