Linux common commands,Tips: Ctrl + F to quickly find Linux commands (click the title to shrink and expand)
command code | comment description |
---|---|
Arch | Display the processor architecture of the machine (1) |
Uname -m | Display the processor architecture of the machine (2) |
Uname -r | Display the kernel version in use |
Dmidecode -q | Display Hardware System Components - (SMBIOS/DMI) |
HDPARM -i /dev/hda | List the architectural characteristics of a disk |
HDPARM -tT /dev/sda | Perform a test read operation on disk |
Cat /proc/cpuinfo | Display CPU info |
Cat /proc/interrupts | Display interrupt |
Cat /proc/meminfo | check memory usage |
Cat /proc/swaps | Shows which swaps are being used |
Cat /proc/version | Show the version of the kernel |
Cat /proc/net/dev | Display network adapters and statistics |
Cat /proc/mounts | Show the loaded file system |
LSPCI -TV | List PCI devices |
LSUSB -TV | Display USB devices |
Date | Display system date |
Cal 2007 | Show the calendar for 2007 |
Date 04121700 2007.00 | Set date and time - month, day, hour, year. seconds |
Clock -w | Save time changes to BIOS |
command code | comment description |
---|---|
Shutdown -h now | Shut down the system |
Init 0 | Shut down the system |
Telinit 0 | Shut down the system |
Shutdown -h hours: minutes & | Shut down the system at the scheduled time |
Shutdown -c | Cancel to shut down the system at the scheduled time |
Shutdown -r now | restart |
Reboot | restart |
Logout | cancellation |
command code | comment description |
---|---|
CD /home | Go to the '/home' directory. |
CD.. | Return to the previous level of directory |
CD../.. | Return to the previous two levels of directory |
CD | Enter the personal home directory |
Cd~ user1 | Enter the personal home directory |
CD - | Return to the directory where you were last time |
PWD | Show work path |
ls | View files in the directory |
LS -F | View files in the directory |
LS -l | Display file and directory details |
Ls -a | Show hidden files |
Ls * [0-9] * | Display file and directory names containing numbers |
Tree | Displays the tree structure of files and directories starting from the root directory |
LSTREE | Displays the tree structure of files and directories starting from the root directory |
Mkdir dir1 | Create a directory called'dir1 '. |
Mkdir dir1 dir2 | Create two directories simultaneously |
Mkdir -p /tmp/dir1/dir2 | Create a directory tree |
Rm -f file1 | Delete a file called'file1 '. |
Rmdir dir1 | Delete a directory called'dir1 '. |
Rm -rf dir1 | Delete a directory called'dir1 'and delete its contents simultaneously |
Rm -rf dir1 dir2 | Delete both directories and their contents simultaneously |
MV dir1 new_dir | Rename/move a directory |
CP file1 file2 | Copy a file |
CP dir/*. | Copy all files in a directory to the current working directory |
CP -A /tmp/dir1. | Copy a directory to the current working directory |
CP -a dir1 dir2 | Copy a directory |
-S file1 lnk1 | Create a soft link to a file or directory |
Ln file1 lnk1 | Create a physical link to a file or directory |
Touch -t 0712250000 file1 | Modify the timestamp of a file or directory - (YYMMDDhhmm) |
IconV -l | List the known codes |
iconv -f fromEncoding -t toEncoding inputFile > outputFile | Change the encoding of characters |
Find. -maxdepth 1 -name * .jpg -print -exec convert | Batch resizing files in the current directory and send them to the thumbnail directory (requires conversion from ImageMagick) |
command code | comment description |
---|---|
Find/-name file1 | Start with '/' to enter the root file system to search for files and directories |
Find/-user user1 | Search for files and directories belonging to user'user1 ' |
Find /home/user1 -name * .bin | Search the directory '/home/user1' for files ending in '.bin' |
Find /usr/bin -type f -atime + 100 | Search for executable files that have not been used in the past 100 days |
Find /usr/bin -type f -mtime -10 | Search for files that have been created or modified within 10 days |
Find/-name * .rpm -exec chmod 755 '{}' ; | Search for files ending in '.rpm' and define their permissions |
Find/-xdev -name * .rpm | Search for files ending in '.rpm', ignoring removable devices such as optical drives and flash drives |
Locate * .ps | Find files ending in '.ps' - run the'updatedb 'command first |
Whereis halt | Display the location of a binary, source, or man |
Which halts | Displays the full path to a binary or executable file |
command code | comment description |
---|---|
Mount /dev/hda2 /mnt/hda2 | Mount a disk called hda2 - make sure the directory '/mnt/hda2' already exists |
Umount /dev/hda2 | Unmount a disk called hda2 - exit from the mount point '/mnt/hda2' first |
Fuser -km /mnt/hda2 | Forced uninstallation when the device is busy |
Umount -n /mnt/hda2 | Running uninstall operations without writing /etc/mtab file useful when the file is read-only or when the disk is full |
Mount /dev/fd0 /mnt/floppy | Mount a floppy disk |
Mount /dev/cdrom /mnt/cdrom | Mount a cdrom or dvdrom |
Mount /dev/hdc /mnt/cdrecorder | Mount a cdrw or dvdrom |
Mount /dev/hdb /mnt/cdrecorder | Mount a cdrw or dvdrom |
Mount -o loop file.iso /mnt/cdrom | Mount a file or ISO image |
Mount -t vfat /dev/hda5 /mnt/hda5 | Mount a Windows FAT32 file system |
Mount /dev/sda1 /mnt/usbdisk | Mount a USB drive or flash device |
Mount -t smbfs -o username = user, password = pass//WinClient/share /mnt/share | Mount a windows network share |
command code | comment description |
---|---|
DF -h | Show a list of mounted partitions |
LS -lSr | more | Sort files and directories by size |
Du -sh dir1 | Estimate the disk space already used by the directory'dir1' |
Du -sk * | sort -rn | Displays the size of files and directories in sequence according to capacity |
Rpm -q -a --qf '% 10 {SIZE} t% {NAME} n' | sort -k1,1n | Displays the space used by installed rpm packages in order of size (fedora, redhat class system) |
Dpkg-query -W -f = '${Installed-Size; 10} t ${Package} n' | sort -k1,1n | Displays the space used by installed deb packages based on size (ubuntu, debian class system) |
command code | comment description |
---|---|
GroupAdd group_name | Create a new user group |
Groupdel group_name | Delete a user group |
Groupmod -n new_group_name old_group_name | Rename a user group |
Useradd -c "Name Surname" -g admin -d /home/user1 -s /bin/bash user1 | Create a user that belongs to the "admin" user group |
UserAdd user1 | Create a new user |
Userdel -r user1 | Delete a user ('-r' excludes home directory) |
Usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 | Modify user properties |
Passwd | Change password |
Passwd user1 | Modify a user's password (only allows root execution) |
Chage -E 2020-12-31 user1 | Set the expiration date for user passwords |
PWCK | Check for file format and syntax fixes for '/etc/passwd' and the existence of users |
GRPCK | Check for file format and syntax fixes for '/etc/passwd' and existing groups |
Newgrp group_name | Log in to a new group to change the default group for newly created files |
command code | comment description |
---|---|
LS -lh | display permission |
LS /tmp | pr -T5 -W $COLUMNS | Divide the end point into 5 columns to display |
Chmod ugo + rwx directory1 | Set permissions for the owner (u), group (g), and others (o) of the directory to read (r), write (w), and execute (x) |
Chmod go-rwx directory1 | Delete group (g) and others (o) read and write execution permissions to directories |
Chown user1 file1 | Change the owner attributes of a file |
Chown -R user1 directory1 | Change the owner attributes of a directory and simultaneously change the attributes of all files in the directory |
CHGRP group1 file1 | Change the group of files |
Chown user1: group1 file1 | Change the owner and group attributes of a file |
Find/-perm -u + s | List all files in a system that use SUID control |
Chmod u + s /bin/file1 | Set the SUID bit of a binary file - the user running the file is also given the same permissions as the owner |
CHMOD U-S /bin/file1 | Disable the SUID bit of a binary file |
Chmod g + s /home/public | Set the SGID bit of a directory - similar to SUID, but for directories |
CHMOD G-S /home/public | Disable the SGID bit of a directory |
Chmod o + t /home/public | Set the STIKY bit of a file - only allows the legal owner to delete the file |
CHMOD O-T /home/public | Disable the STIKY bit of a directory |
command code | comment description |
---|---|
Chattr + a file1 | Only read and write files in append mode are allowed |
Chattr + c file1 | Allows this file to be automatically compressed/decompressed by the kernel |
Chattr + d file1 | The dump program will ignore this file when backing up the file system |
Chattr + i file1 | Set to immutable files that cannot be deleted, modified, renamed, or linked |
Chattr + s file1 | Allows a file to be safely deleted |
Chattr + S file1 | Once the application performs a write operation on this file, the system immediately writes the modified results to disk |
Chattr + u file1 | If the file is deleted, the system will allow you to recover the deleted file later |
Lsattr | Show special properties |
command code | comment description |
---|---|
Bunzip2 file1.bz2 | Unzip a file called'file1.bz2 ' |
Bzip2 file1 | Compress a file called'file1 ' |
Gunzip file1.gz | Unzip a file called'file1.gz' |
Gzip file1 | Compress a file called'file1 ' |
Gzip -9 file1 | maximum compression |
Rar a file1.rar test_file | Create a package called'file1.rar ' |
Rar a file1.rar file1 file2 dir1 | Simultaneously compress'file1 ',' file2 'and directory'dir1' |
Rar x file1.rar | Unzip the rar package |
Unrar x file1.rar | Unzip the rar package |
Tar -cvf archive.tar file1 | Create an uncompressed tarball |
Tar -cvf archive.tar file1 file2 dir1 | Create an archive containing'file1 ',' file2 'and'dir1' |
Tar -tf archive.tar | Display the content of a package |
Tar -xvf archive.tar | Release a package |
Tar -xvf archive.tar -C /tmp | Release the compressed package to the /tmp directory |
Tar -cvfj archive.tar.bz2 dir1 | Create a compressed package in bzip2 format |
Tar -jxvf archive.tar.bz2 | Unzip a compressed package in bzip2 format |
Tar -cvfz archive.tar.gz dir1 | Create a compressed package in gzip format |
Tar -zxvf archive.tar.gz | Unzip a compressed package in gzip format |
Zip file1.zip file1 | Create a zip file |
Zip -r file1.zip file1 file2 dir1 | Compress several files and directories simultaneously into a zip file |
Unzip file1.zip | Unzip a zip file |
command code | comment description |
---|---|
Rpm -ivh package.rpm | Install an rpm package |
Rpm -ivh --nodeeps package.rpm | Installing an rpm package while ignoring dependency warnings |
rpm -U package.rpm | Update an RPM package without changing its configuration file |
Rpm -F package.rpm | Update a confirmed installed rpm package |
Rpm -e package_name rpm | Delete an RPM package |
RPM -QA | Display all installed rpm packages in the system |
Rpm -qa | grep htpd | Display all rpm packages with the word "htpd" in their name |
RPM -Qi package_name | Get special information about an installed package |
RPM -qg "System Environments/Daemons" | Display the rpm package of a component |
RPM -QL package_name | Displays a list of files provided by an installed rpm package |
RPM -QC package_name | Displays a list of configuration files provided by an installed rpm package |
RPM -Q package_name --WhatRequires | Displays a list of dependencies with an rpm package |
RPM -q package_name --WhatProvides | Shows the volume of an rpm package |
Rpm -q package_name --scripts | Show scripts executed during installation/removal |
RPM -Q package_name --Changelog | Display the modification history of an RPM package |
RPM -QF /etc/httpd/conf/httpd.conf | Verify which rpm package provided the given file |
Rpm -qp package.rpm -l | Show a list of files provided by an uninstalled rpm package |
RPM --import /media/cdrom/RPM-GPG-KEY | Import Public Key Digital Certificate |
Rpm --checksig package.rpm | Verify the integrity of an RPM package |
Rpm -qa gpg-pubkey | Verify the integrity of all installed rpm packages |
RPM -V package_name | Check file size, license, type, owner, group, MD5 check, and last modified |
RPM -Va | Check all installed rpm packages in the system - use with caution |
Rpm -Vp package.rpm | Confirm that an rpm package has not been installed |
Rpm2cpio package.rpm | cpio --extract --make-directories * bin * | Running an executable from an rpm package |
Rpm -ivh /usr/src/redhat/RPMS/arch/package.rpm | Install a built package from an rpm source |
RPMbuild --rebuild package_name src.rpm | Build an RPM package from an RPM source |
command code | comment description |
---|---|
Yum install package_name | Download and install an RPM package |
Yum localinstall package_name | An rpm package will be installed, using your own software repository to resolve all dependencies for you |
Yum update package_name | Update all installed rpm packages in the current system |
Yum update package_name | Update an rpm package |
Yum remove package_name | Delete an RPM package |
Yum list | List all packages installed in the current system |
Yum search package_name | Search for packages in the rpm repository |
Yum cleaning packages | Clean the rpm cache and delete downloaded packages |
Yum cleaning headers | Delete all header files |
Yum clean all | Delete all cached packages and header files |
command code | comment description |
---|---|
Dpkg -i package.deb | Install/update a deb package |
Dpkg -r package_name | Delete a deb package from the system |
Dpkg -l | Display all installed deb packages in the system |
Dpkg -l | grep htpd | Display all deb packages with the word "htpd" in their name |
Dpkg -s package_name | Obtain information about a special package that has been installed in the system |
DPKG -L package_name | Displays a list of files provided by a deb package already installed on the system |
Dpkg --contents package.deb | Displays a list of files provided by a package that has not yet been installed |
DPKG -S /bin/ping | Verify which deb package provided the given file |
command code | comment description |
---|---|
Apt-get install package_name | Install/update a deb package |
Apt-cdrom install package_name | Install/update a deb package from CD |
Apt-get update | Upgrade packages in the list |
Apt-get upgrade | Upgrade all installed software |
Apt-get remove package_name | Delete a deb package from the system |
Apt-get check | Verify that the dependent software repository is correct |
Apt get clean | Clean the cache from the downloaded package |
Apt-cache search searched-package | Returns the package name containing the search string |
command code | comment description |
---|---|
Cat file1 | Forward view of file contents from the first byte |
Tac file1 | Review the contents of a file backwards from the last line |
More file1 | View the content of a long file |
Less file1 | Similar to the'more 'command, but it allows reverse operations in the file as well as forward operations |
Head -2 file1 | Examine the first two lines of a document |
Tail -2 file1 | Examine the last two lines of a file |
Tail -f /var/log/messages | View content added to a file in real time |
command code | comment description |
---|---|
Cat file1 | command (sed, grep, awk, grep, etc...) > result.txt | Merge the detailed description text of a file and write the introduction to a new file |
Cat file1 | command (sed, grep, awk, grep, etc...) > > result.txt | Merge the detailed description text of a file and write the introduction to an existing file |
Grep Aug /var/log/messages | Look for the keyword "Aug" in the file '/var/log/messages' |
Grep ^ Aug /var/log/messages | Look for words starting with "Aug" in the file '/var/log/messages' |
Grep [0-9] /var/log/messages | Select all lines containing numbers in the '/var/log/messages' file |
Grep Aug -R /var/log/* | Search for string "Aug" in directory '/var/log' and subsequent directories |
Sed's/stringa1/stringa2/g'example.txt | Replace "string1" in the example.txt file with "string2" |
Sed '/^ $/d' example.txt | Remove all blank lines from the example.txt file |
Se d '/ *#/ d;/^ $/d'example.txt from example.txt | Remove all comments and blank lines from the file |
Echo'esempio '| tr' [: lower :]' '[: upper:] ' | Merge upper and lower cell contents |
Sed -e '1d' result.txt | Exclude the first line from the file example.txt |
Sed -n '/stringa1/p' | View lines containing only the word "string1" |
Sed -e's / *$//' example.txt | Delete the whitespace at the end of each line |
Sed -e's/stringa1/g'example.txt | Delete only the word "string1" from the document and keep all the rest |
Sed -n '1,5p; 5q' example.txt | Review the content from the first line to the fifth line |
Sed -n '5p; 5q' example.txt | Check line 5 |
Sed -e's/00 */0/g'example.txt | Replace multiple zeros with a single zero |
Cat -n file1 | Identify the number of lines in the file |
Cat example.txt | awk'NR% 2 == 1 ' | Delete all even-numbered lines in the example.txt file |
Echo a b c | awk '{print 1 dollar}' | Look at the first column of a line |
Echo a b c | awk '{print 1 dollar, 3 dollars}' | Check the first and third columns of a row |
Paste file1 file2 | Merge the contents of two files or columns |
Paste -d '+' file1 file2 | Merge the contents of two files or columns, distinguished by "+" in the middle |
Sort file1 file2 | Sort the contents of two files |
Sort file1 file2 | uniq | Remove the union of two files (only one copy of duplicate lines is kept) |
Sort file1 file2 | uniq -u | Delete the intersection, leaving other lines |
Sort file1 file2 | uniq -d | Remove the intersection of two files (leaving only files that exist in both files simultaneously) |
Comm -1 file1 file2 | Comparing the contents of two files removes only the content contained in'file1 ' |
Comm -2 file1 file2 | Comparing the contents of two files removes only the content contained in'file2 ' |
Comm -3 file1 file2 | Compare the contents of two files to delete only the parts common to both files |
command code | comment description |
---|---|
Dos2unix filedos.txt fileunix.txt | Convert a text file format from MSDOS to UNIX |
Unix2dos fileunix.txt filedos.txt | Convert a text file format from UNIX to MSDOS |
Recode.. HTML < page.txt > Page.html | Convert a text file to HTML. |
Recode -l | more | Show all allowed conversion formats |
command code | comment description |
---|---|
Badblocks -v /dev/hda1 | Check for bad magnets on disk hda1 |
FSCK /dev/hda1 | Repair/check the integrity of the Linux file system on the HDA1 disk |
Fsck.ext2 /dev/hda1 | Repair/check the integrity of the ext2 file system on the hda1 disk |
E2FSCK /dev/hda1 | Repair/check the integrity of the ext2 file system on the hda1 disk |
E2fsck -j /dev/hda1 | Repair/check the integrity of the ext3 file system on the hda1 disk |
Fsck.ext3 /dev/hda1 | Repair/check the integrity of the ext3 file system on the hda1 disk |
Fsck.vfat /dev/hda1 | Repair/check the integrity of the fat file system on the hda1 disk |
Fsck.msdos /dev/hda1 | Repair/check the integrity of the DOS file system on the HDA1 disk |
Dosfsck /dev/hda1 | Repair/check the integrity of the DOS file system on the HDA1 disk |
command code | comment description |
---|---|
MKFS /dev/hda1 | Create a file system in the HDA1 partition |
MKE2FS /dev/hda1 | Create a linux ext2 filesystem in the hda1 partition |
MKE2FS -J /dev/hda1 | Create a linux ext3 (journaling) filesystem in the hda1 partition |
MKFS -T vfat 32 -F /dev/hda1 | Create a FAT32 file system |
Fdformat -n /dev/fd0 | Format a floppy disk |
MKSwap /dev/hda3 | Create a swap file system |
command code | comment description |
---|---|
MKSwap /dev/hda3 | Create a swap file system |
Swapon /dev/hda3 | Enable a new swap file system |
Swapon /dev/hda2 /dev/hdb3 | Enable two swap partitions |
command code | comment description |
---|---|
Dump -0aj -f /tmp/home0.bak /home | Make a complete backup of the '/home' directory |
Dump -1aj -f /tmp/home0.bak /home | Make an interactive backup of the '/home' directory |
Restore -if /tmp/home0.bak | Restore an interactive backup |
Rsync -rogpav --delete /home /tmp | Sync directories on both sides |
Rsync -rogpav -e ssh --delete /home ip_address:/tmp | Via SSH channel rsync |
Rsync -az -e ssh --delete ip_addr:/home/public /home/local | Synchronize a remote directory to a local directory via ssh and compression |
Rsync -az -e ssh --delete /home/local ip_addr:/home/public | Synchronize local directories to remote directories via ssh and compression |
Dd bs = 1M if =/dev/hda | gzip | ssh user@ip _addr 'dd of = hda.gz' | Perform a backup of the local disk on a remote host via ssh |
Dd if =/dev/sda of =/tmp/file1 | Backup disk contents to a file |
Tar -Puf backup.tar /home/user | Perform an interactive backup of the '/home/user' directory |
(Cd /tmp/local/& tar c . ) | ssh -C user@ip _addr 'cd /home/share/& & tar x -p' | Copy the contents of a directory in a remote directory via ssh |
(Tar c /home) | ssh -C user@ip _addr 'cd /home/backup-home & & tar x -p' | Copy a local directory in a remote directory via ssh |
Tar cf - . | ( cd /tmp/backup; tar xf -) | Copy a directory locally to another place, retaining the original permissions and links |
Find /home/user1 -name '* .txt' | xargs cp -av --target-directory =/home/backup/--parents | Find and copy all files ending in '.txt' from one directory to another |
Find /var/log -name '* .log' | tar cv --files-from = - | bzip2 > log.tar.bz2 | Find all files ending in '.log' and make a bzip package |
Dd if =/dev/hda of =/dev/fd0 bs = 512 count = 1 | Do an action to copy the MBR (Master Boot Record) content to a floppy disk |
Dd if =/dev/fd0 of =/dev/hda bs = 512 count = 1 | Restore MBR content from a backup that has been saved to a floppy disk |
command code | comment description |
---|---|
CDRecord -v gracetime = 2 dev =/dev/cdrom -eject blank = fast -force | Empty the contents of a rewritable disc |
Mkisofs /dev/cdrom > cd.iso | Create an ISO image of a disc on disk |
Mkisofs /dev/cdrom | gzip > cd_iso | Create a compressed disc iso image file on disk |
MKISOFS -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o./cd.iso data_cd | Create an ISO image of a directory |
Cdrecord -v dev =/dev/cdrom cd.iso | Burn an ISO image file |
Gzip -dc cd_iso | cdrecord dev =/dev/cdrom - | Burn a compressed ISO image file |
Mount -o loop cd.iso /mnt/iso | Mount an ISO image file |
cd-paranoia -B | Transcribe audio tracks from a CD to a wav file |
CD-paranoia -- "-3" | Transcribe audio tracks from a CD to a wav file (argument -3) |
CDRecord --scanbus | Scan bus to identify scsi channel |
Dd if =/dev/hdc | md5sum | Verify the MD5sum encoding of a device, such as a CD |
command code | comment description |
---|---|
Dhclient eth01 | Enable'eth0 'network device in dhcp mode |
Ethtool eth01 | Display the traffic statistics of the network interface card'eth0 ' |
Host www.example.com | Find Hostname to Resolve Name and Internet Protocol Address and Mirror |
Hostname | Show hostname |
Ifconfig eth0 | Displays the configuration of an Ethernet network interface card |
Ifconfig eth0 192.168.1.1 netmask 255.255.255.0 | Control Internet Protocol Addresses |
Ifconfig eth0 promisc | Set'eth0 'to promiscuous mode to sniff data packets |
Ifdown eth01 | Disable an'eth0 'network device |
Ifup eth01 | Enable an'eth0 'network device |
IP link show | Display the connection status of all network devices |
Iwconfig eth1 | Displays the configuration of a wireless network interface card |
IWList scan | Show wireless network |
mii-tool eth01 | Show the connection status of'eth0 ' |
Netstat -Tup | Display all enabled network connections and their PIDs |
Netstat -tup1 | Display all network services in the system and their PIDs |
Netstat -rn | Display the routing table, similar to the "route -n" command |
Nslookup www.example.com | Find Hostname to Resolve Name and Internet Protocol Address and Mirror |
Route -n | Show routing table |
Route added -net 0/0 gw IP Gateway | Control Preset Gateway |
Route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 | Controlling static routes to network '192.168.0.0/16 ' |
Route del 0/0 gw IP gateway | Delete static route |
Echo "1" > /proc/sys/net/ipv4/ip_foward | Activate IP forwarding |
Tcpdump tcp port 80 | Show all HTTP loops |
Whois www.example.com | Search in the Whois database |
command code | comment description |
---|---|
Mount -t smbfs -o Username = user, password = pass //WinClient/share/mnt/share | Mount a windows network share |
Nbtscan ip addr | Netbios name resolution |
Nmblookup -A ip addr | Netbios name resolution |
smbclient -L ip addr/hostname | Display a remote share of a Windows host |
smbget -Rr smb://ip addr/share | Ability to download files from a windows host via smb like wget |
command code | comment description |
---|---|
Iptables -t filter -L | Show all links to the filter table |
Iptables -t nae -L | Show all links to the NAT table |
Iptables -t filter -F | Clean up all rules based on the filter table |
Iptables -t nat -F | Clean up all rules based on the nat table |
Iptables -t filter -X | Delete all user-created links |
IPTables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT | Allow telnet access |
IPTables -t filter -A OUTPUT -p tcp --dport telnet -j DROP | Block telnet access |
Iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT | Allow POP3 connections on the forwarding link |
Iptables -t filter -A INPUT -j LOG --log-prefix | Record packets seized in all links |
Iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | Set up a PAT (Port Address Translation) to mask outgoing packets in eth0 |
Iptables -t nat -A POSTROUTING -d 192.168.0.1 -p tcp -m tcp --dport 22-j DNAT --to-destination 10.0.0.2:22 | Forward packets destined for one host address to another host |
command code | comment description |
---|---|
Free -m | List RAM status in megabytes |
Kill -9 process id | Forcibly close the process and end it |
Kill -1 process id | Force a process to overload its configuration |
Last reboot | Show restart history |
lsmod | kernel module for listing states |
Lsof -p process id | List of files opened by the process |
LSOF /home/user1 | List of open files in the given system path |
PS -eafw | List linux tasks |
Ps -e -o pid, args --forest | List Linux tasks in a hierarchical manner |
PSTRESS | Display the program as a tree diagram |
SmartCTL -A /dev/hda | Monitor the reliability of hard disk devices by enabling SMART |
SmartCTL -I /dev/hda | Check if SMART is enabled for a hard disk device |
Strace -c ls >/dev/null | List system calls made and receive with one process |
Strace -f -e open ls >/dev/null | list library call |
Tail /var/log/dmesg | Display internal events during kernel boot |
Tail /val/log/messages | Display system events |
top | List the Linux tasks that use the most CPU resources |
Watch -nl'cat /proc/interrupts ' | List real time interrupts |
command code | comment description |
---|---|
Alias hh = 'history' | Set an alias for command history |
Apropos... keyword | Make a list of commands including program keywords, especially useful when you only know what the program does and don't remember the commands |
CHSH | Change shell command |
CHSH --list-shells | Good command for finding out if you have to connect to another machine remotely |
GPG -C filel | Encrypt a file with GNU Privacy Guard |
Gpg filel.gpg | Decrypt a file with GNU Privacy Guard |