Linux Cheat Sheet
Linux Cheat Sheet
cat /etc/redhat-release shows installed redhat version whoami shows who you are logged in as
uptime displays system running/life time who shows who is logged into the system
shows who is logged in and what
hostname shows system host name w
they do
hostname -I shows ip addresses of the host groupadd test creates group “test”
creates “Gokhan” account with
last reboot displays system reboot history useradd -c “GK” -m Gokhan
comment “GK”
date displays current date and time userdel Gokhan deletes account “Gokhan”
usermod -aG Networkers adds account “Gokhan” to the
cal displays monthly calendar
Gokhan “Networkers” group
mount shows mounted filesy-stems File Permission
changes ownership of a
File Commands chown user
file/directory
shows file type and access changes user and group for a file or
ls -l chown user:group filename
permission directory
ls -a lists also hidden files r (read) permission, 4
less abc browse through a text file abc grep -v inverted search
head abc displays first 10 lines of file abc grep -o shows only matched part of the file
tail abc displays last 10 lines of file abc find /dir/ -name aaa* finds files starting with aaa in dir
displays last 10 lines of file abc and
tail -f abc find /dir/ -user Gokhan finds files owned by Gokhan in dir
follow it as it grows
outputs last lines of abc as it finds files modifed less than 10
tail -F abc find /dir/ -mmin 10
changes minutes ago in dir
file abc gets type of abc find /home -size +500M finds files larger than 500MB in /xyz
find [/folder/location] -name finds file names starting with
gpg -c abc encrypts file abc
[x] character x
locates the binary, source, and
gpg abc decrypts file abc whereis aaa
manual page of aaa
gpg abc decrypts file abc locate abc finds the location of abc quickly
pkill xyz kills process with name xyz bzip2 abc compresses abc file using bzip2.
compresses abc file into the archive
killall abc kills all processes named abc zip abc.zip abc
abc.zip.
tar -czvf archive.tar.gz compresses a full directory with all
program & starts program in the background
/home/temp2/ subdirectories
lists and resumes stopped jobs in
bg gzip -d xyz.gz extracts xyz.gz with gzip utility
the background
brings the most recent background
fg gunzip xyz.gz extracts xyz.gz with gzip utility
job to foreground.
fg x brings job x to the foreground bzip2 -d file.php.bz2 extracts xyz.gz with bzip2 utility
nice starts a process with a given priority bunzip2 file.php.bz2 extracts xyz.gz with bzip2 utility
changes priority of an already
renice unzip xyz.zip extracts xyz.zip with zip utility
running process
displays processes in a tree-like to view the contents of both files
pstree gunzip -c output.txt.gz
diagram without extracting
displays a memory usage map of creates tar named archive.tar
pmap tar cf archive.tar directory
processes containing directory
lists files opened by running extracts the contents from
lsof tar xf archive.tar
processes archive.tar
tar czf archive.tar.gz creates a gzip compressed tar file
Search Commands directory name archive.tar.gz
command -h / command to review all available options of the
tar xzf archive.tar.gz extracts a gzip compressed tar file
–help “command”
to find info documents about the tar cjf archive.tar.bz2 creates a tar file with bzip2
info command
“command” directory compression
displays a single line description
whatis command tar xjf archive.tar.bz2 extracts a bzip2 compressed tar file
about the”command”
to view detailed man page of the
$ man UNIXCOMMAND
“command”
used to search man pages for
apropos
available commands on a specific
LINUX COMMANDS CHEAT SHEET
by Gokhan Kosem, www.ipcisco.com
Networking Commands Install Commands
arp displays ARP table of the device yum search keyword compresses abc file using gzip.
displays ethernet activity and
arpwatch yum install abc installs abc package
Ethernet/ip pairings
displays description and summary
bmon displays bandwidth, captures yum info abc
info about abc package
installs package from local file
curl used for for file transfer rpm -i abc.rpm
named abc.rpm
used to analyze clients ip address,
dhclient yum remove abc Remove/uninstall abc package
subnet mask, gateway, dns server
dig used for simple DNS lookup yum list installedl lists all installed packages with yum
finds a package by a related
dstat collects and shows system resources yum search [keyword]
keyword
shows package information and
ethtool used to check settings of your NIC yum info [package_name]
summary
yum install installs a package using the YUM
ftp used for for file transfer
[package_name.rpm] package manager
dnf install installs a package using the DNF
host used for IP-Name matchings
[package_name.rpm] package manager
apt-get install installs a package using the APT
hping3 used for packet analyze
[package_name] package manager
used to monitor network interface installs an .rpm package from a local
ifstat rpm -i [package_name.rpm]
statistics file
used to check network interfaces
ip addr rpm -e [package_name.rpm] removes an .rpm package
and routing activities
iptables used for ip packet filtering Hardware Information Commands
displays messages in kernel ring
iftop displays current bandwidth usage dmesg
buffer
ifup/ifdown used to enable or disable interfaces cat /proc/cpuinfo displays CPU information
iwconfig used to configure wireless interfaces cat /proc/meminfo displays memory information
nload used as bandwidth monitoring tool lsusb -tv displays USB devices
nmap used for security audits dmidecode displays DMI/SMBIOS from BIOS
nslookup used also for DNS query hdparm -i /dev/sda displays info about disk sda
performs a read speed test on disk
ping used to check reachability hdparm -tT /dev/sda
sda
tests for unreadable blocks on disk
route displays IP Routing Table badblocks -s /dev/sda
sda
scp secured file transfer