Command Description
arch Display the machine's processor architecture (1)
uname -m Display the machine's processor architecture (2)
uname -r Display the currently used kernel version
dmidecode -q Display hardware system components - (SMBIOS / DMI)
hdparm -i /dev/hda List the architecture features of a disk
hdparm -tT /dev/sda Perform a test read on the disk
cat /proc/cpuinfo Display CPU information
cat /proc/interrupts Display interrupts
cat /proc/meminfo Check memory usage
cat /proc/swaps Show which swaps are being used
cat /proc/version Display the kernel version
cat /proc/net/dev Show network adapters and statistics
cat /proc/mounts Display mounted file systems
lspci -tv List PCI devices
lsusb -tv Display USB devices
date Display system date
cal 2007 Display the calendar for 2007
date 041217002007.00 Set date and time - MMDDhhmmYYYY.ss
clock -w Save time changes to 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 a scheduled shutdown
shutdown -r now Restart
reboot Restart
logout Log out

Command Description
cd /home Enter the '/home' directory
cd .. Return to the previous directory
cd ../.. Return two directories up
cd Enter your home directory
cd ~user1 Enter the home directory of user1
cd - Return to the last directory you were in
pwd Display the current working path
ls View files in the directory
ls -F View files in the directory with file types
ls -l Display detailed information about files and directories
ls -a Display hidden files
ls *[0-9]* Display files and directories that contain 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' along with 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 Modify the timestamp of a file or directory (YYMMDDhhmm)
iconv -l List known encodings
iconv -f fromEncoding -t toEncoding inputFile > outputFile Convert character encoding
find . -maxdepth 1 -name *.jpg -print -exec convert Batch resize files in the current directory and move them to the thumbnail directory (requires ImageMagick)

Command Description
find / -name file1 Search for files and directories starting from the root ('/')
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 '/home/user1' directory
find /usr/bin -type f -atime +100 Search for executable files that haven't been accessed in the last 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 or floppy drives
locate \*.ps Find files ending with '.ps' (run 'updatedb' command first)
whereis halt Show the location of a binary, source, or manual file
which halt Show the full path of a binary or executable file

Command Description
mount /dev/hda2 /mnt/hda2 Mount a disk called 'hda2' - ensure that the directory '/mnt/hda2' exists
umount /dev/hda2 Unmount a disk 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 Run the unmount operation 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 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 storage 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 file and directory sizes sorted by capacity
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n Display the disk space used by installed RPM packages sorted by size (for Fedora, Red Hat systems)
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n Display the disk space used by installed DEB packages sorted by size (for Ubuntu, Debian 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" group
useradd user1 Create a new user
userdel -r user1 Delete a user ('-r' excludes the home directory)
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 Modify user attributes
passwd Change password
passwd user1 Change a user's password (only allowed for root)
chage -E 2020-12-31 user1 Set a password expiration date for the user
pwck Check the format and syntax of '/etc/passwd' and existing users
grpck Check the format and syntax of '/etc/group' and existing groups
newgrp group_name Log into a new group to change the default group for newly created files

Command Description
ls -lh Display permissions
ls /tmp | pr -T5 -W$COLUMNS Display terminal output in 5 columns
chmod ugo+rwx directory1 Set read (r), write (w), and execute (x) permissions for the owner (u), group (g), and others (o) on a directory
chmod go-rwx directory1 Remove read, write, and execute permissions for the group (g) and others (o) on a directory
chown user1 file1 Change the owner of a file
chown -R user1 directory1 Change the owner of a directory and all its files
chgrp group1 file1 Change the group of a file
chown user1:group1 file1 Change the owner and group of a file
find / -perm -u+s List all files in the system with SUID set
chmod u+s /bin/file1 Set the SUID bit on a binary file, giving users who run the file the same privileges as the owner
chmod u-s /bin/file1 Disable the SUID bit on 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 Disable the SGID bit on a directory
chmod o+t /home/public Set the Sticky bit on a directory, allowing only the owner to delete files
chmod o-t /home/public Disable the Sticky bit on a directory

Command Description
chattr +a file1 Allow the file to be read and written only in append mode
chattr +c file1 Allow the file to be automatically compressed/decompressed by the kernel
chattr +d file1 Ignore this file during filesystem backups by the dump program
chattr +i file1 Set the file as immutable; it cannot be deleted, modified, renamed, or linked
chattr +s file1 Allow a file to be securely deleted
chattr +S file1 Immediately write changes to disk after an application writes to this file
chattr +u file1 If the file is deleted, the system allows you to recover the deleted file later
lsattr Display special attributes

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 an 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 an uncompressed tarball
tar -cvf archive.tar file1 file2 dir1 Create an archive file containing 'file1', 'file2', and 'dir1'
tar -tf archive.tar Show 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 Extract a bzip2 compressed archive
tar -cvfz archive.tar.gz dir1 Create a gzip compressed archive
tar -zxvf archive.tar.gz Extract a gzip compressed archive
zip file1.zip file1 Create a zip compressed archive
zip -r file1.zip file1 file2 dir1 Compress several files and directories into a single zip archive
unzip file1.zip Extract a zip compressed archive

Command Description
rpm -ivh package.rpm Install an RPM package
rpm -ivh --nodeeps package.rpm Install an RPM package while ignoring dependency warnings
rpm -U package.rpm Update an RPM package without changing its configuration files
rpm -F package.rpm Update an already installed RPM package
rpm -e package_name.rpm Remove an RPM package
rpm -qa Display all installed RPM packages in the system
rpm -qa | grep httpd Display all RPM packages containing "httpd" in their name
rpm -qi package_name Get specific information about an installed package
rpm -qg "System Environment/Daemons" Display RPM packages of a component
rpm -ql package_name Show the file list provided by an installed RPM package
rpm -qc package_name Show the configuration file list 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 Show the size occupied by an RPM package
rpm -q package_name --scripts Show scripts executed during installation/removal
rpm -q package_name --changelog Display the changelog of an RPM package
rpm -qf /etc/httpd/conf/httpd.conf Identify which RPM package provides the given file
rpm -qp package.rpm -l Show the file list provided by an uninstalled RPM package
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 modified time
rpm -Va Check all installed RPM packages in the system — use with caution
rpm -Vp package.rpm Verify that an RPM package is not installed
rpm2cpio package.rpm | cpio --extract --make-directories *bin* Run executable files 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 Description
yum install package_name Download and install an RPM package
yum localinstall package_name.rpm Install an RPM package, resolving all dependencies using your own software repository
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 packages in the RPM repository
yum clean packages Clean up RPM cache by removing downloaded packages
yum clean headers Remove all header files
yum clean all Remove all cached packages and header files

Command Description
dpkg -i package.deb Install/update a DEB package
dpkg -r package_name Remove a DEB package from the system
dpkg -l Display all DEB packages installed on the system
dpkg -l | grep httpd Show all DEB packages with "httpd" in their names
dpkg -s package_name Get information about a specific installed package
dpkg -L package_name Display the list of files provided by an installed DEB package
dpkg --contents package.deb Show the list of files provided by an uninstalled package
dpkg -S /bin/ping Identify which DEB package provides the specified file

Command Description
apt-get install package_name Install/update a DEB package
apt-cdrom install package_name Install/update a DEB package from a CD
apt-get update Upgrade the list of available packages
apt-get upgrade Upgrade all installed software
apt-get remove package_name Remove a DEB package from the system
apt-get check Verify that dependency software repositories are correct
apt-get clean Clean up cached files from downloaded packages
apt-cache search searched-package Return package names that contain the search string

Command Description
cat file1 View the contents of a file from the first byte onward
tac file1 View the contents of a file from the last line backward
more file1 View the contents of a long file
less file1 Similar to 'more', but allows backward navigation in 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 Real-time view of contents being added to a file

Command Description
cat file1 | command (sed, grep, awk, etc...) > result.txt Merge detailed description text from a file and write it to a new file
cat file1 | command (sed, grep, awk, etc...) >> result.txt Merge detailed description text from a file and append it 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 in '/var/log/messages' that contain numbers
grep Aug -R /var/log/* Search for the string "Aug" in the '/var/log' directory and its subdirectories
sed 's/stringa1/stringa2/g' example.txt Replace "string1" with "string2" in example.txt
sed '/^$/d' example.txt Delete all blank lines from example.txt
sed '/ *#/d; /^$/d' example.txt Delete all comments and blank lines from the file
echo 'esempio' | tr '[:lower:]' '[:upper:]' Convert all characters to uppercase
sed -e '1d' result.txt Exclude the first line from example.txt
sed -n '/stringa1/p' View only the lines containing "string1"
sed -e 's/ *$//' example.txt Remove trailing whitespace from each line
sed -e 's/stringa1//g' example.txt Delete "string1" from the document, keeping everything else
sed -n '1,5p;5q' example.txt View the contents from the first to the fifth line
sed -n '5p;5q' example.txt View the fifth line
sed -e 's/00*/0/g' example.txt Replace multiple zeros with a single zero
cat -n file1 Show line numbers in the file
cat example.txt | awk 'NR%2==1' Delete all even lines from example.txt
echo a b c | awk '{print $1}' View the first column of a line
echo a b c | awk '{print $1,$3}' View the first and third columns 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 (duplicate lines kept once)
sort file1 file2 | uniq -u Remove the intersection, leaving only the other lines
sort file1 file2 | uniq -d Get the intersection of two files (only lines existing in both files)
comm -1 file1 file2 Compare two files and show only content from 'file1'
comm -2 file1 file2 Compare two files and show only content from 'file2'
comm -3 file1 file2 Compare two files and show only common content

Command Description
dos2unix filedos.txt fileunix.txt Convert a text file from MSDOS format to UNIX format
unix2dos fileunix.txt filedos.txt Convert a text file from UNIX format to MSDOS format
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 disk hda1
fsck /dev/hda1 Repair/check the integrity of the Linux file system on disk hda1
fsck.ext2 /dev/hda1 Repair/check the integrity of the ext2 file system on disk hda1
e2fsck /dev/hda1 Repair/check the integrity of the ext2 file system on disk hda1
e2fsck -j /dev/hda1 Repair/check the integrity of the ext3 file system on disk hda1
fsck.ext3 /dev/hda1 Repair/check the integrity of the ext3 file system on disk hda1
fsck.vfat /dev/hda1 Repair/check the integrity of the FAT file system on disk hda1
fsck.msdos /dev/hda1 Repair/check the integrity of the DOS file system on disk hda1
dosfsck /dev/hda1 Repair/check the integrity of the DOS file system on disk hda1

Command Description
mkfs /dev/hda1 Create a file system on partition hda1
mke2fs /dev/hda1 Create a Linux ext2 file system on partition hda1
mke2fs -j /dev/hda1 Create a Linux ext3 (journaled) file system on partition hda1
mkfs -t vfat -F 32 /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 incremental backup of the '/home' directory
restore -if /tmp/home0.bak Restore an interactive backup
rsync -rogpav --delete /home /tmp Sync two directories
rsync -rogpav -e ssh --delete /home ip_address:/tmp Sync over SSH
rsync -az -e ssh --delete ip_addr:/home/public /home/local Sync a remote directory to a local directory over SSH with compression
rsync -az -e ssh --delete /home/local ip_addr:/home/public Sync a local directory to a remote directory over SSH with compression
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' Backup the local disk 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 a directory's 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 while preserving 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 create a bzip package
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 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 saved floppy disk backup

Command Description
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force Erase the contents of a rewritable CD
mkisofs /dev/cdrom > cd.iso Create an ISO image file of the CD on disk
mkisofs /dev/cdrom | gzip > cd_iso.gz Create a compressed ISO image file of the 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 from a directory
cdrecord -v dev=/dev/cdrom cd.iso Burn an ISO image file to a CD
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom - Burn a compressed ISO image file to a CD
mount -o loop cd.iso /mnt/iso Mount an ISO image file
cd-paranoia -B Rip audio tracks from a CD to WAV files
cd-paranoia -- "-3" Rip audio 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 MD5 checksum of a device, such as a CD

Command Description
dhclient eth0 Enable the 'eth0' network device in DHCP mode
ethtool eth0 Display traffic statistics for the network card 'eth0'
host www.example.com Look up a hostname to resolve names to IP addresses and mirrors
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 the IP address
ifconfig eth0 promisc Set 'eth0' to promiscuous mode to sniff packets
ifdown eth0 Disable the 'eth0' network device
ifup eth0 Enable the 'eth0' network device
ip link show Show the connection status of all network devices
iwconfig eth1 Display the configuration of a wireless network card
iwlist scan Show available wireless networks
mii-tool eth0 Display the connection status of 'eth0'
netstat -tup Show all enabled network connections and their PIDs
netstat -tup1 Show 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 Look up a hostname to resolve names to IP addresses and mirrors
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 Add a 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_forward Enable IP forwarding
tcpdump tcp port 80 Show all HTTP traffic
whois www.example.com Look up information in the Whois database

Command 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 Show 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 Display all chains in the filter table
iptables -t nat -L Display 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 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 forward chain
iptables -t filter -A INPUT -j LOG --log-prefix Log all packets that are dropped
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE Set up PAT (Port Address Translation) on eth0 to masquerade outgoing packets
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 address to another host

Command Description
free -m List RAM status in megabytes
kill -9 process_id Forcefully close a process and terminate it
kill -1 process_id Force a process to reload its configuration
last reboot Display reboot history
lsmod List loaded kernel modules
lsof -p process_id List files opened by a process
lsof /home/user1 List opened files in the specified system path
ps -eafw List Linux tasks
ps -e -o pid,args --forest List Linux tasks in a hierarchical manner
pstree Display programs in a tree format
smartctl -A /dev/hda Check hard disk reliability via SMART monitoring
smartctl -i /dev/hda Check if SMART is enabled on a hard disk device
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 Show internal events during the kernel boot process
tail /var/log/messages Display system events
top List the Linux tasks using the most CPU resources
watch -n 1 'cat /proc/interrupts' List real-time interrupts

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

Friendly Links: PM EVE PM EVE