>_FoxiRef
>_/cheatsheet/linux
Linux

Linux Cheatsheet

Frequently used Linux commands

#File Management

CommandDescription
lsList files
ls -laList all with details
ls -lhHuman readable sizes
touch [file]Create empty file
cp [src] [dest]Copy file
cp -r [src] [dest]Copy directory
mv [src] [dest]Move/rename
rm [file]Remove file
rm -rf [dir]Force remove directory
mkdir [dir]Create directory
mkdir -p [path]Create with parents
rmdir [dir]Remove empty directory
ln -s [target] [link]Create symbolic link

#Viewing Files

CommandDescription
cat [file]Print file content
less [file]View with pagination
head [file]Show first 10 lines
head -n 20 [file]Show first 20 lines
tail [file]Show last 10 lines
tail -f [file]Follow file in real-time
wc [file]Count lines/words/bytes
wc -l [file]Count lines only

#Permissions

CommandDescription
chmod 755 [file]Change mode (numeric)
chmod +x [file]Add execute permission
chmod -w [file]Remove write permission
chmod u+x [file]Add execute for owner
chown [user] [file]Change owner
chown user:group [file]Change owner and group
chgrp [group] [file]Change group

#Processes

CommandDescription
psCurrent processes
ps auxAll processes detailed
ps aux | grep [name]Search processes
topReal-time process monitor
htopEnhanced process monitor
kill [pid]Kill process
kill -9 [pid]Force kill
killall [name]Kill by name
bgSend to background
fgBring to foreground
jobsList background jobs
nohup [cmd] &Run after logout

#Disk/Memory

CommandDescription
df -hDisk usage
du -sh [dir]Directory size
du -h --max-depth=1Sizes at depth 1
free -hMemory usage
mount [dev] [dir]Mount device
umount [dir]Unmount

#Network

CommandDescription
ping [host]Check host connection
curl [url]Request URL
curl -O [url]Download file
wget [url]Download file
ssh user@hostSSH connection
scp [file] user@host:[path]Remote file copy
netstat -tulpnShow open ports
ss -tulpnSocket statistics
ifconfigNetwork interfaces
ip addrShow IP addresses

#Compression

CommandDescription
tar -cvf arch.tar [files]Create tar archive
tar -xvf arch.tarExtract tar archive
tar -czvf arch.tar.gz [files]Create gzip archive
tar -xzvf arch.tar.gzExtract gzip archive
zip arch.zip [files]Create zip archive
unzip arch.zipExtract zip archive
gzip [file]Gzip compress
gunzip [file.gz]Gzip decompress

#Redirection/Pipes

CommandDescription
cmd > fileRedirect output (overwrite)
cmd >> fileRedirect output (append)
cmd < fileRedirect input from file
cmd 2> fileRedirect stderr
cmd &> fileRedirect stdout and stderr
cmd1 | cmd2Pipe output
cmd | tee fileOutput and save to file
cmd | xargs [cmd2]Pass as arguments

#Text Processing

CommandDescription
sort [file]Sort lines
sort -r [file]Reverse sort
sort -n [file]Numeric sort
uniq [file]Remove duplicates
cut -d: -f1 [file]Extract field
awk '{print $1}' [file]Print first column
sed 's/old/new/g' [file]Replace string
tr 'a-z' 'A-Z'Translate characters

#System

CommandDescription
uname -aSystem information
hostnameHostname
uptimeUptime
whoamiCurrent user
idUser ID info
dateCurrent date/time
calCalendar
historyCommand history
sudo [cmd]Run as root
su - [user]Switch user
shutdown -h nowShutdown now
rebootReboot

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

Linux Cheatsheet - Command Reference | Foxi Dev Reference