Linux Commands Cheat Sheet - Linux Training Academy
Linux Commands Cheat Sheet - Linux Training Academy
Linux Commands Cheat Sheet - Linux Training Academy
About Products Books Linux for Beginners Resources Video Training Courses
Did you know that there are literally hundreds of Linux commands? Even on a bare-bones Linux
server install there are easily over 1,000 different commands.
The interesting thing is that most people only need to use a very small subset of those
commands. Below you’ll find a Linux “cheat sheet” that breaks down some of the most
commonly used commands by category.
To get your own PDF and printable copy scroll to the bottom of the page
To get your own PDF and printable copy, scroll to the bottom of the page.
Enjoy!
Contents [hide]
1 – SYSTEM INFORMATION
2 – HARDWARE INFORMATION
3 – PERFORMANCE MONITORING AND STATISTICS
4 – USER INFORMATION AND MANAGEMENT
5 – FILE AND DIRECTORY COMMANDS
6 – PROCESS MANAGEMENT
7 – FILE PERMISSIONS
8 – NETWORKING
9 – ARCHIVES (TAR FILES)
10 – INSTALLING PACKAGES
11 – SEARCH
12 – SSH LOGINS
13 – FILE TRANSFERS
14 – DISK USAGE
15 – DIRECTORY NAVIGATION
1 – SYSTEM INFORMATION
# Display Linux system information
uname -a
2 – HARDWARE INFORMATION
# Display messages in kernel ring buffer
dmesg
# Display free and used memory ( -h for human readable, -m for MB, -g for GB.)
free -h
# Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.)
tail -100 /var/log/messages
# Display free and used memory ( -h for human readable, -m for MB, -g for GB.)
free -h
# Display the last users who have logged onto the system.
last
# Create an account named john, with a comment of "John Smith" and create the user's
home directory.
useradd -c "John Smith" -m john
# Create a directory
mkdir directory
cp -r source_directory destination
# Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory
file2
mv file1 file2
# Create an empty file or update the access and modification times of file.
touch file
# Di l th l t 10 li f fil
# Display the last 10 lines of file
tail file
6 – PROCESS MANAGEMENT
# Display your currently running processes
ps
7 – FILE PERMISSIONS
PERMISSION EXAMPLE
U G W
rwx rwx rwx chmod 777 filename
rwx rwx r-x chmod 775 filename
rwx r-x r-x chmod 755 filename
rw- rw- r-- chmod 664 filename
rw- r-- r-- chmod 644 filename
LEGEND
U = User
G = Group
W = World
r = Read
w = write
x = execute
- = no access
8 – NETWORKING
# Display all network interfaces and IP address
ip a
# Download http://domain.com/file
wget http://domain.com/file
10 – INSTALLING PACKAGES
# Search for a package by keyword.
yum search keyword
# Install package.
yum install package
# Remove/uninstall package.
yum remove package
11 – SEARCH
# Search for pattern in file
grep pattern file
12 – SSH LOGINS
# Connect to host as your local username.
ssh host
# Connect to host as user
ssh user@host
13 – FILE TRANSFERS
# Secure copy file.txt to the /tmp folder on server
scp file.txt server:/tmp
# Copy all files and directories recursively from server to the current system's /tmp
folder.
scp -r server:/var/www /tmp
# Synchronize /home to /backups/home
rsync -a /home /backups/
# Synchronize files/directories between the local and remote system with compression
enabled
rsync -avz /home server:/backups/
14 – DISK USAGE
# Show free and used space on mounted filesystems
df -h
# Display disk usage for all files and directories in human readable format
du -ah
15 – DIRECTORY NAVIGATION
# To go up one level of the directory tree. (Change into the parent directory.)
cd ..
Related Posts:
Linux ip Command Networking Cheat Sheet
Vim Cheat Sheet
Managing Linux Users and Groups
How to Find Any File or Command on a Linux System
Filed Under: blog — Tagged With: CentOS, cheat sheet, Command Line, Linux, RedHat, Server, Shell Scripting,
SSH, Ubuntu
M tP l
Most Popular
Topics