Linux Commands

Files & Navigation

ls -laList all with details
cd /pathChange directory
pwdPrint working dir
mkdir -p dirCreate dir (nested)
cp src destCopy file
cp -r src destCopy directory
mv src destMove / rename
rm fileDelete file
rm -rf dirDelete dir recursively
touch fileCreate empty file
ln -s target linkCreate symlink
tree -L 2Show dir tree

File Content

cat filePrint file content
less fileScrollable viewer
head -n 20 fileFirst 20 lines
tail -n 20 fileLast 20 lines
tail -f fileFollow file updates
wc -l fileCount lines
sort fileSort lines
uniqRemove duplicates
diff a bCompare files
cut -d: -f1Extract columns

Search & Find

find . -name "*.js"Find by name
find . -type f -mtime -1Modified today
grep "pattern" fileSearch in file
grep -r "pat" dirRecursive search
grep -iCase insensitive
grep -nShow line numbers
which cmdLocate command
locate fileFast file search

Permissions

chmod 755 filerwxr-xr-x permission
chmod +x fileMake executable
chown user:grp fileChange owner
chown -R user dirRecursive ownership
r=4 w=2 x=1Permission values
sudo cmdRun as superuser

Process Management

ps auxList all processes
top / htopLive process monitor
kill PIDTerminate process
kill -9 PIDForce kill
killall nameKill by name
bg / fgBackground / foreground
nohup cmd &Run after logout
jobsList background jobs

Disk & System

df -hDisk space usage
du -sh dirDirectory size
free -hMemory usage
uname -aSystem info
uptimeSystem uptime
whoamiCurrent user
hostnameMachine name
lsblkList block devices

Networking

curl URLHTTP request
wget URLDownload file
ping hostTest connectivity
ssh user@hostRemote login
scp file user@host:pathSecure copy
netstat -tulpnOpen ports
ss -tulpnSocket stats (modern)
ip addrNetwork interfaces

Archives & Compression

tar -czf a.tar.gz dirCreate gzip archive
tar -xzf a.tar.gzExtract gzip archive
tar -xf archive.tarExtract tar
zip -r a.zip dirCreate zip archive
unzip a.zipExtract zip
gzip / gunzipCompress / decompress

Piping & Redirection

cmd > fileRedirect stdout to file
cmd >> fileAppend to file
cmd 2> err.logRedirect stderr
cmd1 | cmd2Pipe output
cmd < fileInput from file
cmd &> /dev/nullDiscard all output
tee fileWrite & pass through
xargs cmdBuild args from stdin
allprintabledoc.com