Linux Command Line Cheat Sheet
Linux Command Line Cheat Sheet
CHEAT SHEET
A QUICK REFERENCE GUIDE from:
LinuxTrainingAcademy.com
https://www.LinuxTrainingAcademy.com
Table of Contents
1 - SYSTEM INFORMATION 2
2 - HARDWARE INFORMATION 2
3 - PERFORMANCE MONITORING AND STATISTICS 3
4 - USER INFORMATION AND MANAGEMENT 3
5 - FILE AND DIRECTORY COMMANDS 4
6 - PROCESS MANAGEMENT 5
7 - FILE PERMISSIONS 5
8 - NETWORKING 6
9 - ARCHIVES (TAR FILES) 7
10 - INSTALLING PACKAGES 7
11 - SEARCH 8
12 - SSH LOGINS 8
13 - FILE TRANSFERS 9
14 - DISK USAGE 9
15 - DIRECTORY NAVIGATION 9
16 - SECURITY 10
17 - LOGGING AND AUDITING 10
uptime # Show how long the system has been running + load
2 - HARDWARE INFORMATION
tail -100 /var/log/messages # Display the last 100 syslog messages (Use
/var/log/syslog for Debian based systems.)
usermod -aG sales john # Add the john account to the sales group
7 - FILE PERMISSIONS
PERMISSION EXAMPLE
U G W
rwx rwx rwx chmod 777 filename # Use sparingly!
rwx rwx r-x chmod 775 filename
rwx r-x r-x chmod 755 filename
rw- rw- r-- chmod 664 filename
LEGEND
U = User
G = Group
W = World
r = Read
w = write
x = execute
- = no access
8 - NETWORKING
ip a # Display all network interfaces and IP address
netstat -nutlp # Display listening tcp and udp ports and corresponding
programs
tar czf archive.tar.gz directory # Create a gzip compressed tar file name
archive.tar.gz.
tar cjf archive.tar.bz2 directory # Create a tar file with bzip2 compression
10 - INSTALLING PACKAGES
yum search keyword # Search for a package by keyword.
yum update package # Update package with name package for RHEL
based systems.
apt-get install package # Install package with name package for Debian
based systems.
11 - SEARCH
grep pattern file # Search for pattern in file
find /home/john -name 'prefix*' # Find files in /home/john that start with "prefix".
find /home -size +100M # Find files larger than 100MB in /home
12 - SSH LOGINS
ssh host # Connect to host as your local username.
scp server:/var/www/*.html /tmp # Copy *.html files from server to the local
/tmp folder.
scp -r server:/var/www /tmp # Copy all files and directories recursively from
server to the current system's /tmp folder.
14 - DISK USAGE
df -h # Show free and used space on mounted filesystems
15 - DIRECTORY NAVIGATION
cd .. # To go up one level of the directory tree. (Change into
the parent directory.)