Command Code Commentary/Explanation
arch Shows the processor architecture of the machine (1)
uname -m Displays the processor architecture of the machine (2)
uname -r Displays the kernel version in use
dmidecode -q Display Hardware System Components- (SMBIOS / DMI)
hdparm -i /dev/hda List the schema 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 Interrupts
cat /proc/meminfo Verify Memory Usage
cat /proc/swaps Show which swaps are used
cat /proc/version Displays the version of the kernel
cat /proc/net/dev Display network adapters and statistics
cat /proc/mounts Show mounted file systems
lspci -tv List PCI Devices
lsusb -tv Show USB Devices
date Show system date
cal 2007 Show calendar table for 2007
date 041217002007.00 Set date and time-month day hour minute year. second
clock -w Save time changes to BIOS

Command Code Commentary/Explanation
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 System shutdown at scheduled time
shutdown -r now Restart
reboot Restart
logout Log out

Command Code Commentary/Explanation
cd /home 进入 '/ home' 目录'
cd .. Return to the previous directory
cd ../.. Return to the directory two levels up
cd Enter the personal home directory
cd ~user1 Enter the personal home directory
cd - Returns the last directory
pwd Show Work Path
ls View files in a directory
ls -F View files in a directory
ls -l Display details of files and directories
ls -a Show Hidden Files
ls *[0-9]* Displays file and directory names that contain numbers
tree Displays a tree structure of files and directories starting from the root directory
lstree Displays a tree structure of files and directories starting from the root directory
mkdir dir1 创建一个叫做 'dir1' 的目录'
mkdir dir1 dir2 Create two directories at the same time
mkdir -p /tmp/dir1/dir2 Create a directory tree
rm -f file1 删除一个叫做 'file1' 的文件'
rmdir dir1 删除一个叫做 'dir1' 的目录'
rm -rf dir1 Delete a directory called 'dir1' and delete its contents at the same time
rm -rf dir1 dir2 Delete both directories and their contents
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
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 a character
find . -maxdepth 1 -name *.jpg -print -exec convert Batch resize files in the current directory and send them to the thumbnail directory (requires conversion from ImageMagick)

Command Code Commentary/Explanation
find / -name file1 Search for files and directories in the root file system starting from '/'
find / -user user1 Search for files and directories belonging to user 'user1'
find /home/user1 -name \*.bin Search for files ending with '.bin' in directory'/ home/user1'
find /usr/bin -type f -atime +100 Search for executable files that have not been used in the last 100 days
find /usr/bin -type f -mtime -10 Search for files 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 with '.rpm', ignoring removable devices such as optical drives and flash drives.
locate \*.ps Look for files that end with '.ps'-run the 'updatedb' command first
whereis halt Displays the location of a binary, source, or man
which halt Displays the full path of a binary or executable file

Command Code Commentary/Explanation
mount /dev/hda2 /mnt/hda2 mount a disk called hda2-make sure the directory '/ mnt/hda2' already exists
umount /dev/hda2 Unmount a disk named hda2-first exit from the mount point '/ mnt/hda2'
fuser -km /mnt/hda2 Force uninstall when device is busy
umount -n /mnt/hda2 Run an unload 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 an ISO image file
mount -t vfat /dev/hda5 /mnt/hda5 Mount a Windows FAT32 file system
mount /dev/sda1 /mnt/usbdisk mount a usb flash or flash device
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share Mount a windows network share

Command Code Commentary/Explanation
df -h Display the list of mounted partitions.
ls -lSr |more Arrange files and directories by size.
du -sh dir1 估算目录 'dir1' 已经使用的磁盘空间'
du -sk * | sort -rn Displays the size of files and directories in order by capacity size
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n Displays the space used by the 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 the installed deb package based on size (ubuntu, debian class system)

Command Code Commentary/Explanation
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 Modifying User Properties
passwd Modify Password
passwd user1 Change a user's password (only allow root execution)
chage -E 2020-12-31 user1 Set the expiration date of a user's password
pwck Check '/etc/passwd' for file format and syntax fixes and existing users
grpck Check the file format and syntax correction of '/etc/passwd' and the existing groups
newgrp group_name Log in to a new group to change the default group for newly created files

Command Code Commentary/Explanation
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 the directory's owner (u), group (g), and others (o) to read (r), write (w), and execute (x)
chmod go-rwx directory1 Delete group (g) and others (o) read and write permissions on the directory
chown user1 file1 change the owner attribute of a file
chown -R user1 directory1 Change the owner attribute of a directory and change the attributes of all files in the directory at the same time.
chgrp group1 file1 Change the group of a file
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 for 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 for a binary file
chmod g+s /home/public Set the SGID bit for a directory-similar to a SUID, but this is for a directory
chmod g-s /home/public Disable the SGID bit for a directory
chmod o+t /home/public Set the STIKY bit of a file-only allow the legal owner to delete the file
chmod o-t /home/public Disable the STIKY bit for a directory

Command Code Commentary/Explanation
chattr +a file1 Only read and write files by append
chattr +c file1 Allow this file to be automatically compressed/decompressed by the kernel
chattr +d file1 The dump program ignores this file during file system backups
chattr +i file1 Files that are made immutable and 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 restore the deleted file later.
lsattr Show special properties

Command Code Commentary/Explanation
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 同时压缩 'file1', 'file2' 以及目录 '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 file containing 'file1', 'file2', and 'dir1'
tar -tf archive.tar Display the contents of a package
tar -xvf archive.tar Release a package
tar -xvf archive.tar -C /tmp Release the package to the/tmp directory
tar -cvfj archive.tar.bz2 dir1 Create a bzip2 format compression package
tar -jxvf archive.tar.bz2 Decompress a compressed package in bzip2 format
tar -cvfz archive.tar.gz dir1 Create a gzip package
tar -zxvf archive.tar.gz Decompress a gzip-format package
zip file1.zip file1 Create a zip package
zip -r file1.zip file1 file2 dir1 Compress several files and directories into a zip format
unzip file1.zip Unzip a zip format package

Command Code Commentary/Explanation
rpm -ivh package.rpm Install an rpm package
rpm -ivh --nodeeps package.rpm Install an rpm package and ignore dependency warnings
rpm -U package.rpm Update an rpm package without changing its configuration file
rpm -F package.rpm Update an rpm package that is sure to be installed
rpm -e package_name.rpm Delete an rpm package
rpm -qa Displays all installed rpm packages in the system
rpm -qa | grep httpd Show all rpm packages with the word "httpd" in their name
rpm -qi package_name Get special information about an installed package
rpm -qg "System Environment/Daemons" Displays the rpm package for 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 Displays the volume occupied by an rpm packet
rpm -q package_name --scripts Shows scripts executed during installation/removal 1
rpm -q package_name --changelog Displays the modification history of an rpm package
rpm -qf /etc/httpd/conf/httpd.conf Confirm which rpm package the given file is provided
rpm -qp package.rpm -l Displays a list of files provided by an rpm package that has not been installed
rpm --import /media/cdrom/RPM-GPG-KEY Import Public Key Digital Certificate
rpm --checksig package.rpm confirming the integrity of an rpm packet
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 time
rpm -Va Check all installed rpm packages in the system-use with caution
rpm -Vp package.rpm Verify that an rpm package has not been installed
rpm2cpio package.rpm | cpio --extract --make-directories *bin* Run the 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 Commentary/Explanation
yum install package_name Download and install an rpm package
yum localinstall package_name.rpm will install an rpm package and use your own software repository to resolve all dependencies for you
yum update package_name.rpm 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 Lists all packages installed on the current system
yum search package_name search for packages in the rpm repository
yum clean packages Cleaning the rpm cache Deleting downloaded packages
yum clean headers Delete all header files
yum clean all Delete all cached packages and header files

Command Code Commentary/Explanation
dpkg -i package.deb Install/update a deb package
dpkg -r package_name Deleting 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 name
dpkg -s package_name Get 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 that has been installed on the system
dpkg --contents package.deb Displays a list of files provided by a package that has not been installed
dpkg -S /bin/ping Confirm which deb package provides the given file

Command Code Commentary/Explanation
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 Deleting a deb package from the system
apt-get check Confirm that the dependent software repository is correct
apt-get clean Clean cache from downloaded packages
apt-cache search searched-package Returns the package name that contains the string you want to search

Command Code Commentary/Explanation
cat file1 View the contents of the file forward from the first byte
tac file1 Reverse view the contents of a file from the last line
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 Commentary/Explanation
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 在文件 '/var/log/messages'中查找关键词"Aug"
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 in the '/var/log/messages' file that contain numbers
grep Aug -R /var/log/* 在目录 '/var/log' 及随后的目录中搜索字符串"Aug"
sed 's/stringa1/stringa2/g' example.txt 将example.txt文件中的 "string1" 替换成 "string2"
sed '/^$/d' example.txt Remove all blank lines from the example.txt file
sed '/ *#/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 first line from file example.txt
sed -n '/stringa1/p' View rows that contain only the word "string1"
sed -e 's/ *$//' example.txt Remove the last white space character of each line
sed -e 's/stringa1//g' example.txt Remove only the word "string1" from the document and keep all the rest
sed -n '1,5p;5q' example.txt View the contents from the first line to the fifth line
sed -n '5p;5q' example.txt Look at line 5
sed -e 's/00*/0/g' example.txt Replace multiple zeros with a single zero
cat -n file1 Number of lines in the markup 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}' Look at the first and third columns of a row
paste file1 file2 Combine the contents of two files or two columns
paste -d '+' file1 file2 Combine the contents of two files or two columns, and distinguish them with "" in the middle.
sort file1 file2 Sort the contents of two files
sort file1 file2 | uniq Take out the union of two files (keep only one copy of duplicate lines)
sort file1 file2 | uniq -u Delete the intersection, leaving the other rows
sort file1 file2 | uniq -d Take the intersection of two files (leaving only the files that exist in both files)
comm -1 file1 file2 Comparing the contents of two files removes only the contents of 'file1'
comm -2 file1 file2 Comparing the contents of two files removes only the contents of 'file2'
comm -3 file1 file2 Comparing the contents of two files removes only the parts that are common to both files

Command Code Commentary/Explanation
dos2unix filedos.txt fileunix.txt Convert a text file format from MSDOS to UNIX
unix2dos fileunix.txt filedos.txt Converts a text file format from UNIX to MSDOS
recode ..HTML < page.txt > page.html convert a text file into html
recode -l | more Show all allowed conversion formats

Command Code Commentary/Explanation
badblocks -v /dev/hda1 check for bad blocks on disk hda1
fsck /dev/hda1 repair/check the integrity of linux file system on hda1 disk
fsck.ext2 /dev/hda1 repair/check the integrity of ext2 file system on hda1 disk
e2fsck /dev/hda1 repair/check the integrity of ext2 file system on hda1 disk
e2fsck -j /dev/hda1 repair/check the integrity of ext3 file system on hda1 disk
fsck.ext3 /dev/hda1 repair/check the integrity of ext3 file system on hda1 disk
fsck.vfat /dev/hda1 repair/check integrity of fat file system on hda1 disk
fsck.msdos /dev/hda1 repair/check the integrity of dos file system on hda1 disk
dosfsck /dev/hda1 repair/check the integrity of dos file system on hda1 disk

Command Code Commentary/Explanation
mkfs /dev/hda1 create a file system on the hda1 partition
mke2fs /dev/hda1 create a linux ext2 file system on the hda1 partition
mke2fs -j /dev/hda1 Create a Linux ext3 (journaled) file system on the hda1 partition
mkfs -t vfat 32 -F /dev/hda1 Create a FAT32 file system
fdformat -n /dev/fd0 Formatting a floppy disk
mkswap /dev/hda3 Create a swap file system

Command Code Commentary/Explanation
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 Commentary/Explanation
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 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 via ssh and compression
rsync -az -e ssh --delete /home/local ip_addr:/home/public Synchronize a local directory to a remote directory via ssh and compression
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' Perform an operation to back up the local disk on the remote host through 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 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 - ) Local copy a directory to another place, retain 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 with '.log' and make a bzip package
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 Make an action to copy the contents of the MBR (Master Boot Record) to the floppy disk
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 Restore MBR contents from a backup that has been saved to a floppy disk

Command Code Commentary/Explanation
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 file of a cd on disk
mkisofs /dev/cdrom | gzip > cd_iso.gz create a compressed disk iso image file on the 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 Transcribe tracks from a CD into a wav file
cd-paranoia -- "-3" Transcribe tracks from a CD into 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 Commentary/Explanation
dhclient eth0 Enable 'eth0' network device in dhcp mode
ethtool eth0 Display traffic statistics of the NIC 'eth0'
host www.example.com Find hostname to resolve name and IP address and mirror
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 networks
mii-tool eth0 Show connection status for 'eth0'
netstat -tup Displays all enabled network connections and their PIDs
netstat -tup1 Displays all listening 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 IP address and mirror
route -n Show Routing Table
route add -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 Control static route to network '192.168.0.0/16'
route del 0/0 gw IP gateway Delete a static route
echo “1”> /proc/sys/net/ipv4/ip_foward Enable IP forwarding
tcpdump tcp port 80 Show all HTTP loops
whois www.example.com Find in the Whois database

Command Code Commentary/Explanation
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 remote shares for a windows host
smbget -Rr smb://ip addr/share Ability to download files from a windows host via smb like wget

Command Code Commentary/Explanation
iptables -t filter -L Display all links of the filter table
iptables -t nae -L display all links in the nat table
iptables -t filter -F Clean up all rules based on 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 forwarding links
iptables -t filter -A INPUT -j LOG --log-prefix Record the seized packets in all links
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Set 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 Divert packets destined for one host address to another host

Command Code Commentary/Explanation
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 reload its configuration
last reboot Show restart history
lsmod List kernel modules by state
lsof -p process id List a list of files opened by a 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 Show program in tree view
smartctl -A /dev/hda Monitor hard drive device reliability by enabling SMART
smartctl -i /dev/hda Check if SMART is enabled for a hard drive device
strace -c ls >/dev/null List system calls made and receive with one 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 Commentary/Explanation
alias hh='history' Set an alias for the command history (history)
apropos ...keyword A list of commands that include program keywords is especially useful when you only know what the program is for, but don't remember the commands.
chsh Change the shell command
chsh --list-shells Nice command to know if you have to connect to another machine remotely
gpg -c filel Encrypt a file with the GNU Privacy Guard
gpg filel.gpg Decrypt a file with GNU Privacy Guard
Your footprint:

Friend Links:iCMS