Linux Ubuntu Commands Cheat Sheet

 


System Information Ubuntu Commands

System information commands in Ubuntu enable users to retrieve important information about their system such as user information, CPU usage, etc. See the table containing system information command lists below:

CommandsDescription
freeDisplays the amount of free and used memory in the system
psDisplays a snapshot of the current processes
ps auxDisplays detailed information about all processes currently running
uptimeDisplays the current uptime of the system
wDisplays the list of currently logged-in users
unameDisplays system information
uname -aDisplays detailed system information
hostnameDisplays the name of the current host
infoProvides access to the documentation of various installed software packages
lshwLists hardware configuration of the system
historyDisplays a list of previously executed commands
helpDisplays information about built-in shell commands
manDisplays the manual page for a specified command
ttyReports the file name of the terminal device that is currently used to interact with the shell

System Administration Ubuntu Commands

In this section, I have listed system administration Ubuntu commands that you can use to monitor system performanceinstall and update software, and other administrative tasks. Check out the following table:

CommandsDescription
sudoAllows users to run programs with the security privileges of another user, typically the root user
sudo -sStarts a shell with root privileges
sudo -s -u -userStarts a shell with the privileges of the specified user
sudo -kInvalidates the user’s cached credentials
sudo visudoOpens the sudoers file for editing
sudo -H nautilusOpens the file browser with root privileges
sudo  /etc/init.d/gdm restartRestarts the GDM (GNOME Display Manager) service
sudo /etc/init.d/kdm restartRestarts the KDM (KDE Display Manager) service
passwdAllows users to change their password
shutdownShuts down the system in a safe way
syncForces all file system changes to be written to disk
rebootReboots the system
installInstalls one or more packages on a Linux system using a package manager
setstatusDisplays the status of the SELinux security system
serviceControls system services, such as starting, stopping, and restarting them
getentRetrieves entries from databases
envDisplays the current environment variables or sets a new environment variable
jobsDisplays a list of jobs running in the background of a shell

Permission Management Ubuntu Commands

In this section, I’ve listed the commands you’ll need to change access permissions and perform other system administration tasks:

CommandsDescription
chmodChanges the permissions of a file or directory and determines who can read, write, or execute a file
chownChanges the owner and/or group of a file or directory

System Monitoring Ubuntu Commands

This category contains system monitoring Ubuntu commands that allow users to monitor system performance and provide real-time information on system resource usage and process activity. To check the system monitoring Linux commands, go through the below table:

CommandsDescription
topDisplays information about the active processes running on the system
htopShows a list of all the running processes throughout the system
vmstatShows detailed information about system performance, including memory usage, CPU utilization, and Input/Output (I/O) statistics
freeDisplays the total amount of free and used memory in the system, as well as the buffers and cached memory used by the kernel
psDisplays information about the active processes on the system, including their process ID (PID), CPU usage, memory usage, and other details
uptimeDisplays how long the system has been running and the current system load averages
timeMeasures the execution time of a command or script
dmesgDisplays the kernel ring buffer messages, which include system boot messages and other kernel-related messages
fingerDisplays information about a user, including their login name, full name, home directory, login shell, and the time they last logged in

Shell Built-in Ubuntu Commands

The shell directly executes some commands. Here, you can find these commands without the use of an external program. Following are the shell built-in Linux commands:

CommandsDescription
exportSets environment variables that are used by processes started by the shell that exported the variable
echoDisplays text on the screen or redirects it to a file or variable
aliasCreates a shortcut or alternate name for a command
unaliasRemoves an alias previously created with the “alias” command.
exitCloses the current shell or terminal session
clearClears the terminal screen
bashEnables users to interact with Linux Operating System
declareDeclares variables and specifies their attributes, such as their data type or scope
sourceExecutes a script in the current shell environment rather than creating a new subshell to run the script

File and Directory Management Ubuntu Commands

You can use the file and directory management Ubuntu commands to manage and manipulate files and directories, such as copyingremovingsearching, and navigating through them. Get the list in a tabular form below:

CommandsDescription
mkdirCreates a new directory
cdChanges the current working directory to a specified directory
cd ..Changes the current working directory to the parent directory of the current directory
pwdPrints the current working directory
rm [file]Removes a file
rm -r [dir]Removes a directory and its contents
rm -f [file]Forces the removal of a file
rm -rf [dir]Forces the removal of a directory and its contents
mvMoves or renames files or directories
cpCopies files or directories
locateSearches for files in a database that contains a cached record of all files on the system
cmpCompares two files byte-by-byte and reports the first byte and line that differs between them
commCompares two sorted files line by line and displays the lines that are common or unique to each file
lsofLists all open files and the processes that opened them
chgrpChanges the group ownership of files and directories
fileDetermines the type of a file by examining its contents
fsckChecks and repairs a file system for errors
patchApplies a patch file to an original file, making the changes specified in the patch file
statDisplays detailed information about a file, including its size, permissions, owner, and modification time

File Management and Manipulation Ubuntu Commands

You’ll find commands in this category that allow users to manage and manipulate files and directories, such as creating, listing, and comparing files and directories, making it simple to organize and work with files on your Linux system. For example:

CommandsDescription
lsLists files in a directory
ls -alLists all files in a directory, including hidden files, with detailed information.
ls -RLists files in a directory and all of its subdirectories
ls -aLists all files in a directory, including hidden files
touchModifies timestamps of a file or creates an empty file if it doesn’t exist
diffCompares two files line by line and shows the differences between them

Compression and Archiving Ubuntu Commands

This category contains commands that enable users to compress, decompress, and archive files:

CommandsDescription
zipArchives files and directories into a compressed zip archive format
unzipExtract the contents of a zip archive file
bzip2Compresses files using the Burrows-Wheeler block sorting text compression algorithm and Huffman coding
gzipCompresses files using the Lempel-Ziv algorithm and Huffman coding
gunzipDecompresses files that have been compressed using gzip
tarCreates and manipulates archive files

Package Management Commands in Ubuntu

These commands allow users to manage software packages by installingremovingupdating, and searching for packages:

CommandsDescription
apt-get updateUpdates the list of available packages
apt-get upgradeUpgrades all installed packages to their latest version
apt-get dist-upgradeUpgrades all installed packages to their latest version
apt-get install pkgInstalls a package
apt-get purge pkgCompletely removes a package, including its configuration files
apt-get autoremoveRemoves any packages that were installed as dependencies and are no longer needed
apt-get -f installAttempts to fix any broken dependencies and install missing packages
dpkg -lLists all installed packages
dpkg – -configure -aConfigures all packages that have been unpacked but not yet configured
dpkg -i pkg.debInstalls a package from a .deb file
snapInstalls and manages applications on systems

Network Configuration and Firewall Management Commands

In this category, you’ll find commands for configuring and managing network interfaces and firewall rules in the Linux operating system:

CommandsDescription
wgetDownloads files from the internet
ifconfigShows network interface configuration
iwconfigShows wireless network interface configuration
sudo iwlist scanScans for available wireless networks
sudo systemctl restart networking.serviceRestarts the networking service
ifup interfaceBrings up a network interface
ifdown interfaceBrings down a network interface
firewall -cmdAllows users to configure and manage the firewall settings
ufw enableEnables the firewall
ufw disableDisables the firewall
ufw default allowSets the default policy to allow traffic
ufw default denySets the default policy to deny traffic
ufw statusShows the status of the firewall
ufw allow portOpens a port
ufw deny portCloses a port
ufw deny from ipBlocks traffic from a specific IP address

Network Management Ubuntu Commands

These commands allow users to manage network connectionsdisplay network information, and troubleshoot network issues:

CommandsDescription
ipDisplays and manipulates network interfaces and routing tables
pingSends a packet to a host and measures the response time
sshRemotely logs into a server or other device over a network
scpTransfers files between hosts on a network

User Management Ubuntu Commands

You can use user management commands to manage user accounts and permissions, such as creatingmodifying, and deleting user accountsmanaging user groups, and setting permissions on files and directories, all of which contribute to the security and accessibility of the system. The table containing user management Linux commands is given below:

CommandsDescription
useraddCreates a new user account, including setting up a home directory and assigning a password
adduserCreates a new user account interactively or using command-line options
whoDisplays information about the users who are currently logged in
whoamiDisplays the current username of the user who is logged in
idDisplays the user and group IDs of a specified user or the current user
usermodModifies a user account, such as changing the user’s login name, password, home directory, or group membership
usersDisplays a list of usernames of users who are currently logged in
suSwitches the current user to another user account, usually with elevated privileges, by prompting for the target user’s password
chageModifies the password expiry information for a user
userdelDeletes a user account and all associated files and directories
addgroupCreates a new user group
groupaddCreates a new user group
groupmodModifies the properties of an existing user group

Disk Management Commands in Ubuntu

In this section, you’ll find commands for displaying disk usage, as well as creating, resizing, and formatting disk partitions, as well as mounting and unmounting file systems, to help you optimize storage usage and maintain the health of your Linux system’s storage. Check the table below:

CommandsDescription
dfDisplays the disk usage statistics for the file system
df -hDisplays the disk usage statistics for the file system in human-readable format
duEstimates the file space usage
fdiskAllows users to create, delete, and modify partitions on hard drives, flash drives, and other storage devices
shredSecurely deletes files by overwriting them multiple times with random data
ddCopies and converts data between files, partitions, and devices at the block level
mountMounts a file system, making it accessible at a specified mount point in the directory tree
mke2fsCreates a new ext2/ext3/ext4 file system on a specified device
mkfsCreates a new file system on a specified device and supports various file system types such as ext2, ext3, ext4, NTFS, and FAT32

Text Processing Ubuntu Commands

In this section, I’ve listed commands for editingsearchingsorting, and transforming text to help you work with large text files and automate text processing tasks:

CommandsDescription
wcCounts the number of lines, words, and characters in a text file
sortSorts the lines of a text file in alphabetical or numerical order
nanoAllows users to create and edit text files
cutExtracts specific columns or fields from a text file
jedOpens up a powerful text editor that supports multiple modes and macros
viOpens up a powerful text editor that uses modal editing to allow for quick and efficient editing
vimOpens up a more advanced version of the vi editor with additional features such as syntax highlighting and plugins
pasteMerges lines from multiple files and writes them to the standard output
egrepSearches a text file for lines that match a specified pattern using extended regular expressions
splitSplits a text file into smaller files based on the number of lines or bytes
sedA stream editor that performs editing operations on a text stream or file
trTranslates or deletes characters in a text stream or file
uniqFilters out duplicate lines from a sorted text file
catDisplays the contents of a file on the terminal
headDisplays the first ten lines of a file on the terminal
tailDisplays the last ten lines of a file
grepSearches for a specific pattern or text in a file or output
lessDisplays the contents of a file one page at a time, allowing scrolling back and forth.
moreDisplay the contents of a text file one screen at a time allowing user to scroll up and down through the file, search for specific text, and navigate to specific lines

Miscellaneous Commands in Ubuntu

This section contains commands that provide additional functionality and utility, such as task scheduling, time and calendar display, and so on:

CommandsDescription
lsblkLists information about all available or specified block devices and can also display the relationship between the different devices, such as partitions and logical volumes
enableEnables or disables a service at startup or a specific hardware device or driver
bcCommand-line calculator that allows for floating-point arithmetic and advanced mathematical functions
cronAutomates tasks to run at specified times or intervals
crontabSchedules periodic commands or scripts to run at specified intervals
ncalDisplays a calendar for a given month or year
neofetchDisplays system information and an ASCII art logo of the operating system
treeDisplays a directory tree structure in a hierarchical forma
whereisLocates the binary, source, and manual page files for a command
whatisDisplays a brief description of a command
whichDisplays the location of a command or script in the system’s PATH
atSchedules a one-time command or script to run at a specified time
teeRedirects the output of a command to a file and to the screen
dateDisplays the current date and time

Ubuntu Keyboard Shortcuts

In this section, you will find some keyboard shortcuts for Ubuntu. Using these shortcuts can help you save time on your tasks:

CommandsDescription
CTRL+ALT+TOpens terminal in Ubuntu
CTRL+APlaces the cursor at the start of the active line
CTRL+EPlaces the cursor at the end of the active line.
CTRL+URemoves the entire active line
CTRL+KRemoves the command from the cursor to the right
CTRL+WRemoves the word preceding the cursor.
CTRL+RPerforms a history search for commands that match the user’s input
CTRL+CStop the active process
CTRL+ DCloses the current terminal
CTRL+ZSends the signal SIGSTOP to temporarily halt the active process
CTRL+LClears terminal display
CTRL+QResumes suspended commands
CTRL+SHalts command output to the screen
CTRL+ZHalts the current command and places it in the background
CTRL+GExits the history search mode.
CTRL+JCompletes the history search at the current command line.
CTRL+OExecutes the command found in the reverse search.
CTRL+N / Down ArrowDisplays the following command line
CTRL+P / Up ArrowDisplays the preceding command line
CTRL+ _Undo the last action
ALT+FGoes forward one word
ALT+BGoes back one word
ALT+PSearches the history forward from the current line
CTRL+SHIFT+TOpens a new tab on the currently active terminal.
CTRL+SHIFT+WCloses the active tab
CTRL+SHIFT+CCopies the highlighted characters to the clipboard
CTRL+SHIFT+V or SHIFT+INSERTPastes contents of the clipboard to the active line
Up/Down Arrow keysAllows to quickly execute previous commands multiple times
TABCompletes the typing command
CTRL+B / Left ArrowMoves cursor position one character backward
CTRL+F / Right ArrowMoves cursor position one character forward
CTRL+XXSwitches between the current cursor position and the start line
CTRL+]+AMoves the cursor forward to next character of A
ALT+CTRL+]+ABacks the cursor to the preceding character of A

Comments