0% found this document useful (0 votes)
12 views3 pages

Essential Linux Commands

Uploaded by

Bob
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)
12 views3 pages

Essential Linux Commands

Uploaded by

Bob
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/ 3

Essential Linux Commands

File and Directory Navigation

pwd Print current working directory


ls List directory contents
ls -l List with details (permissions, size, date)
ls -a Include hidden files
cd <dir> Change directory
cd .. Go up one level
cd ~ Go to home directory

File Operations

touch file.txt Create empty file


cp src dest Copy file or directory
mv src dest Move (or rename) file or directory
rm file.txt Remove file
rm -r dir/ Remove directory recursively
mkdir newdir Create a directory
rmdir dir Remove an empty directory

Viewing Files

cat file.txt View file contents (all at once)


less file.txt View file one screen at a time
more file.txt Similar to `less`
head -n 10 file Show first 10 lines
tail -n 10 file Show last 10 lines
tail -f log.txt Live view of logs

Finding Files and Text

find . -name "file.txt" Find file by name


grep "text" file.txt Search for text in a file
grep -r "text" dir/ Search recursively
locate file.txt Fast search (needs `updatedb`)

Permissions & Ownership

chmod 755 file Change permissions


chown user:group file Change owner and group

Disk and Resource Monitoring

df -h Disk space usage (human-readable)


Essential Linux Commands

du -sh dir/ Size of directory


top Live CPU/memory usage
htop Enhanced `top` (if installed)
free -h Show memory usage
uptime System load and uptime

Package Management (Ubuntu/Debian)

sudo apt update Update package list


sudo apt upgrade Upgrade installed packages
sudo apt install pkg Install a package
sudo apt remove pkg Uninstall a package

Archiving & Compression

tar -czvf file.tar.gz dir/ Compress directory


tar -xzvf file.tar.gz Extract archive
zip file.zip file1 file2 Create zip
unzip file.zip Extract zip

User Management

whoami Show current user


id Show user ID and groups
users Show logged in users
adduser newuser Add new user
passwd user Change password

Networking

ping google.com Test connectivity


wget URL Download from web
curl URL Fetch data from URL
ifconfig / ip a Show network interfaces

Process & Job Management

ps aux View running processes


kill PID Terminate a process
kill -9 PID Force kill
jobs View background jobs
bg Resume in background
fg Bring job to foreground
nohup cmd & Run immune to hangups
Essential Linux Commands

Text Editors

nano file.txt Open in Nano


vi file.txt Open in Vim
code . Open in VS Code (if installed)

Jupyter & Python-Specific

jupyter notebook Start Jupyter Notebook


jupyter lab Start Jupyter Lab
pip install package Install Python package
conda install package Install via Conda
python file.py Run a Python script

You might also like