Skip to main content

Linux Command Cheat Sheet

Everyday commands for web development — keyword search supported

lsList directory contents
ls -laDetailed list including hidden files
cd ~/projectsSwitch to the projects directory
cd ..Go up one directory
pwdPrint current path
mkdir myappCreate a new folder
mkdir -p a/b/cCreate nested folders in one go
rm file.txtDelete a file
rm -rf myfolderForce delete a folder (use with care)
cp src.txt dst.txtCopy a file
mv old.txt new.txtMove or rename a file
touch index.htmlCreate an empty file
find . -name '*.js'Search for .js files under the current directory
cat file.txtPrint the entire file
less file.txtPage through a file (q to quit)
head -n 20 file.txtShow the first 20 lines
tail -f app.logFollow log output in real time
grep 'error' file.logSearch for a keyword in a file
grep -r 'TODO' ./srcRecursively search a directory
wc -l file.txtCount lines
diff a.txt b.txtCompare two files
chmod +x script.shMake a file executable
chmod 755 fileSet rwxr-xr-x permissions
chown user:group fileChange file owner
sudo commandRun as administrator
ls -lView permissions (rwxr-xr-x format)
ps auxList all running processes
ps aux | grep nodeFilter for node processes
kill 1234Terminate the process with PID 1234
kill -9 1234Force kill a process
topLive view of system resource usage
htopInteractive system monitor (install required)
&Append & to run a command in the background
jobsList background jobs
Ctrl+CAbort the running command
Ctrl+ZSuspend the process (fg to resume)
curl https://example.comSend a GET request
curl -X POST -d '{}' urlSend a POST request
wget https://example.com/fileDownload a file
ping google.comTest network connectivity
netstat -tulpnList open ports
ss -tulpnShow socket status (modern netstat replacement)
ssh user@hostSSH into a remote host
scp file user@host:/pathCopy a file to a remote host
ifconfigView network interfaces (legacy)
ip addrView network interfaces (modern)
apt updateRefresh the package list
apt install nginxInstall a package
apt remove nginxRemove a package
apt upgradeUpgrade all packages
which nodeShow install location of a command
node -vShow Node.js version
npm init -yInitialize a project (skip prompts)
npm installInstall package.json dependencies
npm install expressInstall the express package
npm install -D viteInstall as a dev dependency
npm run devRun the dev script
npm run buildRun the build script
npx create-react-app myappScaffold a React project with npx
git initInitialize a Git repository
git clone urlClone a remote repository
git statusShow current status
git add .Stage all changes
git commit -m 'msg'Commit changes
git push origin mainPush to remote
git pullPull latest changes
git branchList all branches
git checkout -b feat/xCreate and switch to a new branch
git log --onelineCompact commit history
git stashStash current changes
df -hShow disk usage
du -sh ./Size of the current directory
free -hShow memory usage
uname -aShow system info
uptimeShow uptime and load
historyShow command history
echo $PATHPrint the PATH variable
envList all environment variables