A complete list of commonly used Linux commands,Tips: Ctrl+F Quickly find Linux commands (click the title to shrink and expand)
Command code | Notes |
---|---|
arch | Display the processor architecture of the machine (1) |
uname -m | Display the processor architecture of the machine (2) |
uname -r | Show the kernel version in use |
dmidecode -q | Display hardware system components - (SMBIOS / DMI) |
hdparm -i /dev/hda | List the architectural features of a disk |
hdparm -tT /dev/sda | Perform test read operations on disk |
cat /proc/cpuinfo | Display CPU info information |
cat /proc/interrupts | Display interrupt |
cat /proc/meminfo | Verify memory usage |
cat /proc/swaps | Show which swaps are used |
cat /proc/version | Show the kernel version |
cat /proc/net/dev | Display network adapters and statistics |
cat /proc/mounts | Show loaded file system |
lspci -tv | List PCI devices |
lsusb -tv | Show USB devices |
date | Show system date |
cal 2007 | Show calendar for 2007 |
date 041217002007.00 | Set date and time - month, day, time, year. seconds |
clock -w | Save time modification to BIOS |
Command code | Notes |
---|---|
shutdown -h now | Turn off the system |
init 0 | Turn off the system |
telinit 0 | Turn off the system |
shutdown -h hours:minutes & | Turn off the system at the scheduled time |
shutdown -c | Cancel shut down the system at the scheduled time |
shutdown -r now | Restart |
reboot | Restart |
logout | Log out |
Command code | Notes |
---|---|
cd /home | Go to the '/home' directory' |
cd .. | Return to the previous directory |
cd ../.. | Return to the previous two-level directory |
cd | Enter your personal home directory |
cd ~user1 | Enter your personal home directory |
cd - | Return to the directory you were in the last time |
pwd | Show work path |
ls | View files in the directory |
ls -F | View files in the directory |
ls -l | Display detailed information of files and directories |
ls -a | Show hidden files |
ls *[0-9]* | Show file names 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 at the same time |
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 at the same time |
rm -rf dir1 dir2 | Delete two directories and their contents at the same time |
mv dir1 new_dir | Rename/move a directory |
cp file1 file2 | Copy a file |
cp dir/* . | Copy all files in one 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 |
ln -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 known encodings |
iconv -f fromEncoding -t toEncoding inputFile > outputFile | Change the encoding of characters |
find . -maxdepth 1 -name *.jpg -print -exec convert | Batch resize the file in the current directory and send it to the thumbnail directory (need to be converted from ImageMagick) |
Command code | Notes |
---|---|
find / -name file1 | Starting from '/', 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 for a file ending with '.bin' in directory '/home/user1' |
find /usr/bin -type f -atime +100 | Search for execution 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 with '.rpm' and define their permissions |
find / -xdev -name \*.rpm | Search for files ending with '.rpm', ignoring removable devices such as optical drives and shortcuts |
locate \*.ps | Looking for files ending with '.ps' - Run the 'updatedb' command first |
whereis halt | Displays the location of a binary file, source code, or man |
which halt | Shows the full path to a binary or executable file |
Command code | Notes |
---|---|
mount /dev/hda2 /mnt/hda2 | Mount a disk called hda2 - Confirm the directory '/mnt/hda2' already exists |
umount /dev/hda2 | Uninstall a disk called hda2 - Exit from the mount point '/mnt/hda2' |
fuser -km /mnt/hda2 | Forced uninstall when the device is busy |
umount -n /mnt/hda2 | Run the uninstall operation without writing to the /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 file |
mount -t vfat /dev/hda5 /mnt/hda5 | Mount a Windows FAT32 file system |
mount /dev/sda1 /mnt/usbdisk | Mount a usb shortcut or flash device |
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share | Mount a Windows network share |
Command code | Notes |
---|---|
df -h | Shows the mounted partition list |
ls -lSr |more | Arrange files and directories by size |
du -sh dir1 | Estimate the disk space already used by directory 'dir1' |
du -sk * | sort -rn | Display the size of files and directories in sequence based on capacity size |
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n | Display the space used by installed rpm packages in sequence based on size (fedora, redhat class system) |
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n | Display the space used by the installed deb package based on size (ubuntu, debian system) |
Command code | Notes |
---|---|
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 belonging to the "admin" user group |
useradd user1 | Create a new user |
userdel -r user1 | Delete a user ('-r' exclude home directory) |
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 | Modify user attributes |
passwd | Modify password |
passwd user1 | Modify a user's password (only root is allowed to execute) |
chage -E 2020-12-31 user1 | Set the expiration period of user password |
pwck | Check the file format and syntax correction of '/etc/passwd' and the existing users |
grpck | Check the file format and syntax corrections of '/etc/passwd' and the existing groups |
newgrp group_name | Log in to a new group to change the preset group of newly created files |
Command code | Notes |
---|---|
ls -lh | Show permissions |
ls /tmp | pr -T5 -W$COLUMNS | Divide the terminal into 5 columns to display |
chmod ugo+rwx directory1 | Set permissions for everyone (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 properties of a file |
chown -R user1 directory1 | Change the properties of all files in a directory and change the properties of all files in the directory at the same time |
chgrp group1 file1 | Change the group of files |
chown user1:group1 file1 | Change the owner and group properties 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 this is for the directory |
chmod g-s /home/public | Disable the SGID bits of a directory |
chmod o+t /home/public | Set the STIKY bit of a file - Only legal everyone can delete files |
chmod o-t /home/public | Disable the STIKY bit of a directory |
Command code | Notes |
---|---|
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 | When performing file system backup, the dump program ignores this file |
chattr +i file1 | Files that are set to immutable cannot be deleted, modified, renamed or linked |
chattr +s file1 | Allow a file to be deleted safely |
chattr +S file1 | Once the application performs a write operation on this file, the system immediately writes the modified result to disk. |
chattr +u file1 | If the file is deleted, the system will allow you to restore the deleted file in the future. |
lsattr | Show special properties |
Command code | Notes |
---|---|
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 | Compress 'file1', 'file2' and directory 'dir1' at the same time |
rar x file1.rar | Unzip rar package |
unrar x file1.rar | Unzip rar package |
tar -cvf archive.tar file1 | Create a non-compressed tarball |
tar -cvf archive.tar file1 file2 dir1 | Create an archive file containing 'file1', 'file2' and 'dir1' |
tar -tf archive.tar | Show contents in a package |
tar -xvf archive.tar | Release a package |
tar -xvf archive.tar -C /tmp | Release the compressed package into /tmp directory |
tar -cvfj archive.tar.bz2 dir1 | Create a bzip2 format compressed package |
tar -jxvf archive.tar.bz2 | Unzip a compressed package in bzip2 format |
tar -cvfz archive.tar.gz dir1 | Create a gzip compressed package |
tar -zxvf archive.tar.gz | Unzip a gzip compressed package |
zip file1.zip file1 | Create a zip-format compressed package |
zip -r file1.zip file1 file2 dir1 | Compress several files and directories into a zip format compressed package at the same time |
unzip file1.zip | Unzip a zip format compressed package |
Command code | Notes |
---|---|
rpm -ivh package.rpm | Install a rpm package |
rpm -ivh --nodeeps package.rpm | Install an rpm package and ignore dependency warning |
rpm -U package.rpm | Update an rpm package without changing its configuration file |
rpm -F package.rpm | Update a rpm package that is sure to have been installed |
rpm -e package_name.rpm | Delete a rpm package |
rpm -qa | Display all installed rpm packages in the system |
rpm -qa | grep httpd | Show all rpm packages with the word "httpd" in their names |
rpm -qi package_name | Get special information about an installed package |
rpm -qg "System Environment/Daemons" | Displays a component's rpm package |
rpm -ql package_name | Shows 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 | Shows a list of dependencies with an rpm package |
rpm -q package_name --whatprovides | Shows the volume occupied by an rpm package |
rpm -q package_name --scripts | Show scripts executed during installation/deletion |
rpm -q package_name --changelog | Shows the modification history of an rpm package |
rpm -qf /etc/httpd/conf/httpd.conf | Confirm which rpm package is provided by the given file |
rpm -qp package.rpm -l | Shows a list of files provided by a rpm package that has not been installed yet |
rpm --import /media/cdrom/RPM-GPG-KEY | Import public key digital certificate |
rpm --checksig package.rpm | Confirm the integrity of an RPM package |
rpm -qa gpg-pubkey | Confirm the integrity of all installed rpm packages |
rpm -V package_name | Check file size, permission, type, owner, group, MD5 check and last modification time |
rpm -Va | Check all installed rpm packages in the system - use with caution |
rpm -Vp package.rpm | Confirm that a rpm package has not been installed yet |
rpm2cpio package.rpm | cpio --extract --make-directories *bin* | Run an executable from a rpm package |
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm | Install a built package from a rpm source code |
rpmbuild --rebuild package_name.src.rpm | Build an rpm package from a rpm source |
Command code | Notes |
---|---|
yum install package_name | Download and install an rpm package |
yum localinstall package_name.rpm | A rpm package will be installed and all dependencies will be resolved for you using your own repository |
yum update package_name.rpm | Update all installed rpm packages in the current system |
yum update package_name | Update a rpm package |
yum remove package_name | Delete a rpm package |
yum list | List all packages installed in the current system |
yum search package_name | Search for packages in rpm repository |
yum clean packages | Clean up rpm cache to delete downloaded packages |
yum clean headers | Delete all header files |
yum clean all | Delete all cached packages and header files |
Command code | Notes |
---|---|
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 httpd | Show all deb packages with the word "httpd" in their names |
dpkg -s package_name | Get information about a special package that has been installed in the system |
dpkg -L package_name | Displays the file list provided by a deb package that has been installed in the system |
dpkg --contents package.deb | Shows a list of files provided by a package that has not been installed yet |
dpkg -S /bin/ping | Confirm which deb package is provided by the given file |
Command code | Notes |
---|---|
apt-get install package_name | Install/update a deb package |
apt-cdrom install package_name | Install/update a deb package from the disc |
apt-get update | Upgrade the 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 | Confirm that the dependent repository is correct |
apt-get clean | Clean cache from downloaded package |
apt-cache search searched-package | Returns the package name containing the string you want to search for |
Command code | Notes |
---|---|
cat file1 | Starting from the first byte, the contents of the file are viewed forward |
tac file1 | Starting from the last line, view the contents of a file in reverse |
more file1 | View the contents of a long file |
less file1 | Similar to the 'more' command, but it allows reverse operations in files as well as forward operations |
head -2 file1 | View the first two lines of a file |
tail -2 file1 | View the last two lines of a file |
tail -f /var/log/messages | View content added to a file in real time |
Command code | Notes |
---|---|
cat file1 | command( sed, grep, awk, grep, etc...) > result.txt | Merge the detailed description text of a file and write the introduction into 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 into an existing file |
grep Aug /var/log/messages | Find keyword "Aug" in file '/var/log/messages' |
grep ^Aug /var/log/messages | Find vocabulary starting with "Aug" in file '/var/log/messages' |
grep [0-9] /var/log/messages | Select '/var/log/messages' all lines containing numbers in the file |
grep Aug -R /var/log/* | Search the string "Aug" in the 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 example.txt file |
sed '/ *#/d; /^$/d' example.txt from example.txt | Delete all comments and blank lines in 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 that contain only the word "string1" |
sed -e 's/ *$//' example.txt | Delete the last whitespace character of each line |
sed -e 's/stringa1//g' example.txt | Remove only the vocabulary "string1" from the document and keep all remaining |
sed -n '1,5p;5q' example.txt | View content from line 1 to line 5 |
sed -n '5p;5q' example.txt | View Line 5 |
sed -e 's/00*/0/g' example.txt | Replace multiple zeros with a single zero |
cat -n file1 | Number of lines indicating the file |
cat example.txt | awk 'NR%2==1' | Delete all even lines in the example.txt file |
echo a b c | awk '{print $1}' | View the first column of a row |
echo a b c | awk '{print $1,$3}' | View the first and third columns of a row |
paste file1 file2 | Merge the contents of two files or two columns |
paste -d '+' file1 file2 | Merge the contents of two files or two columns, and use "+" to distinguish them in the middle. |
sort file1 file2 | Sort the contents of two files |
sort file1 file2 | uniq | Take out the union of two files (only one copy of the duplicate lines) |
sort file1 file2 | uniq -u | Delete the intersection, leaving other lines |
sort file1 file2 | uniq -d | Take out the intersection of two files (leave only files that exist in both files at the same time) |
comm -1 file1 file2 | Compare the contents of two files and delete only the contents contained in 'file1' |
comm -2 file1 file2 | Compare the contents of two files and delete only the contents contained in 'file2' |
comm -3 file1 file2 | Compare the contents of two files and delete only the parts shared by the two files. |
Command code | Notes |
---|---|
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 | Notes |
---|---|
badblocks -v /dev/hda1 | Check for bad blocks on disk hda1 |
fsck /dev/hda1 | Fix/check the integrity of the linux file system on hda1 disk |
fsck.ext2 /dev/hda1 | Fix/check the integrity of ext2 file system on hda1 disk |
e2fsck /dev/hda1 | Fix/check the integrity of ext2 file system on hda1 disk |
e2fsck -j /dev/hda1 | Fix/check the integrity of ext3 file system on hda1 disk |
fsck.ext3 /dev/hda1 | Fix/check the integrity of ext3 file system on hda1 disk |
fsck.vfat /dev/hda1 | Fix/check the integrity of the fat file system on hda1 disk |
fsck.msdos /dev/hda1 | Fix/check the integrity of the dos file system on hda1 disk |
dosfsck /dev/hda1 | Fix/check the integrity of the dos file system on hda1 disk |
Command code | Notes |
---|---|
mkfs /dev/hda1 | Create a file system in hda1 partition |
mke2fs /dev/hda1 | Create a linux ext2 file system in hda1 partition |
mke2fs -j /dev/hda1 | Create a linux ext3 (log type) file system in 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 | Notes |
---|---|
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 | Notes |
---|---|
dump -0aj -f /tmp/home0.bak /home | Make a full 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 | Synchronize the directories on both sides |
rsync -rogpav -e ssh --delete /home ip_address:/tmp | Rsync via SSH channel |
rsync -az -e ssh --delete ip_addr:/home/public /home/local | Synchronize a remote directory to a local directory through 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 local disks 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 operation to the '/home/user' directory |
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' | Copy a directory content 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 - ) | Locally copy one directory 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 with '.txt' from one directory to another |
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 | Find all files ending with '.log' and make a bzip package |
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 | Do an action to copy MBR (Master Boot Record) content to the floppy disk |
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 | Recover MBR content from backups that have been saved to floppy disk |
Command code | Notes |
---|---|
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force | Clear a rewriteable CD content |
mkisofs /dev/cdrom > cd.iso | Create a disc's iso image file on disk |
mkisofs /dev/cdrom | gzip > cd_iso.gz | 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 file for a directory |
cdrecord -v dev=/dev/cdrom cd.iso | Burn an ISO image file |
gzip -dc cd_iso.gz | 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 | Transcribing the audio track from a CD to a wav file |
cd-paranoia -- "-3" | Transcribing the track from a CD disc to a wav file (parameter-3) |
cdrecord --scanbus | Scan the bus to identify the scsi channel |
dd if=/dev/hdc | md5sum | Verify the md5sum encoding of a device, such as a CD |
Command code | Notes |
---|---|
dhclient eth0 | Enable 'eth0' network device in dhcp mode |
ethtool eth0 | Display traffic statistics of network card ‘eth0’ |
host www.example.com | Find the host name to resolve the name and IP address and image |
hostname | Show host name |
ifconfig eth0 | Displays the configuration of an Ethernet card |
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 | Control IP address |
ifconfig eth0 promisc | Set 'eth0' to promiscuous mode to sniff packets (sniffing) |
ifdown eth0 | Disable an 'eth0' network device |
ifup eth0 | Enable an 'eth0' network device |
ip link show | Displays the connection status of all network devices |
iwconfig eth1 | Displays the configuration of a wireless network card |
iwlist scan | Show wireless network |
mii-tool eth0 | Shows the connection status of 'eth0' |
netstat -tup | Show all enabled network connections and their PIDs |
netstat -tup1 | Displays all listening network services and their PIDs in the system |
netstat -rn | Display routing table, similar to the "route -n" command |
nslookup www.example.com | Find the host name to resolve the name and IP address and image |
route -n | Show routing table |
route add -net 0/0 gw IP Gateway | Control the preset gateway |
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 | Control static routes to the network ‘192.168.0.0/16’ |
route del 0/0 gw IP gateway | Delete static routes |
echo “1”> /proc/sys/net/ipv4/ip_foward | Activate IP forwarding |
tcpdump tcp port 80 | Show all HTTP loopbacks |
whois www.example.com | Find in Whois database |
Command code | Notes |
---|---|
mount -t smbfs -o username=user,password=pass //WinClient/share/mnt/share | Mount a Windows network share |
nbtscan ip addr | Netbios name analysis |
nmblookup -A ip addr | Netbios name analysis |
smbclient -L ip addr/hostname | Show remote sharing of a windows host |
smbget -Rr smb://ip addr/share | Like wget, you can download files from a windows host via smb |
Command code | Notes |
---|---|
iptables -t filter -L | Show all links in the filter table |
iptables -t nae -L | Show all links in the nat table |
iptables -t filter -F | Clean all rules based on filter tables |
iptables -t nat -F | Clean all rules based on nat table |
iptables -t filter -X | Delete all links created by users |
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 forwarding links |
iptables -t filter -A INPUT -j LOG --log-prefix | Record all the packets seized in the links |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | Set a PAT (port address translation) to mask out 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 | Transfer packets sent to one host address to another host |
Command code | Notes |
---|---|
free -m | List RAM status in megabytes |
kill -9 process id | Forcefully close the process and end it |
kill -1 process id | Force a process to overload its configuration |
last reboot | Show restart history |
lsmod | Kernel modules that list states |
lsof -p process id | List a list of files opened by a process |
lsof /home/user1 | List the list of opened files in the given system path |
ps -eafw | List Linux tasks |
ps -e -o pid,args --forest | List Linux tasks in a hierarchical way |
pstress | Show program in a tree diagram |
smartctl -A /dev/hda | Monitor the reliability of hard drive devices by enabling SMART |
smartctl -i /dev/hda | Check if SMART of a hard disk device is enabled |
strace -c ls >/dev/null | List the system calls made and receive them with a process |
strace -f -e open ls >/dev/null | List library calls |
tail /var/log/dmesg | Display internal events during kernel boot |
tail /val/log/messages | Show system events |
top | List the Linux tasks that use the most CPU resources |
watch -nl ‘cat /proc/interrupts’ | List real-time interrupts |
Command code | Notes |
---|---|
alias hh='history' | Set an alias for the command history |
apropos ...keyword | List a list of commands that include program keywords, which is especially useful when you only know what the program does and don't remember commands. |
chsh | Change shell command |
chsh --list-shells | Good commands to find 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 using GNU Privacy Guard |
Link:aitoolsbar