Linux Commands Cheat Sheet
Basic Commands
pwd # Print working directory.
ls # List files and directories.
ls -a # Include hidden files.
ls -l # Long listing format.
cd [path] # Change directory.
cd .. # Go up one directory level.
cd ~ # Go to the home directory.
mkdir [dir] # Create a new directory.
rmdir [dir] # Remove an empty directory.
rm [file] # Remove a file.
rm -r [dir] # Remove a directory and its contents.
touch [file] # Create an empty file.
cp [source] [destination] # Copy files or directories.
cp -r # Copy directories.
mv [source] [destination] # Move or rename files/directories.
cat [file] # View file contents.
less [file] # View file contents one page at a time.
head -n [number] [file] # View the first n lines of a file.
tail -n [number] [file] # View the last n lines of a file.
file [file] # Determine the file type.
File Permissions
ls -l # View file permissions.
chmod [permissions] [file] # Change file permissions.
# Example: chmod 755 file
# 7 = read, write, execute (owner)
# 5 = read, execute (group)
# 5 = read, execute (others)
Linux Commands Cheat Sheet
chown [owner]:[group] [file] # Change file ownership.
chgrp [group] [file] # Change group ownership of a file.
umask # Set default file creation permissions.
stat [file] # View file status including size, permissions, and
timestamps.
Process Management
ps # Display running processes.
ps aux # Detailed process list.
top or htop # Monitor processes in real time.
kill [PID] # Terminate a process by PID.
kill -9 [PID] # Force kill a process.
jobs # List background jobs.
fg [job] # Bring a background job to the foreground.
bg [job] # Resume a job in the background.
nice [priority] [command] # Run a command with a specified priority.
renice [priority] [PID] # Change the priority of a running process.
nohup [command] # Run a command immune to hangups.
pstree # Show a tree of processes.