Command 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 architecture characteristics of a disk
hdparm -tT /dev/sda Perform a test read on a disk
cat /proc/cpuinfo Display CPU information
cat /proc/interrupts Display interrupts
cat /proc/meminfo Check memory usage
cat /proc/swaps Display which swap spaces are in use
cat /proc/version Display the kernel version
cat /proc/net/dev Display network adapters and statistics
cat /proc/mounts Display mounted file systems
lspci -tv List PCI devices
lsusb -tv Display USB devices
date Display the system date
cal 2007 Display the calendar for the year 2007
date 041217002007.00 Set the date and time - MMDDhhmmYYYY.ss
clock -w Save the time changes to the BIOS

Command 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 a scheduled time
shutdown -c Cancel the scheduled shutdown
shutdown -r now Restart the system
reboot Restart the system
logout Log out

Command Description
cd /home Enter the '/home' directory
cd .. Go up one directory level
cd ../.. Go up two directory levels
cd Enter the personal home directory
cd ~user1 Enter the personal home directory of user1
cd - Return to the previous directory
pwd Display the current working directory
ls List files in the directory
ls -F List files in the directory
ls -l Display detailed information about files and directories
ls -a Display hidden files
ls *[0-9]* Display filenames and directory names containing numbers
tree Display a tree structure starting from the root directory
lstree Display a tree structure 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 its contents
rm -rf dir1 dir2 Delete two directories and their contents
mv dir1 new_dir Rename/move a directory
cp file1 file2 Copy a file
cp dir/* . Copy all files from 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 symbolic link to a file or directory
ln file1 lnk1 Create a hard link to a file or directory
touch -t 0712250000 file1 Change the timestamp of a file or directory - (YYMMDDhhmm)
iconv -l List known encodings
iconv -f fromEncoding -t toEncoding inputFile > outputFile Change file encoding
find . -maxdepth 1 -name *.jpg -print -exec convert Batch resize files in the current directory and send them to a thumbnail directory (requires ImageMagick conversion)

Command Description
find / -name file1 Search for files and directories starting from the root filesystem '/'
find / -user user1 Search for files and directories owned by user 'user1'
find /home/user1 -name \*.bin Search for files ending with '.bin' in the directory '/home/user1'
find /usr/bin -type f -atime +100 Search for executable files not used in the past 100 days
find /usr/bin -type f -mtime -10 Search for files created or modified within the last 10 days
find / -name \*.rpm -exec chmod 755 '{}' \; Search for files ending with '.rpm' and set their permissions
find / -xdev -name \*.rpm Search for files ending with '.rpm', excluding removable devices like CD-ROMs
locate \*.ps Find files ending with '.ps' (run the 'updatedb' command first)
whereis halt Display the location of a binary, source, or man page
which halt Display the full path of a binary or executable file

Command Description
mount /dev/hda2 /mnt/hda2 Mount a partition called hda2 - Ensure the directory '/mnt/hda2' exists
umount /dev/hda2 Unmount a partition called hda2 - Exit from the mount point '/mnt/hda2' first
fuser -km /mnt/hda2 Force unmount when the device is busy
umount -n /mnt/hda2 Unmount without writing to the /etc/mtab file - Useful when the file is read-only or the disk is full
mount /dev/fd0 /mnt/floppy Mount a floppy disk
mount /dev/cdrom /mnt/cdrom Mount a CD-ROM or DVD-ROM
mount /dev/hdc /mnt/cdrecorder Mount a CD-RW or DVD-ROM
mount /dev/hdb /mnt/cdrecorder Mount a CD-RW or DVD-ROM
mount -o loop file.iso /mnt/cdrom Mount 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 pen drive or flash device
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share Mount a Windows network share

Command Description
df -h Display a list of mounted partitions
ls -lSr |more List files and directories sorted by size
du -sh dir1 Estimate the disk space used by directory 'dir1'
du -sk * | sort -rn Display the size of files and directories in descending order based on capacity
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n Display the space used by installed RPM packages sorted by size (Fedora, RedHat-based systems)
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n Display the space used by installed DEB packages sorted by size (Ubuntu, Debian-based systems)

Command 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 belonging to the "admin" user group
useradd user1 Create a new user
userdel -r user1 Delete a user ('-r' removes the home directory)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 Modify user properties
passwd Change password
passwd user1 Change a user's password (root only)
chage -E 2020-12-31 user1 Set password expiration date for a user
pwck Verify the format and syntax of the '/etc/passwd' file and check for existing users
grpck Verify the format and syntax of the '/etc/group' file and check for existing groups
newgrp group_name Log into a new group to change the default group for new files

Command Description
ls -lh Display permissions
ls /tmp | pr -T5 -W$COLUMNS Divide the terminal into 5 columns for display
chmod ugo+rwx directory1 Set read (r), write (w), and execute (x) permissions for the owner (u), group (g), and others (o) of the directory
chmod go-rwx directory1 Remove read, write, and execute permissions for the group (g) and others (o) on the directory
chown user1 file1 Change the ownership of a file
chown -R user1 directory1 Change the ownership of a directory and all files within it
chgrp group1 file1 Change the group of a file
chown user1:group1 file1 Change both the owner and group of a file
find / -perm -u+s List all files with SUID bit set in the system
chmod u+s /bin/file1 Set the SUID bit on a binary file - Users running the file gain the same privileges as the owner
chmod u-s /bin/file1 Remove the SUID bit from a binary file
chmod g+s /home/public Set the SGID bit on a directory - Similar to SUID, but for directories
chmod g-s /home/public Remove the SGID bit from a directory
chmod o+t /home/public Set the Sticky bit on a file - Only the owner can delete the file
chmod o-t /home/public Remove the Sticky bit from a directory

Command Description
chattr +a file1 Allow a file to be opened for appending only
chattr +c file1 Allow the file to be automatically compressed/decompressed by the kernel
chattr +d file1 Exclude the file from being backed up by the dump program
chattr +i file1 Make the file immutable; it cannot be deleted, modified, renamed, or linked
chattr +s file1 Allow the file to be securely deleted
chattr +S file1 Ensure that changes to the file are immediately written to disk when the file is modified
chattr +u file1 Allow the file to be recoverable if it is deleted
lsattr Display special attributes of files

Command Description
bunzip2 file1.bz2 Decompress a file named 'file1.bz2'
bzip2 file1 Compress a file named 'file1'
gunzip file1.gz Decompress a file named 'file1.gz'
gzip file1 Compress a file named 'file1'
gzip -9 file1 Compress to the maximum extent
rar a file1.rar test_file Create a RAR archive named 'file1.rar'
rar a file1.rar file1 file2 dir1 Compress 'file1', 'file2', and directory 'dir1' into one archive
rar x file1.rar Extract a RAR archive
unrar x file1.rar Extract a RAR archive
tar -cvf archive.tar file1 Create a non-compressed tarball
tar -cvf archive.tar file1 file2 dir1 Create an archive containing 'file1', 'file2', and 'dir1'
tar -tf archive.tar Display the contents of an archive
tar -xvf archive.tar Extract an archive
tar -xvf archive.tar -C /tmp Extract the archive to the /tmp directory
tar -cvfj archive.tar.bz2 dir1 Create a bzip2 compressed archive
tar -jxvf archive.tar.bz2 Decompress a bzip2 compressed archive
tar -cvfz archive.tar.gz dir1 Create a gzip compressed archive
tar -zxvf archive.tar.gz Decompress a gzip compressed archive
zip file1.zip file1 Create a zip archive
zip -r file1.zip file1 file2 dir1 Compress multiple files and directories into a zip archive
unzip file1.zip Decompress a zip archive

Command Description
rpm -ivh package.rpm Install an RPM package
rpm -ivh --nodeeps package.rpm Install an RPM package ignoring dependency warnings
rpm -U package.rpm Update an RPM package without changing its configuration files
rpm -F package.rpm Update an installed RPM package if it exists
rpm -e package_name.rpm Remove an RPM package
rpm -qa Display all installed RPM packages
rpm -qa | grep httpd Display all RPM packages containing "httpd" in their name
rpm -qi package_name Get detailed information about an installed package
rpm -qg "System Environment/Daemons" Display RPM packages of a specific component
rpm -ql package_name Display a list of files provided by an installed RPM package
rpm -qc package_name Display a list of configuration files provided by an installed RPM package
rpm -q package_name --whatrequires Display a list of dependencies for an RPM package
rpm -q package_name --whatprovides Display what an RPM package provides
rpm -q package_name --scripts Display scripts executed during the installation/removal of the package
rpm -q package_name --changelog Display the changelog of an RPM package
rpm -qf /etc/httpd/conf/httpd.conf Identify which RPM package provides a given file
rpm -qp package.rpm -l Display the list of files provided by an RPM package not yet installed
rpm --import /media/cdrom/RPM-GPG-KEY Import a public key 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, permissions, type, owner, group, MD5 checksum, and last modification time
rpm -Va Verify all installed RPM packages on the system - Use with caution
rpm -Vp package.rpm Verify an RPM package that is not yet installed
rpm2cpio package.rpm | cpio --extract --make-directories *bin* Extract executable files from an RPM package
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm Install a built package from RPM source
rpmbuild --rebuild package_name.src.rpm Build an RPM package from source

Command Description
yum install package_name Download and install an RPM package
yum localinstall package_name.rpm Install an RPM package, using your own repositories to resolve all dependencies
yum update package_name.rpm Update all installed RPM packages on the current system
yum update package_name Update a specific RPM package
yum remove package_name Remove an RPM package
yum list List all packages installed on the current system
yum search package_name Search for a package in the RPM repository
yum clean packages Clean the RPM cache by deleting downloaded packages
yum clean headers Delete all header files
yum clean all Delete all cached packages and header files

Command Description
dpkg -i package.deb Install/upgrade a DEB package
dpkg -r package_name Remove a DEB package from the system
dpkg -l Display all installed DEB packages on the system
dpkg -l | grep httpd Display all DEB packages containing "httpd" in their name
dpkg -s package_name Get information about a specific package installed on the system
dpkg -L package_name Display the list of files provided by an installed DEB package
dpkg --contents package.deb Display the list of files provided by a DEB package that is not yet installed
dpkg -S /bin/ping Identify which DEB package provides the given file

Command Description
apt-get install package_name Install/upgrade a DEB package
apt-cdrom install package_name Install/upgrade a DEB package from a CD
apt-get update Update the list of packages
apt-get upgrade Upgrade all installed software
apt-get remove package_name Remove a DEB package from the system
apt-get check Verify the correctness of the package dependencies
apt-get clean Clean the cache of downloaded packages
apt-cache search searched-package Return the package name containing the search string

Command Description
cat file1 View the contents of a file from the beginning
tac file1 View the contents of a file in reverse order, starting from the last line
more file1 View the contents of a long file
less file1 Similar to the 'more' command, but allows both forward and backward navigation through the file
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 the content being appended to a file in real time

Command Description
cat file1 | command (sed, grep, awk, grep, etc...) > result.txt Merge detailed description text of a file and write the summary into a new file
cat file1 | command (sed, grep, awk, grep, etc...) >> result.txt Merge detailed description text of a file and append the summary to an existing file
grep Aug /var/log/messages Search for the keyword "Aug" in the file '/var/log/messages'
grep ^Aug /var/log/messages Search for lines starting with "Aug" in the file '/var/log/messages'
grep [0-9] /var/log/messages Select all lines containing numbers in the file '/var/log/messages'
grep Aug -R /var/log/* Search for the string "Aug" in the directory '/var/log' and its subdirectories
sed 's/string1/string2/g' example.txt Replace "string1" with "string2" in the file example.txt
sed '/^$/d' example.txt Delete all empty lines from the file example.txt
sed '/ *#/d; /^$/d' example.txt Delete all comments and empty lines from the file example.txt
echo 'example' | tr '[:lower:]' '[:upper:]' Convert text from lowercase to uppercase
sed -e '1d' result.txt Exclude the first line from the file result.txt
sed -n '/string1/p' Display lines containing only "string1"
sed -e 's/ *$//' example.txt Remove trailing whitespace characters from each line
sed -e 's/string1//g' example.txt Delete the word "string1" from the document while keeping the rest
sed -n '1,5p;5q' example.txt Display lines from the first to the fifth
sed -n '5p;5q' example.txt Display the fifth line
sed -e 's/00*/0/g' example.txt Replace multiple zeros with a single zero
cat -n file1 Display line numbers in the file
cat example.txt | awk 'NR%2==1' Delete all even-numbered lines from the file example.txt
echo a b c | awk '{print $1}' Display the first field of a line
echo a b c | awk '{print $1,$3}' Display the first and third fields of a line
paste file1 file2 Merge the contents of two files or columns
paste -d '+' file1 file2 Merge the contents of two files or columns, separated by "+"
sort file1 file2 Sort the contents of two files
sort file1 file2 | uniq Get the union of two files (keeping only unique lines)
sort file1 file2 | uniq -u Remove the intersection, leaving other lines
sort file1 file2 | uniq -d Get the intersection of two files (leaving only lines common to both)
comm -1 file1 file2 Compare the contents of two files and delete content from 'file1'
comm -2 file1 file2 Compare the contents of two files and delete content from 'file2'
comm -3 file1 file2 Compare the contents of two files and delete common content

Command 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 format
recode -l | more Display all allowed conversion formats

Command Description
badblocks -v /dev/hda1 Check for bad blocks on the disk hda1
fsck /dev/hda1 Repair/check the integrity of the Linux file system on the disk hda1
fsck.ext2 /dev/hda1 Repair/check the integrity of the ext2 file system on the disk hda1
e2fsck /dev/hda1 Repair/check the integrity of the ext2 file system on the disk hda1
e2fsck -j /dev/hda1 Repair/check the integrity of the ext3 file system on the disk hda1
fsck.ext3 /dev/hda1 Repair/check the integrity of the ext3 file system on the disk hda1
fsck.vfat /dev/hda1 Repair/check the integrity of the FAT file system on the disk hda1
fsck.msdos /dev/hda1 Repair/check the integrity of the DOS file system on the disk hda1
dosfsck /dev/hda1 Repair/check the integrity of the DOS file system on the disk hda1

Command Description
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 (journaling) file system on 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 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 Description
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 Perform rsync over an SSH channel
rsync -az -e ssh --delete ip_addr:/home/public /home/local Synchronize a remote directory to a local directory with SSH and compression
rsync -az -e ssh --delete /home/local ip_addr:/home/public Synchronize a local directory to a remote directory with SSH and compression
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' Perform a local disk backup on a remote host over SSH
dd if=/dev/sda of=/tmp/file1 Backup disk content 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 directory contents to a remote directory over SSH
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' Copy a local directory to a remote directory over SSH
tar cf - . | (cd /tmp/backup ; tar xf - ) Copy a directory locally to another location, preserving 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 create a bzip archive
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 Copy the MBR (Master Boot Record) contents to a floppy disk
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 Restore the MBR contents from a backup saved on a floppy disk

Command Description
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force Erase the content of a rewritable CD
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 ISO image file of a CD on disk
mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd Create an ISO image file of 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 Rip tracks from a CD to WAV files
cd-paranoia -- "-3" Rip tracks from a CD to WAV files (parameter -3)
cdrecord --scanbus Scan the bus to identify SCSI channels
dd if=/dev/hdc | md5sum Check the md5sum of a device, e.g., a CD

Command Description
dhclient eth0 Enable 'eth0' network device in DHCP mode
ethtool eth0 Display traffic statistics for 'eth0'
host www.example.com Lookup hostname to resolve name and IP address
hostname Display the hostname
ifconfig eth0 Display the configuration of an Ethernet card
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 Set IP address
ifconfig eth0 promisc Set 'eth0' to promiscuous mode for packet sniffing
ifdown eth0 Disable 'eth0' network device
ifup eth0 Enable 'eth0' network device
ip link show Show connection status of all network devices
iwconfig eth1 Display the configuration of a wireless network card
iwlist scan Display wireless networks
mii-tool eth0 Show the connection status of 'eth0'
netstat -tup Display all active network connections and their PIDs
netstat -tup1 Display all listening network services and their PIDs
netstat -rn Display the routing table, similar to "route -n"
nslookup www.example.com Lookup hostname to resolve name and IP address
route -n Display the routing table
route add -net 0/0 gw IP Gateway Set the default gateway
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 Set a static route to network '192.168.0.0/16'
route del 0/0 gw IP gateway Remove a static route
echo "1" > /proc/sys/net/ipv4/ip_forward Enable IP forwarding
tcpdump tcp port 80 Display all HTTP loops
whois www.example.com Lookup in Whois database

Command Description
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share Mount a Windows network share
nbtscan ip addr Resolve NetBIOS names
nmblookup -A ip addr Resolve NetBIOS names
smbclient -L ip addr/hostname List remote shares on a Windows host
smbget -Rr smb://ip addr/share Download files from a Windows host via SMB, similar to wget

Command Description
iptables -t filter -L List all chains in the filter table
iptables -t nat -L List all chains in the nat table
iptables -t filter -F Flush all rules in the filter table
iptables -t nat -F Flush all rules in the nat table
iptables -t filter -X Delete all user-defined chains
iptables -t filter -A INPUT -p tcp --dport telnet -j ACCEPT Allow incoming telnet connections
iptables -t filter -A OUTPUT -p tcp --dport telnet -j DROP Block outgoing telnet connections
iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT Allow forwarding of POP3 connections
iptables -t filter -A INPUT -j LOG --log-prefix Log all blocked packets
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Set up a PAT (Port Address Translation) to masquerade outgoing packets on 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 Redirect packets destined for one host to another host

Command Description
free -m List RAM status in megabytes
kill -9 process id Forcefully terminate a process
kill -1 process id Force a process to reload its configuration
last reboot Show reboot history
lsmod List the status of kernel modules
lsof -p process id List files opened by a process
lsof /home/user1 List files opened in the specified system path
ps -eafw List Linux tasks
ps -e -o pid,args --forest List Linux tasks hierarchically
pstress Display programs in a tree view
smartctl -A /dev/hda Monitor the reliability of a hard disk by enabling SMART
smartctl -i /dev/hda Check if SMART is enabled on a hard disk
strace -c ls >/dev/null List system calls made by a process
strace -f -e open ls >/dev/null List library calls
tail /var/log/dmesg Display kernel boot events
tail /var/log/messages Display system events
top List Linux tasks using the most CPU resources
watch -nl ‘cat /proc/interrupts’ Display real-time interrupts

Command Description
alias hh='history' Set an alias for the history command
apropos ...keyword List a command that includes a program keyword, useful when you know what the program does but not the command
chsh Change the shell command
chsh --list-shells Useful to know if you need to connect remotely to another machine
gpg -c file1 Encrypt a file using GNU Privacy Guard
gpg file1.gpg Decrypt a file using GNU Privacy Guard
Your Footprints: