Linux Commands Cheat Sheet | Using Linux Like a Pro

Linux Commands Cheat Sheet

Linux is one of the popular operating systems, and since it is open source, it has a lot of versions built on it. However, one thing remains unchanged, using commands to do everything on Linux. For instance, using “mkdir” to create a directory or using cd to change the active working directory. There are so many helpful commands that, after some time, we just get used to them. And to make it easier for you to know and use most of the Linux commands, here I am with a Linux Commands Cheat Sheet.

Linux does have its own cheat sheet for all the commands, and you can access it by using the man page. It is a manual for each command, how to use it, descriptions, and examples. However, at times, they are weirdly scary, with a huge index and a little difficult to understand.

Also Read: 11 Best Linux Distro For Programmers

Linux Commands Cheat Sheet: Use Linux Like a Pro

In this Linux Commands Cheat Sheet, we group Linux commands based on their operations, such as file operations, networks, and more. This should make the Linux Commands Cheat Sheet easier for you to understand, and you can directly refer to commands based on your interests.

To start with, let’s look at some commands that come in handy to do basic tasks. For instance, changing directories, listing files, and more. Don’t worry if they repeat later.

Quick Tip: Bookmark this Linux Commands Cheat Sheet to get a quick eye when in need.

Basic Linux Commands

Linux CommandDescription
manDisplays the manual pages for a command
lsLists files and directories from the current working directory
cdChanges the current working directory to new directory
pwdPrints the current working directory
mkdirCreates a new directory
touchMoves or renames files and directories
cpCopies, files, and directories
mvMoves or renames file and directories
rmRemoves files and directories
catDisplays the contents of a file
lessDisplays the contents of a file one page at a time
headShows the first few lines of a file
tailDisplays the last few lines of a file
grepSearches for a pattern in files
findSearches for files and directories
tarCreates or extracts compressed archives
chmodChanges the permissions of a file or directory
chownChanges the owner of a file or directory
chgrpChanges the group of a file or directory
sshConnects to a remote server using the secure shell protocol
scpCopies files between a local and remote server securely
wgetDownloads files from the internet
historyShows the command history
psDisplays the running processes
killTerminates a process
suSwitches to another user account
sudoExecutes a command with superuser privileges
dfShows the disk space usage of file systems
duDisplays the disk usage of files and directories
ifconfigDisplays network interface configuration
pingSends ICMP echo requests to a network host
netstatShows network connections and statistics
ssh-keygenGenerates SSH key pairs for secure authentication
sourceExecutes commands from a file in the current shell

Also Read: Want to Change Your Linux User Password? Here is the Guide For You


Linux Network Commands

Linux Network CommandsDescription
ifconfigDisplays or configures network interfaces
ipShows or manipulates routing, devices, policy routing, and tunnels
pingSends ICMP echo requests to a network host to check connectivity
traceroutePrints the route packets take to a destination host, showing each hop along the way
netstatShows network connections, routing tables, and network interface statistics
nslookupPerforms DNS lookups to retrieve domain name or IP address information
digPerforms DNS queries and displays detailed information about DNS records
hostPerforms DNS lookups and displays information about a particular host or domain
sshConnects to a remote server using the secure shell protocol
scpCopies files between a local and remote server securely
ftpTransfers files to and from a remote file server using the FTP protocol
curlSends HTTP requests and displays the response from a server
telnetConnects to a remote host using the Telnet protocol
ifupBrings a network interface up
ifdownBrings a network interface down
routeShows or manipulates the IP routing table
iptablesManages firewall rules and network address translation (NAT)
tcpdumpCaptures and analyzes network traffic
nmapScans network hosts and services to discover open ports and gather information
arpDisplays or modifies the Address Resolution Protocol (ARP) cache
ssShows detailed information about network sockets and connections
route addAdds a static route to the routing table
route delDeletes a static route from the routing table
ethtoolDisplays or modifies Ethernet device settings and statistics
iwconfigConfigures wireless network interfaces
hostnameDisplays or sets the system’s hostname
tcpdump -iCaptures network traffic on a specific network interface
iftopDisplays real-time network bandwidth usage by individual connections
netcatEstablishes network connections, reads from and writes to network sockets

Also Read: Best & Free Network Monitoring Tools for Linux


Linux File Commands

File CommandDescription
lsLists files and directories in the current directory
cdChanges the current directory
pwdPrints the current working directory
mkdirCreates a new directory
touchCreates an empty file or updates the timestamp of an existing file
cpCopies files and directories
mvMoves or renames files and directories
rmRemoves files and directories
catConcatenates and displays the contents of files
lessDisplays the contents of a file one page at a time
headDisplays the first few lines of a file
tailDisplays the last few lines of a file
fileDetermines the file type
findSearches for files and directories based on various criteria
locateFinds files and directories using a pre-built database
grepSearches for a pattern in files
wcCounts the number of lines, words, and characters in a file
diffCompares and displays the differences between two files
cmpCompares two files byte by byte
lnCreates a hard or symbolic link to a file or directory
chmodChanges the permissions of a file or directory
chownChanges the owner of a file or directory
chgrpChanges the group ownership of a file or directory
gzipCompresses files using the gzip compression algorithm
gunzipDecompresses files compressed with gzip
tarCreates or extracts compressed archives
zipCompresses files into a zip archive
unzipExtracts files from a zip archive
statDisplays file or file system status
duShows the disk usage of files and directories
dfShows the disk space usage of file systems
mountMounts a file system to a specified mount point
umountUnmounts a mounted file system
syncFlushes file system buffers

Also Read: How to Delete Files and Directories in Linux – Simple Guide


Linux User and Group Commands

User and Group CommandsDescription
useraddAdds a new user to the system
userdelDeletes a user account from the system
usermodModifies user account properties such as username, home directory, or default shell
passwdSets or changes the password for a user account
suSwitches to another user account or becomes the superuser
sudoExecutes a command with superuser privileges
chownChanges the owner of a file or directory
chgrpChanges the group ownership of a file or directory
chmodChanges the permissions of a file or directory
groupsDisplays the groups a user belongs to
idDisplays the user and group information for a given username or current user
whoamiPrints the username of the current user
adduserInteractive command for creating new user accounts
deluserAn interactive command for deleting user accounts
groupaddCreates a new user group
groupdelDeletes a user group
groupmodModifies group properties such as group name or GID
gpasswdManages the group password file, including adding or deleting members and managing group administrators
newgrpSwitches to a different group
passwdChanges the password for a user or group
fingerDisplays information about user accounts, such as login name, full name, and terminal
whoShows the list of currently logged-in users
wDisplays information about currently logged-in users and their activities
lastShows the list of last logged-in users and their login history
lognamePrints the login name of the current user
usermod -GAdds or removes a user from a specific group
usermod -sChanges the default shell for a user
usermod -lRenames a user account
groupmod -nRenames a group
pwckChecks the integrity of password and shadow files
su -cExecutes a command as another user

Also Read: How to Rename Files and Directories in Linux?


Linux Process Commands

Process CommandsDescription
psDisplays information about active processes
topShows real-time system resource usage and running processes
pgrepSearches for processes based on specified criteria and prints their process IDs
pkillSends a signal to processes based on specified criteria to terminate them
killallSends a signal to all processes with a specified name to terminate them
pidofPrints the process IDs of running processes based on their names
niceSets the priority of a process
reniceChanges the priority of running processes
pstreeDisplays running processes in a tree-like structure
topAn Interactive command that shows real-time system resource usage and running processes
htopAn Interactive process viewer that shows real-time system resource usage and running processes with additional features
uptimeShows the system uptime and load average
freeDisplays the system’s memory usage
vmstatReports virtual memory statistics
lsofLists open files and the processes that opened them
iotopMonitors and displays I/O usage by processes
sarCollects and reports system activity information, including CPU, memory, disk, and network usage
atSchedules commands or scripts to run at a specified time
cronSchedules recurring commands or scripts to run at specified intervals
watchExecutes a command repeatedly and displays the output in real-time
jobsLists the active jobs and their statuses in the current shell session
fgBrings a job to the foreground
bgResumes a job in the background
disownRemoves a job from the shell’s job control
sleepSuspends execution for a specified time
timeMeasures the time taken to execute a command
systemctlControls system services, including starting, stopping, and restarting
serviceControls system services, including starting, stopping, and restarting
systemdSystem and service manager for Linux
shutdownShuts down or restarts the system

VI Editor Commands

VI Editor CommandDescription
iEnters insert mode to start inserting text at the current cursor position
aEnters insert mode to start inserting text after the current cursor position
oOpens a new line below the current line and enters insert mode
OOpens a new line above the current line and enters insert mode
ddDeletes the current line
yyCopies the current line
pPastes the copied or deleted text after the current line
uUndoes the last command or action
/patternSearches forward for the specified pattern
?patternSearches backward for the specified pattern
nJumps to the next occurrence of the search pattern
NJumps to the previous occurrence of the search pattern
:wSaves the changes made to the file
:qQuits the VI editor
:q!Quits the VI editor without saving changes
:wqSaves the changes made to the file and quits the VI editor
: xSaves the changes made to the file and exits the VI editor; no space between : and x
:set numberDisplays line numbers in the left margin
:set nonumberHides line numbers in the left margin
:%s/old/new/gcReplaces all occurrences of ‘old’ with ‘new’ in the entire file with a confirmation
:e filenameReplaces all occurrences of ‘old’ with ‘new’ in the entire file with a confirmation
:r filenameInserts the contents of another file at the current cursor position
:w filenameSaves the current file with a different filename
:set tabstop=nSets the number of spaces for a tab character
:set autoindentEnables automatic indentation
:set nowrapDisables line wrapping
:set spellEnables spell checking
:set ruler:Displays a ruler at the bottom of the editor
:set background=darkSets the color scheme for dark backgrounds
:set background=lightSets the color scheme for light backgrounds
:helpDisplays the VI editor’s built-in help documentation

Environment Variable Commands

Environmental VariableDescription
exportSets an environmental variable
echoDisplays the value of an environmental variable
envDisplays all environmental variables
setDisplays all variables, including environmental variables
unsetRemoves an environmental variable
$PATHRepresents the search path for executable files
$HOMERepresents the home directory of the current user
$USERRepresents the username of the current user
$PWDRepresents the present working directory
$SHELLRepresents the current shell
$LANGRepresents the current language setting
$EDITORRepresents the default text editor
$TERMRepresents the terminal type
$DISPLAYRepresents the display server
$LOGNAMERepresents the login name of the current user
$MAILRepresents the location of the user’s mailbox
$HOSTNAMERepresents the hostname of the system
$PS1Represents the primary prompt string
$PS2Represents the secondary prompt string
$PS3Represents the select prompt string
$PS4Represents the selected prompt string
$IFSRepresents the internal field separator
$OLDPWDRepresents the previous working directory
$UIDRepresents the user ID of the current user
$EUIDRepresents the effective user ID of the current user
$GROUPSRepresents the groups the current user belongs to
$BASH_VERSIONRepresents the version of the Bash shell
$PWDRepresents the present working directory
$OSTYPERepresents the operating system type
$HISTSIZERepresents the maximum number of commands stored in the command history
$HOSTNAMERepresents the hostname of the system
$RANDOMRepresents a random number
$SECONDSRepresents the number of seconds the script has been running
$TZRepresents the current time zone

Package Management Linux Commands

CommandDescription
apt-get installInstalls a package and its dependencies from the repository
apt-get removeRemoves a package from the system
apt-get updateUpdates the package lists from the repositories
apt-get upgradeUpgrades all installed packages to the latest available versions
apt-get dist-upgradeUpgrades the system to the latest available version, including package dependencies
apt-get autoremoveRemoves automatically installed packages that are no longer needed
apt-get cleanClears the local repository of retrieved package files
apt-cache searchSearches for packages based on keywords
apt-cache showDisplays detailed information about a specific package
apt-cache dependsShows the dependencies of a package
dpkg -iInstalls a .deb package file
dpkg -rRemoves a package from the system
dpkg -lLists all installed packages
dpkg -LLists the files installed by a package
dpkg -SSearches for packages owning a specific file
dpkg-reconfigureReconfigures an installed package
yum installInstalls a package and its dependencies from the repository (used in CentOS/RHEL systems)
yum removeRemoves a package from the system (used in CentOS/RHEL systems)
yum updateUpdates all installed packages to the latest available versions (used in CentOS/RHEL systems)
yum searchSearches for packages based on keywords (used in CentOS/RHEL systems)
dnf installInstalls a package and its dependencies from the repository (used in Fedora systems)

Also Read: Best & Free Network Monitoring Tools for Linux


System Information Commands

CommandDescription
unameDisplays system information such as kernel name, hostname, kernel release, etc
hostnameShows the name of the current host system
lsb_releaseDisplays information about the Linux Standard Base and distribution-specific information
cat /etc/os-releasePrints detailed information about the Linux distribution
cat /proc/versionShows the Linux kernel version and build information
dateDisplays the current date and time
uptimeShows the system uptime, load average, and number of users logged in
whoamiPrints the username of the current user
whoDisplays information about currently logged-in users
dfShows disk space usage of file systems
freeDisplays memory usage and information
topProvides real-time information about system resource usage and processes
psShows information about active processes
htopInteractive process viewer that displays system resource usage and running processes with additional features
iostatReports CPU, disk, and input/output statistics
ifconfigDisplays network interface configuration
netstatShows network statistics and active network connections
routeDisplays or manipulates the IP routing table
lspciLists PCI devices connected to the system
lsusbLists USB devices connected to the system

Also Read: 10 Best & Free Screen Recorders for Linux/Ubuntu


Wrapping Up: Linux Commands Cheat Sheet

This sums up our handy Linux Commands Cheat Sheet for using Linux like a pro. However, this is not all. There are several more advanced commands which are more application related and need some more advancement in how you use Linux. Let’s try covering them up in our future blog post; let me know in the comment section if you need a more advanced Linux Commands Cheat Sheet. 

Before You Leave

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.

Give this article a quick share,

I hope this Linux Commands Cheat Sheet came in handy to you. If I have missed out on a common Linux command, do let me know in the comment section. If you like this article, do give this a quick share on your social media handles, and do tag us. Also, join our Telegram channelFacebook page, and Twitter to never miss a quick update.

Leave a Reply

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

Previous Post
Windows 11

Night Light Not Working on Windows 10 or 11? Here is the Fix

Next Post
Cleaning microphones

How to Clean Your Podcast Microphones? A Handy Guide

Related Posts
Popup subscribe Form Tiny Quip

Connect

Some Catchy Line to Grab your Attention

Get Our Prime Content Delivered to your Inbox for Free!! Join the Ever-Growing Community… Right Now.

Total
0
Share