Linux Commands Cheat Sheet - Codelvily
Linux Commands Cheat Sheet - Codelvily
Codelvily
The command line terminal in Linux is the operating systemʼs most powerful
component. However, due to the sheer amount of commands available, it can be
intimidating for newcomers. Even longtime users may forget a command every once
in a while and that is why we have created this Linux cheat sheet commands guide.
In this page, weʼll present you with a curated list of the most handy Linux
commands.
Please note that those commands are for Linux in general, both RedHat-like and
Debian-like distributions. There are some commands in the Package management
session which may be specific for Redhat-based such as yum and rpm which do
not work in Ubuntu Debian-based).
head [file_name] Display the first 10 lines of a file with head command
[command] \| tee [filename] Store the command output in a file and skip the
>/dev/null terminal output
Searching
Command Descr iption
grep [pattern]
Search for a specific pattern in a file with grep
[file_name]
grep -r [pattern]
[directory_name]
Recursively search for a pattern in a directory:
locate [name] Find all files and directories related to a particular name:
Directory Navigation
Command Descr iption
tar cf [compressed_file.tar] [file_name] Archive an existing file
Package management
Command Descr iption
List all installed packages with
yum list installed
yum
Find a package by a related
yum search [keyword]
keyword
Process management
Command Descr iption
ps See a snapshot of active processes
bg
List and resume stopped jobs in the background
Bring the most recently suspended job to the
fg foreground
Bring a particular job to the foreground
fg [job]
List files opened by running processes
lsof
Disk Usage
Command Descr iption
SSH Login
Command Descr iption
ssh user@host Connect to host as user
File Permission
Command Descr iption
chmod 777 [file_name] Assign read, write, and execute permission to everyone
Give read, write, and execute permission to owner, and read
chmod 755 [file_name]
and execute permission to group and others
Assign full permission to owner, and read and write permission
chmod 766 [file_name] to group and others
Change the ownership of a file
chown [user]
[file_name]
chown [user]:[group]
[file_name]
Change the owner and group ownership of a file
Network
Command Descr iption
ip addr show List IP addresses and network interfaces
Variables
Command Descr iption
watch -n [interval-in-
seconds] [command]
Set a custom interval to run a user-defined command
Hardware information
Command Descr iption
dmesg Show bootup messages
fsck [disk-or-partition-location]
Run a disk check on an unmounted disk or partition