Linux GoodToKnow#Basics#Utilities#Tools
Linux GoodToKnow#Basics#Utilities#Tools
Linux GoodToKnow#Basics#Utilities#Tools
To print system information
Displays the username tied to the Linux Directory Structure and File To list the open files associated with your cat (“concatenate“) command is used to create/view
uname kernel-name, nodename, kernel- uname -a whoami lsof cat/zcat
current effective user ID. System Hierarchy application files and redirect output in terminal or files
release, kernel-version, etc…
To view text files in a scrollable manner,pauses after
To find Linux Standard Base (LSB) dpkg is a package manager for
lsb_release lsb_release -a dpkg fsck Check and repair a Linux file system more/zmore each screenful, printing. zmore works on compressed
information Debian-based systems / This is the root directory files
APT(Advanced Package Tool) is a /bin The binary executable files are grep - global regular expression print. Used for pattern
du disk usage is a standard Unix utility used to grep/zgrep
command line tool that is used for located search in text content line by line. zgrep works on
To List Hardware apt estimate file space
easy interaction with the dpkg /sbin Contains system binary executable compressed files
du -h /var/tmp “-h” option for “Human Readable Format“ grep -n “word*” file.txt
packaging system -- To display line numbers
files
df
apt-get is the command-line tool for /dev This holds device drivers display free disk space Same as grep; supports case-insensitive search on
lspci To list all PCI devices lspci | egrep -i 'network|ethernet' apt-get egrep
working with APT software packages /lib Contains shared library files “-h” option for “Human Readable Format“ multiple regular expressions
/boot Contains files for booting the system df -h
apt-cache is another command line
egrep [JNR] test.txt Search for Specific Characters
To extract detailed information on lshw -class network tool which helps you search the To list how long your system is running and the
lshw apt-cache /home Contains users home directory uptime egrep [5-9] test.txt Search for a Range
the hardware configuration lshw -class disk available packages for your Debian number of users are currently logged in
/mnt Used to mount other temporary file egrep 'in|out' test.txt egrep OR Example
system
systems
Free command shows free, total and swap
dmidecode -t system Show the status of modules in the /proc Contains all processes marked as a free -b , free -k free - find
dmidecode To list all hardware data from BIOS lsmod memory information in bytes, Kilo Bytes,
dmidecode -t processor Linux kernel. file by process number m, free -g Command line utility for walking a file hierarchy
Megabytes, Gigabytes
/tmp Contains temporary files
Displays user name, date, time and host find . -name rsi.txt
Network configuration utilities date Show system date and time. /usr Used for miscellaneous purposes who Tofind files using name in the Current Directory
information
/var In general contains variable-length find / -type d -name rsi.txt To find directories using name
files such as log and print files fdisk fdisk is the best utility to manage disk find . -type f -perm 0777 -print To find files with 777 permissions
To view all interfaces configuration ifconfig -a /kernel Contains kernel files partitions. find / -user rengar To find all files based on user
Show or configure the system’s
ifconfig To configure an interface ifconfig eth0 172.16.25.125 hwclock /etc Supervisor directory commands, fdisk -l To view all Disk Partitions in Linux find / -mtime 10 To find all the files modified 10 days back
hardware clock.
Enabe/Disable an interface ifconfig eth0 up/down config files, disk configuration files fdisk -l /dev/sda1 To view specific Disk Partitions in Linux find / -cmin -60 To find Files changed in the Last Hour
fdisk /dev/sda To view all fdisk Commands [select m] find . -size +500M -size -1000M To find files with Size between 500MB – 1000MB
netstat -a
List All Ports tar To rip a collection of files and directories into highly
curl is a tool to transfer data from or to a compressed archive file [tar,gzip and bzip]
netstat -at To open TCP connection to port 45 of 192.168.1.1, using
List all tcp ports nc -p 31557 -w 10 192.168.1.1 45 server, using one of the supported protocols tar cvf archive.tar dirname/ To create a new archive using tar command
netstat netstat -l port 31552 as the source port, with a timeout of 10 curl
List Sockets which are in Listening (HTTP, HTTPS, FTP, FTPS, SCP, SFTP, tar cvzf archive.tar.gz dirname/ To create a tar gzipped archive using option cvzf
seconds.
State TFTP, DICT, TELNET, LDAP or FILE). tar xvf archive.tar
To show statistics for each protocol netstat -s To extract an archive using tar command
tar xvfz archive.tar.gz
gunzip file.gz
vmstat(View memory status) is a memory measurement tool mpstat - Report processors related statistics sudo Execute a command as superuser. To extract files ending in .gzip or .gz
gzip -d file.gz
To extract a rar archive to the current working
To list Active and Inactive Memory [in kilobytes] vmstat -a ethtool eth0 List Ethernet Device Properties unrar directory,
To display statistics about all CPUs unrar e filename.rar
mpstat -P ALL 2 5
The chmod command changes the access mode of
Display Network Statistics of Specific Ethernet
To list Active and Inactive Memory [in Megabytes] vmstat -S M P -Processor Number, ALL - all processors ethtool -S eth0 chmod one file or multiple files.
Device
chmod [option] mode files
To execute vmstat every four seconds and stop vmstat <interval> <iterartions> Identify Specific Device From Multiple Devices gcore - get core images of running process
To display interrupts received by CPUs mpstat -I ALL ethtool -p eth0 gcore
automatically after executing fifth interval vmstat 4 5 (Blink LED Port of NIC Card) gcore [-f] [-s] [-c core] [executable] pid
To compare files line by line,
To display statistics in a table format vmstat -s To display CPU utilization and interrupt statistics mpstat -A groups Show the group(s) to which a user belongs. diff
diff file1.txt file2.txt
The vi editor is the most popular and classic text editor
To display all disks statistics vmstat -d mpstat <interval> <iterartions> sysctl Configure kernel parameters at runtime. vi
To display mpstat output for every 2 seconds in the Linux family
and stop automatically after executing fifth interval Utility used to suppress or count the duplicate nano is a popular command line text editor that is
To display number of forks since last boot vmstat -f mpstat 2 5 uniq nano
lines from a file included in most Linux distributions
tcpdump
ps (processes status) The mount command serves to attach the filesystem
iostat reports CPU, disk I/O statistics Packets sniffer and analyzer tool which can be used to capture and filter packets received or mount
To display about processes running in the system found on some device to the file tree.
transferred over a specific interface
To display every active process on a Linux The umount command detaches the file system(s)
To display CPU, disk I/O statistics iostat To capture Packets from Specific Interface tcpdump -i eth0 ps -A or ps -e umount
system in generic (Unix/Linux) format mentioned from the file hierarchy.
To display only disk I/O statistics iostat -d To display Available Interfaces tcpdump -D To display Parent and Child Processes su To switch from one account to another
To display with timestamp information iostat -t To display Captured Packets in HEX and ASCII tcpdump -XX -i eth0 ps -eo comm,etime,user | grep httpd history Shows the command history.
To display extended disk I/O statistics information iostat -x To capture and Save Packets in a File tcpdump -w capture.pcap -i eth0 To identify top running processes by highest memory and CPU usage ls To list directory contents
To display iostat output for every 5 seconds
iostat 5 To read captured packets File [.pcap] tcpdump -r capture.pcap head To display the beginning of a text file or piped data
(use Ctl-C to break)
To display iostat output for every 2 seconds iostat <interval> <iterartions> ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head Tail is an utility to print the last few number of lines (10
To capture only TCP Packets tcpdump -i eth0 tcp tail
and stop automatically after executing fifth interval iostat 2 5 ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head lines by default) of a specified file
Document Version: V.2.9-18_11 Please email [email protected] for any clarifications/correction This is a Quick Reference Sheet for Linux GoodToKnow#basics#Utilities#Tools