https://clramirez.com/wp-content/uploads/00-linux-cheat-sheet.jpg
SHARE
https://clramirez.com

A list of commands that are undoubtedly needed for navigating & administering Linux:

Linux Cheat Sheet

CommandUsage
badblocks -s /dev/sdaBad blocks disk sda
bgShow stopped/background jobs
calcurrent month calendar
cat /etc/redhat-release
cat /etc/os-release
redhat version
centos / ubuntu
cat /proc/cpuinfoCPU info
cat /proc/meminfoMemory info
cat fileShow file: entire content displayed in terminal
cdNavigate to $HOME DIR
cd ..Navigate up one DIR (parent DIR)
cd /etcNavigate to /etc DIR
clearClear output currently in terminal
cp -r source_directory destinationCopy (recursively) SOURCE => TARGET, if target currently exists merge SOURCE & TARGET
cp file1 file2Copy file1 => file2 (SOURCE => TARGET)
datecurrent date & time
df -hDisplay used/free space on mounted filesystems
df -iDisplay used/free inodes on mounted filesystems
dig -x IP_ADDRESSReverse lookup IP_ADDRESS
dig domainDNS info for DOMAIN
dmesgKernel buffer messages
dmidecodeBIOS info
du -ahDisplay disk usage for all files/DIR in (human readable)
du -shDisplay total disk usage off current DIR
ethtool eth0Modify network driver & hardware settings
fdisk -lDisplay disks partitions sizes/types
fgContinue recent background in foreground
fg nContinue job # in foreground
find /home -size +100MFind files larger than 100MB in /home
find /home/john -name 'prefix*'Find files in /home/chris that start with "prefix"
free -h
free -g
free -m
Memory usage (-h = human readable)
Memory usage (-g = GB)
Memory usage (-m = MB)
grep -r pattern directorySearch recursively for [DESIRED-CONTENT] in DIR
grep pattern fileSearch [DESIRED-CONTENT] in FILE
groupadd coolCreate "cool" group
hdparm -i /dev/sdaDisk info sda
hdparm -tT /dev/sdaTest Read speed disk sda
head fileShow file: first 10 lines
host domainDNS IP for DOMAIN
hostnamename of host
hostname -iNetwork address for HOST
hostname -I (uppercase i)All local IP's
htopInteractive "top"
idUser/Group ID current user
ifconfig -aAll NIC's & IP's
ifconfig eth0eth0 address/details
iostat 1I/O stats
kill pidKill process ID of 1234
killall processnameKill all processes named firefox
lastLast user(s) logged on
last reboothistory of reboot
less fileShow file: content displayed in paged format
ln -s /path/to/file linknameCreate sym-link (SHORTCUT) to linkname (SHORTCUT name)
locate nameLocate FILES & DIR by name
ls -alShow all files
lsofAll open files on the system
lsof -u userAll files by user
lspci -tvPCI devices
lsusb -tvUSB devices
man commandGet "help-file" and examples of how to use a command
mkdir directory
mkdir -p directory
Make DIR
Make -p [parent] directories if they don't exit
mpstat 1Proc stats
mv file1 file2Rename/move file1 => file2 (careful, you can overwrite files using this... if you want to copy, use the copy command) If file2 is DIR, move file1 into DIR file2
netstat -nutlptcp/udp ports & programs
ping hostSend ICMP echo request to host
program &Start program & run in background
psShow your processes
ps -efShow ALL processes
ps -ef | grep processnameShow info for process
pwdPrint working DIR
rm -f fileForce delete file (no prompt: CAUTION)
rm -r directoryDelete DIR (recursively)
rm -rf directoryForce delete DIR recursively (no prompt: CAUTION)
rm fileRemove/delete file
rpm -i package.rpmInstall SOFTWARE using local file named SOFTWARE.rpm
rsync -a /home /backups/Synchronize /home to /backups/home
rsync -avz /home
server:/backups/
Synchronize files/directories between local and remote system with compression enabled
scp -r server:/var/www /tmpCopy all files and directories recursively from server to current system's /tmp DIR.
scp file.txt server:/tmpCopy file.txt to /tmp DIR on server
scp server:/var/www/*.html /tmpCopy *.html files from server to local tmp DIR
ssh -p port user@hostConnect as specified user w/ using specified port
ssh hostConnect as current user
ssh user@hostConnect as user specified
tail -f fileShow file: last 10 lines & continue showing file (useful in troubleshooting)
tail 100 /var/log/messagesFollow 100 syslog messages (Debian = var/log/syslog)
tail fileShow file: last 10 lines
tar cf archive.tar directory[C]reate TAR [F]>ile "archive.tar" using "directory" as contents
tar cjf archive.tar.bz2 directory[C]reate TAR [F]ile using bzip2[j] compression "archive.tar.bz2" using "directory" as contents
tar czf archive.tar.gz directory[C]reate TAR [F]ile using g[z]ip compression "archive.tar.gz" using "directory" as contents
tar xf archive.tarE[x]tract contents [F]rom "archive.tar"
tar xjf archive.tar.bz2E[x]tract contents bzip2[j] compressed TAR [F]ile.
tar xzf archive.tar.gzE[x]tract contents g[z]ip compressed TAR [F]ile.
tar zxvf sourcecode.tar.gz
cd sourcecode
./configure
make
make install
Install SOFTWARE using source code
tcpdump -i eth0All packets on eth0 NIC
tcpdump -i eth0 'port 80'All port 80 (HTTP)traffic on eth0 NIC
topTop processes
topShow top processes
touch fileCreate/update file access/modification times of file.
uname -aSystem info
uname -rkernel info
uptimetime since last reboot
useradd -c "Chris Ramirez" -m chrisCreate account "Chris Ramirez" -m (make home directory) with login as "chris"
userdel chrisDelete account "chris"
usermod -aG cool chrisAdd account "chris" to group "cool"
vmstat 1Virt mem stats
wAll currently logged in + activity
watch df -hContinuous updates "df -h"
wget http://domain.com/fileDownload http://DOMAIN.com/file
whoAll currently logged in
whoamiusername you are logged on as
whois domainWHOIS info for DOMAIN
yum info packageInfo about SOFTWARE
yum install packageInstall SOFTWARE
yum remove packageUninstall/Remove SOFTWARE & Dependencies
yum search keywordSearch with keyword
SHARE
https://clramirez.com

Leave a Reply

Your email address will not be published. Required fields are marked *