Linux Cheat Sheet

File and Directory Operations:

        
# List files and directories
ls
ls -l
ls -a
ls -la

# Change directory
cd directory_path

# Create directory
mkdir directory_name

# Create empty file
touch file_name

# Copy file or directory
cp source_path destination_path

# Move file or directory
mv source_path destination_path

# Remove file
rm file_path

# Remove directory (empty)
rmdir directory_path

# Remove directory (recursive)
rm -r directory_path
        
    

File Permissions:

        
# Change file permissions
chmod permissions file_path

# Symbolic notation
chmod u+x file_path
chmod g+w file_path
chmod o-r file_path

# Numeric notation
chmod 755 file_path
chmod 644 file_path
        
    

File Editing:

        
# Open file with default text editor
nano file_path

# Open file with Vi editor
vi file_path

# Exit Vi editor (command mode)
:wq
        
    

Process Management:

        
# List running processes
ps

# Terminate process by ID
kill process_id

# Terminate process by name
pkill process_name
        
    

File Compression and Archiving:

        
# Create ZIP archive
zip archive.zip file1 file2 directory

# Extract ZIP archive
unzip archive.zip

# Create TAR archive
tar -cvf archive.tar file1 file2 directory

# Extract TAR archive
tar -xvf archive.tar
        
    

Network Operations:

        
# Check IP address
ifconfig

# Ping a host
ping host

# Connect to a remote host (SSH)
ssh username@host

# Download file from URL
wget file_url
        
    

System Information:

        
# Display system information
uname -a

# Display disk usage
df -h

# Display memory usage
free -h

# Display CPU information
cat /proc/cpuinfo

# Display available RAM
cat /proc/meminfo