COMMANDS CHEAT SHEET by Gokhan Kosem, www.ipcisco.com System Information Commands User Information Commands shows user&group ids of the current -a shows Linux system info id user uname -r shows kernel release info last shows the last users logged on /etc/redhat-release shows installed redhat version whoami shows you are logged in as uptime displays system running/life 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 creates group “test” creates “Gokhan” account with last reboot displays system reboot history useradd - “GK” -m Gokhan comment “GK” date displays current date and time userdel Gokhan deletes account “Gokhan” usermod -aG Networkers adds account “Gokhan” to the displays monthly calendar Gokhan “Networkers” group mount shows mounted filesy-stems Permission changes ownership of a File Commands user file/directory shows file and access changes user and group for a file or -l chown user:group filename permission directory ls -a lists also hidden files r (read) permission, 4 ls -al lists files and directories detailly w () permission, 2 File Permissions shows present directory x (execute) permission, 1 directory creates a directory -= no permission xyz deletes file xyz File Owner owner/group/everyone deletes directory /xyz and its 777 | Owner, Group, Everyone has rm -r /xyz contents recursively rwx permissions forcefully deletes abc file without 744 | Owner has rwx permission, rm -f abc Group, Everyone has r permission confirmation File Permissions Examples forcefully deletes directory /xyz 755 | Owner has rwx permission, rm -rf /xyz recursively Group, Everyone has rx permissions 776 | Owner, Group has rwx aaa bbb copies aaa file to bbb file permission, Everyone has rw cp -r /xxx /yyy copies /xxx directıry to /yyy directory Search Commands renames or moves file aaa to file aaa bbb x file searches for x in file bbb abc creates an empty file named abc grep -i case insens-itive search cat abc used to view file abc grep -r recursive search less abc browse through a text file abc grep -v inverted search abc displays first 10 lines of file abc grep -o shows only matched part of the file abc displays last 10 lines of file abc /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 gpg abc decrypts file abc dir shows files in the current directory uploads file ‘abc’ from local to put abc remote device downloads file ‘abc’ from remote to get file local device LINUX COMMANDS CHEAT SHEET by Gokhan Kosem, www.ipcisco.com ls Options File Transfer Commands secure copy file.txt to the /tmp -a shows all (including hidden) scp file.txt server:/tmp folder on server scp server:/var/www/*.html secure copy *.html files in -R recursive list /tmp /var/www/ directory on server to secure copy all files and directories -r reverse order scp -r server:/var/www /tmp recursively from server to the -t by last modified rsync -a /home /backups/ synchronize /home to /backups/ rsync -avz /home Synchronize files/directories -S sort by file size server:/backups/ between the local and remote -l long listing format Disk Usage Commands shows free hard disk space on the -1 one file per line system shows free and used space on -m comma--sep-arated output df -h mounted filesystems shows free and used inodes on -Q quoted output df -i mounted filesystems shows free and used inodes on Process Management Commands fdisk -l mounted filesystems shows total disk usage off the displays currently running processes -sh current directory gives the status of a particular shows disk usage for all files and ps PID du -ah process directories in readable format pidof gives the process ID of a process free shows free RAM on the system displays all running processes on the ps -ef free -h shows free and used memory system shows target mount point for all ps -ef | grep xyz displays process information for xyz findmnt filesystem displays and manages the top mount /xyz /abc mounts a device in /xyz to /abc processes interactive process viewer (top Compress and Decompress Commands alternative) pid kills process with process ID of pid gzip abc compresses abc file using gzip. 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 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 Search Commands tar czf archive.tar.gz creates a gzip compressed tar file 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 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 to check network connections lspci -tv displays PCI devices 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 sftp secured file transfer gives detailed information about the ss sockets ssh used for secure connection tshark analyzing and capturing tcpdump used for analyzing and capturing used for classical unsecure telnet connection tshark used for packet analyze tracepath used for path tracking traceroute used for path tracking used to check the current system w activity used to download the content of the wget web servers checks the whois database and whois return with IP and Domain info