Linux Commands
Essential Linux commands for navigating, managing files, and system administration.
File System Navigation
pwdPrint the current working directory path
ls -laList all files including hidden ones with details
cd /var/wwwChange directory to an absolute path
cd ..Move up one directory level
tree -L 2Display directory structure as a tree (2 levels deep)
File Operations
touch index.htmlCreate a new empty file
mkdir -p src/componentsCreate nested directories
cp -r src/ backup/Copy a directory and its contents recursively
mv old.txt new.txtRename or move a file
rm -rf node_modulesRemove a directory and all its contents
cat package.jsonDisplay the full contents of a file
head -20 README.mdShow the first 20 lines of a file
tail -f /var/log/syslogFollow a log file in real time
Permissions
chmod 755 deploy.shMake a script executable (owner rwx, others rx)
chmod +x script.shAdd execute permission to a file
chown user:group file.txtChange the owner and group of a file
ls -l file.txtView file permissions and ownership details
Process Management
ps auxList all running processes with details
topInteractive real-time view of system processes
kill -9 PIDForce kill a process by its ID
lsof -i :3000Find which process is using a specific port
nohup node server.js &Run a process in the background that survives logout
Networking
curl -I https://example.comFetch HTTP headers from a URL
wget https://example.com/file.zipDownload a file from the internet
netstat -tulpnList all listening ports and associated processes
ping -c 4 google.comSend 4 ICMP packets to test connectivity
ssh user@192.168.1.10Connect to a remote server via SSH
Search & Text Processing
grep -rn "TODO" src/Recursively search for text in files with line numbers
find . -name "*.log" -deleteFind and delete all .log files
wc -l src/**/*.tsCount lines in TypeScript files
sed -i 's/old/new/g' file.txtFind and replace text in a file
sort data.txt | uniq -cSort lines and count unique occurrences