Navigation & File Management
- Go back to previous directory
cd -
- Create and enter directory
mkdir myapp && cd $_
- List files with sizes (human readable)
ls -lh
- Show hidden files
ls -a
- Find files by name
find . -name "*.js"
- Delete files interactively
rm -i file.txt
- Show directory size
du -sh folder/
Search & Text Processing
- Search text in files (recursive)
grep -R "TODO" .
- Case‑insensitive search
grep -i "error" log.txt
-
Count lines, words, characters
wc file.txt -
View file with paging
less file.txt -
Print first 10 lines
head file.txt -
Print last 10 lines (live logs)
tail -f app.log -
Replace text in files
sed -i 's/old/new/g' file.txt -
Sort file contents
sort names.txt
Git Power Tricks
-
Undo last commit (keep changes)
git reset --soft HEAD~1 -
Discard all local changes
git reset --hard -
Show commit graph
git log --oneline --graph --all -
Stash with message
git stash push -m "WIP" -
List changed files only
git diff --name-only -
Fix last commit message
git commit --amend
Productivity & Shortcuts
-
Repeat last command
!! -
Run last command as sudo
sudo !! -
Search command history
Ctrl + R -
Clear terminal
clear -
Exit terminal fast
exit -
Open current folder in file manager
xdg-open .
Networking & System
-
Check open ports
lsof -i -P -n -
Test HTTP endpoint
curl https://api.example.com -
Download file
wget https://example.com/file.zip -
Check disk usage
df -h -
Show running processes
ps aux -
Kill process by name
pkill node
Docker & DevOps
-
List Docker containers
docker ps -a -
Stop all containers
docker stop $(docker ps -q) -
Remove unused Docker data
docker system prune -
Build Docker image
docker build -t myapp . -
Exec into running container
docker exec -it container_name bash
Bash & Scripting
-
Make script executable
chmod +x script.sh -
Run script in background
./script.sh & -
Redirect output to file
command > output.txt -
Pipe output to another command
ps aux | grep node -
Set environment variable
export NODE_ENV=production
Advanced & Fun
-
Watch command output live
watch -n 1 ls -
Measure command time
time npm run build -
Generate random password
openssl rand -base64 16 -
Create alias
alias gs="git status" -
List aliases
alias -
Quick HTTP server
python3 -m http.server -
One‑liner system info
uname -a
Final Tip
Mastering the command line saves hours every week. Start with 5 tricks and build from there — especially if you’re serious about web development.
Top comments (3)
I prefer
pwgento generate a secure random password. By restricting it to base64, you've only got two special characters. pwgen will use all of them, and also has some more options.Aready knew (and use) most of these - but, this is a great list, contains quite a few nuggets of gold!
Thankyou for Your Feedback