[go: up one dir, main page]

0% found this document useful (0 votes)
7 views4 pages

Linux Commands CheatSheet

This document is a cheat sheet for essential Linux commands covering various categories such as file and directory management, file viewing and editing, searching, package management, system info, user management, permissions, networking, disk management, scheduling, archiving, cleaning, redirection, and shell scripting. Each command is accompanied by a brief description of its function. The document serves as a quick reference guide for users to efficiently navigate and utilize Linux commands.

Uploaded by

wolfcosmic5879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

Linux Commands CheatSheet

This document is a cheat sheet for essential Linux commands covering various categories such as file and directory management, file viewing and editing, searching, package management, system info, user management, permissions, networking, disk management, scheduling, archiving, cleaning, redirection, and shell scripting. Each command is accompanied by a brief description of its function. The document serves as a quick reference guide for users to efficiently navigate and utilize Linux commands.

Uploaded by

wolfcosmic5879
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Essential Linux Commands Cheat Sheet

File & Directory Management

ls # List files
ls -l # Long listing
ls -a # Show hidden files
cd /path/to/dir # Change directory
pwd # Show current directory
mkdir new_folder # Create directory
rmdir folder # Remove empty directory
rm file.txt # Remove file
rm -r folder # Remove folder recursively
cp source dest # Copy file/folder
mv source dest # Move or rename file/folder
touch file.txt # Create empty file
stat file.txt # Detailed info about file

File Viewing & Editing

cat file.txt # Show file content


less file.txt # Scrollable file view
more file.txt # View file (paged)
head file.txt # First 10 lines
tail file.txt # Last 10 lines
nano file.txt # Open file in nano editor
vim file.txt # Open file in vim

Searching & Finding

find . -name "*.txt" # Find .txt files


grep "text" file.txt # Search text in file
grep -r "text" . # Recursive search
locate filename # Fast file search (uses DB)
which command # Path of command
whereis command # All related paths

Package Management (Ubuntu/Debian)

sudo apt update # Refresh packages


sudo apt upgrade # Upgrade packages
sudo apt install pkgname # Install package
sudo apt remove pkgname # Remove package
sudo apt autoremove # Remove unused packages

System Info & Monitoring

uname -a # System info


Essential Linux Commands Cheat Sheet

top # Live process view


htop # Advanced task manager
ps aux # List processes
df -h # Disk usage
du -sh folder # Folder size
free -h # RAM usage
uptime # Time system is running
who # Who is logged in
hostname # System hostname

User Management

whoami # Current user


id # User ID & group info
adduser username # Add new user
passwd username # Set password
deluser username # Delete user
su - username # Switch user
sudo command # Run command as root

Permissions & Ownership

chmod 755 file # Change file permissions


chown user:group file # Change ownership
ls -l # Show permissions
umask # Default permission mask

Networking

ifconfig # Show network info


ip a # IP address (modern)
ping google.com # Ping server
traceroute google.com # Trace route
netstat -tulnp # Ports and services
ss -tuln # Show open ports
curl http://example.com # Fetch a web page
wget http://example.com # Download a file

Disk & Partition

lsblk # Show block devices


fdisk -l # List partitions
mount /dev/sdX /mnt # Mount disk
umount /mnt # Unmount disk
df -Th # Show filesystems
Essential Linux Commands Cheat Sheet

Scheduling & Background Jobs

crontab -e # Edit crontab


crontab -l # List cron jobs
at 5pm # Schedule one-time task
jobs # List background jobs
bg # Resume job in background
fg # Bring job to foreground
kill %1 # Kill background job

Archiving & Compression

tar -cvf archive.tar folder # Create tar


tar -xvf archive.tar # Extract tar
tar -czvf archive.tar.gz folder # Create gzip tar
tar -xzvf archive.tar.gz # Extract gzip tar
zip file.zip file1 file2 # Create zip
unzip file.zip # Extract zip

Cleaning & Temp Files

clear # Clear terminal


history # Show command history
!123 # Run command from history
alias ll='ls -alF' # Create alias

Redirection & Pipes

command > file.txt # Redirect output


command >> file.txt # Append output
command < input.txt # Input from file
command1 | command2 # Pipe output to another command

Shell Scripting Example

#!/bin/bash

echo "Hello World"


VAR="Linux"
echo "Welcome to $VAR"

# Run with: bash script.sh or chmod +x script.sh to make executable

File Permissions Reference


Essential Linux Commands Cheat Sheet

Symbolic | Octal | Meaning


-------- | ----- | ---------------------
rwx | 7 | read + write + execute
rw- | 6 | read + write
r-- | 4 | read
--- | 0 | no permission

You might also like