Basic Linux Commands Cheat Sheet [Free PDF Download]

Linux command is a set of instructions for carrying out a certain action in Linux. In this article, I will illustrate a basic Linux commands cheat sheet to make your journey with the Linux command line easier. Type these commands into the terminal to handle everything from files and directories to processes and more.

Download Basic Linux Commands Cheat Sheet

Basic Linux commands cheat sheet image

Available Download Options


Most Popular

PDF (2 Pages)

DOC (2 Pages)

Combo Pack

ZIP (pdf, docx, png)

What is a Linux Command?

A Linux command is a text-based interface that allows you to communicate with the Linux operating system. The commands are inserted into a terminal which is then passed to a shell that tells the operating system what to do. Linux command is a great alternative to Graphical User Interface (GUI) as it is much faster and more efficient. You can perform all tasks with commands that can be done using the GUI.

Basic Linux Commands List

Here I have categorized all the basic commands in Linux. You can also find that some commands are mentioned with their necessary options. For your better understanding, the structure of a Linux command is

Command -options arguments parameters

File and Directory Management

In this category, you will find commands that can be used to copy, make, and remove files; create directories; and navigate through these.

Command Description
cp Copies files and directories
pwd Prints the current working directory
cd  Changes current directory
cd.. Changes to the parent directory
cd – Changes to the previous directory
cd ~ Changes to the home directory
ls Lists contents of the current directory
ls -l Lists the files and directories in the current working directory in long format
ls -a Lists all files and directories including the hidden ones
ls -r Lists files/directories in reverse
mkdir Creates a new directory 
rmdir Removes an empty directory
mv Moves or renames a file /directory 
rm  Removes a file/directory 
rm -i Prompts system confirmation before deleting
rm -r Deletes a file/directory recursively
rm -d Deletes empty folders

File Manipulation

Under this section, you can find commands which will assist you in editing your files and show contents in your desired ways.

Command Description
touch  Creates an empty file/modify timestamp
cat Concatenates and prints file contents
cat -n Displays the contents of a file along with line numbers
tac Concatenates and prints file contents in reverse order
less Shows contents in a scrollable manner
head Displays the first ten lines of a file
tail Displays the last ten lines of a file
grep Searches for a specified pattern in one or more files
nano Edits and creates files
diff Compares two text files
sort Sorts lines of a text file
sort -r Sorts file reversely
sort -u Removes duplicates and sorts unique values

Permissions

Here, you will get to know how you can change the permission of a file or directory:

Command Description
chmod Modifies a file or directory’s read, write, and execute permissions
chown Changes the ownership of a file, directory, or symbolic link to a specified username.
chgrp Changes the group ownership of a file or directory

Control System

This section consists of commands that can be used to control the operating system just by using the command line.

Command Description
poweroff Shuts down the system
reboot Restarts the system
shutdown Shuts down or reboots the system

System and Process Management

Commands for system and process management are:

Command Description
sudo Allows a user to run a command with the privileges of another user
ps Lists the running processes on a system
kill Terminates running processes on a system
killall Terminates all processes with a specified name
df Displays the amount of disk space used and available on a file system
du Estimates file space usage

Package Installation

Commands for package installation are:

Command Description
apt install [package] Installs software packages from the Ubuntu package repository
apt-get install Performs package management tasks such as installing, upgrading, and removing packages

File Compression

Commands for file compression are:

Command Description
tar Creates, views, and extracts files from an archive file
zip Creates, views, and extracts files from a compressed archive file
unzip Extracts files from a compressed archive file in the ZIP format
gzip Compresses files or directories to reduce their size
bzip2 Compresses files or directories to reduce their size

Search

If you are searching for a pattern in a file content or want to locate files in your system these basic commands are here to help you.

Command Description
grep ‘pattern’ files Searches for a specified pattern or regular expression in one or more files and display the matching lines
grep  -r pattern dir Searches for a specified pattern or regular expression recursively in a directory and its subdirectories, and display the matching lines.
locate Locates files and directories on the system
find Locates files and directories on the system
find -empty Searches for empty files

Help Documentation

Linux has huge commands and options to offer. It’s ok if you can’t memorize all these. Use the built-in documentation command to get help.

Command Description
man Displays the manual page of a command or utility

System Information

Commands to get system information are:

Command Description
date Displays and sets system date and time
cal or ncal Displays the calendar of the current month
who Displays information about currently logged-in user
whoami Displays the user name of the current user logged in
uname Displays information about the current system and operating system
hostname Displays or set the hostname of the current system
hostnamectl Queries or modifies the hostname and related settings of the current system
history Displays a list of previously executed commands in the terminal
history -c Clears the history list of previously executed commands
df Shows information about both total and available space on a file system

User Management

You can easily add or remove a user in your system using the following commands.

Command Description
useradd Creates a new user account on the system
userdel Deletes a user account from the system
passwd Changes a user’s password
groupadd Adds a new group to the system
groupdel Deletes an existing group from the system
Id Displays the user and group IDs associated with the current user
su Switches to another user account

Miscellaneous

Finally, we have listed more commands that may help you in your Linux journey.

Command Description
echo Displays a line of text or a variable value on the command line
clear Clears the terminal window
wc Counts the number of lines, words, and characters in a file
vim Texts editor for editing text files
ping Checks the connectivity between two network devices
exit Exits the current shell session
htop Displays the system’s process real-time process activity
shred Securely deletes the files by overwriting multiple times
w Displays information about the currently logged-in users and their activities
ps Displays the running processes
whatis Displays a brief description of a command
wget  Downloads files from the internet

Conclusion

If you are just starting or are still in the learning phase with Linux, these are a few basic commands you will need to know. Furthermore, these commands were comprehensive enough to cover virtually every job performed from the Linux command line.

People Also Ask

What are the basic commands of Linux?

Some basic Linux commands are as follows:

  • ls: Lists files & directories.
  • cd: Changes directory.
  • pwd: Prints current working directory.
  • cp: Copies files and directories.
  • mv: Moves and renames files or directories.
  • rm: Removes files or directories.
  • mkdir: Creates directories.
  • rmdir: Removes empty directory.
  • cat: Displays file contents.
  • echo: Displays a message or a variable.
  • grep: Searches for a pattern in a file.
  • chmod: Changes file permissions.
  • chown: Changes file ownership.

What is sudo in Linux?

In Linux, sudo stands for superuser do, it allows users to execute commands as a superuser. And superuser is the root user in the Linux system having the administrative privileges to perform different actions that regular users can not do.

Which is the best Linux?

There is no straightforward answer to this question. In fact, it depends on your project’s needs and your personal preferences. Some popular Linux distributions include Ubuntu, Fedora, Arch Linux, CentOS, etc.

5/5 - (5 votes)
LINUX
FUNDAMENTALS
A Complete Guide for Beginners Enroll Course Now
icon linux

Lamisa Musharrat

Hello there. My name is Lamisa Musharat, and I'm an Linux Content Developer Executive at SOFTEKO. I earned a bachelor's degree in Naval Architecture and Marine Engineering from Bangladesh University of Engineering and Technology (BUET).I learned Linux out of my curiosity and now I find it useful as automation is easier using Linux. I take great pleasure in assisting others with Linux-related issues. I really want you to enjoy and benefit from my efforts.Read Full Bio

2 thoughts on “Basic Linux Commands Cheat Sheet [Free PDF Download]”

Leave a Comment