Web & Dev

Linux Shell Commands

Essential Linux / Unix shell commands — file system, text processing, processes, networking.

File system

CommandPurpose
ls -laList files with details, including hidden
cd DIRChange directory
pwdPrint working directory
cp SRC DSTCopy file (-r for recursive)
mv SRC DSTMove / rename
rm -rf DIRRemove recursively, force
mkdir -p PATHCreate directory tree
ln -s TARGET LINKCreate symbolic link
chmod 755 FILESet permissions
chown user:group FILEChange ownership
du -sh DIRDirectory size, human-readable
df -hDisk free space
find . -name "*.log"Find files by name

Text processing

CommandPurpose
cat FILEPrint file
less FILEPaginated view (q to quit)
head -n 20 FILEFirst 20 lines
tail -f FILEFollow file (like logs)
grep -rn "text" .Recursive search with line numbers
sed -i "s/a/b/g" FILEIn-place substitution
awk '{print $1}'First column
sort | uniq -cCount occurrences
wc -l FILECount lines
cut -d, -f1 FILEFirst CSV column
tr a-z A-ZTranslate characters

Processes

CommandPurpose
ps auxAll processes
top / htopInteractive process monitor
kill -9 PIDForce kill
pkill NAMEKill by name
jobsBackground jobs
nohup CMD &Run detached
<cmd> &Background
Ctrl+Z / fg / bgSuspend / foreground / background

Networking

CommandPurpose
ip addrShow interfaces & IPs
ss -tulpnListening sockets (replaces netstat)
curl -sSL URLHTTP request
wget URLDownload file
ping HOSTICMP reachability
dig NAMEDNS lookup
ssh user@HOSTRemote shell
scp FILE user@HOST:/pathSecure copy
rsync -av SRC DSTEfficient sync
Was this article helpful?