Sciethesis
Sciethesis
Sciethesis
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.
Enjoy!
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
# 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
# Display the last 10 lines of file and "follow" the file as it grows.
tail -f 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
# 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
13 – FILE TRANSFERS
# Secure copy file.txt to the /tmp folder on server
scp file.txt server:/tmp
# 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 ..
16 – SECURITY
# Change the current user's password.
passwd
# Display SELinux details such as the current SELinux mode, the configured mode, and the loaded policy
sestatus
# Change the current SELinux mode to Permissive. (Does not survive a reboot.)
setenforce 0
# Change the current SELinux mode to Enforcing. (Does not survive a reboot.)
setenforce 1
# Set the SELinux mode to enforcing on boot by using this setting in the /etc/selinux/config file.
SELINUX=enforcing
# Set the SELinux mode to permissive on boot by using this setting in the /etc/selinux/config file.
SELINUX=permissive
# Set the SELinux mode to disabled on boot by using this setting in the /etc/selinux/config file.
SELINUX=disabled
Related Articles:
Linux ip Command Networking Cheat Sheet
Vim Cheat Sheet
Managing Linux Users and Groups
23 Handy Bash Shell Aliases For Unix, Linux, and Mac OS X
AlmaLinux, CentOS, cheat sheet, Command Line, Linux, RedHat, Server, Shell Scripting, SSH, Ubuntu
VirtualBox Troubleshooting Tips
Vim Cheat Sheet
Most Popular