Linux
Commands
Cheat Sheet
</>
Linux Commands Cheat Sheet
1
Directory
cd
navigate through files
and directories
cd..
move one
directory up
mkdir [directory]
create a new directory
cd-
pwd
move to your
previous directory
show the directory
currently working in
rmdir
delete a directory
and its contents
scp [file_name.txt] [server/tmp]
securely copy a specific file to a server directory
rsync -a [/your/directory] [/backup/]
synchronize the contents of a specific directory with a backup directory
Disk Usage
df
du
du -sh
findmnt
get a report on the system’s
disk space usage
check the disk space
usage of a file or directory
fdisk -l
show disk partitions,
sizes, and types
du -ah
show disk usage for
all files and directory
show target mount point
for all filesystems
show disk usage of
the current directory
File Commands
ls
list files in
a directory
cat
ls -R
list all files in
the sub-directories
list the contents of a
file on standard output
ls -a
list all hidden files
cat > filename
creates a new file
list all files and directories with detailed
information like permissions, size, owner, etc
diff
compare the contents
of two files line by line
cat filename 1 filename2>filename3
joins two files (1 and 2) and stores the output
in a new file (3)
ls -al
tar
archive multiple files into
a common Linux file format
tar xf [compressed_file. tar]
extract archived file
cat filename | tr a-z A-Z >output.txt tar czf [compressed_file.tar.gz
convert a file to upper or lower case
create a gzip-compressed tar file
tar cf [compressed_file. tar] [file_name]
create an archived file from a file
chmod
change the read, write, and execute
permissions of files and directories
chown
gzip [file_name]
compress a file with the .gz extension
change or transfer file ownership
rm [file_name]
remove a file
Linux Commands Cheat Sheet
2
File Commands
wc
rm -r [directory_name]
rm -rf [directory_name]
cp
cp [file_name1] [file_name2]
remove a directory recursively
copy files from the current
directory to a different directory
remove a directory recursively without
requiring confirmation
print the number of words,
lines, and bytes in a file
wget
copy the contents of the first file to
the second file
mv
cp -r [directory_name1] [directory_name2]
recursively copy the contents of the first directory into the second directory
mv [file_name1] [file_name2]
rename file_name1 to file_name2
download files from
the internet
to move or rename files
ln -s /path/to/[file_name] [link_name]
create a symbolic link to a file
touch [file_name]
more [file_name]
head [file_name]
tail [file_name]
gpg -c [file_name]
gpg [file_name.gpg]
create a new file
show the contents of a file
show the last 10 lines of a file
show the first 10 lines of a file
encrypt a file
sudo
perform tasks that need
administrative or root permissions
locate
to search for a file
or directory
decrypt a file
find
jobs
to locate files within
a directory
display current jobs
kill
history
uname
man
zip
unzip
top
ps
echo
hostname
ping
terminate an
unresponsive program
compress files into
a zip archive
move data into a file
review the commands
you entered before
extract zipped files
from a zip archive
know the name of
your host/network
print information about
your Linux system
monitor system
resource usage
show manual instructions
of Linux commands
show a snapshot
of active processes
check connectivity
to a server
Network
ip addr show
ifconfig
netstat -pnltu
whois [domain]
dig [domain]
host [domain]
show IP addresses and
network interfaces
show more information
about a domain
show IP addresses of
all network interfaces
show DNS information
about a domain
show active ports
do an IP lookup for
a domain
netstat -nutlp
show more information
about a domain
Linux Commands Cheat Sheet
System
3
User
uname -r
last reboot
id
passwd
timedatectl
date
useradd
last
hostname -i
uptime
show system
information
query and change
the system clock
show the IP address
of the system
show system
reboot history
show details
of the user
show current
time and date
add a password to
a user’s account
create a new user
show last logins
userdel [user_name]
show how long the system
has been running, including
load average
remove a user
Keyboard Shortcuts
Ctrl + E
Ctrl + A
Ctrl + C
Ctrl + W
TAB
Ctrl + Q
Ctrl + Z
Ctrl + S
move to the end
of the line
autofill typing
move to the beginning
of the line
unfreeze the terminal
stop and terminate
the current command
pause the command
cut one word before the cursor
and add it to the clipboard
freeze the terminal
Ctrl + U
Ctrl + K
Ctrl + Y
Ctrl + R
Ctrl + G
Ctrl + O
!!
exit
cut part of the line before the cursor
and add it to the clipboard
recall the last command that
matches the provided characters
repeat the last command
cut part of the line after the cursor
and add it to the clipboard
exit command history without
running a command
log out of the current session
paste from clipboard
run the previously
recalled command