Linux CMD Collection,
Tips: Use Ctrl+F for quick search of Linux commands (Click titles to collapse or expand)
Command Code | Description |
---|---|
arch | Display machine's architecture (1) |
uname -m | Display machine's architecture (2) |
uname -r | Display currently running kernel version |
dmidecode -q | Display hardware system components - (SMBIOS / DMI) |
hdparm -i /dev/hda | Show architecture characteristics of a disk |
hdparm -tT /dev/sda | Perform timing test on disk reads |
cat /proc/cpuinfo | Display CPU info 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 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 system date |
cal 2007 | Display calendar for the year 2007 |
date 041217002007.00 | Set date and time - MMDDhhmmYYYY.ss |
clock -w | Save changes to BIOS clock |
Command | Description |
---|---|
shutdown -h now | Shutdown the system immediately |
init 0 | Shutdown the system |
telinit 0 | Shutdown the system |
shutdown -h hours:minutes & | Shutdown the system at a specified time |
shutdown -c | Cancel a scheduled system shutdown |
shutdown -r now | Reboot the system immediately |
reboot | Reboot the system |
logout | Logout from the current session |
Command Code | Comment Description |
---|---|
cd /home | Change to the '/home' directory |
cd .. | Move to the parent directory |
cd ../.. | Move up two levels in the directory hierarchy |
cd | Change to the user's home directory |
cd ~user1 | Change to user1's home directory |
cd - | Change back to the previous working directory |
pwd | Print the current working directory |
ls | List files in the directory |
ls -F | List files in the directory |
ls -l | List detailed information about files and directories |
ls -a | List hidden files |
ls *[0-9]* | List files and directories containing numbers in their names |
tree | Display the directory tree starting from the root directory |
lstree | Display the directory tree starting from the root directory |
mkdir dir1 | Create a directory named 'dir1' |
mkdir dir1 dir2 | Create two directories simultaneously |
mkdir -p /tmp/dir1/dir2 | Create a directory tree |
rm -f file1 | Delete a file named 'file1' |
rmdir dir1 | Delete a directory named 'dir1' |
rm -rf dir1 | Delete a directory named 'dir1' and its contents recursively |
rm -rf dir1 dir2 | Delete two directories and their contents simultaneously |
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 | Change character encoding |
find . -maxdepth 1 -name *.jpg -print -exec convert | Batch resize files in the current directory and send them to a thumbnails directory (requires conversion from ImageMagick) |
Command | Description |
---|---|
find / -name file1 | Search for file and directories starting from the root file system '/' |
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 in '/usr/bin' not accessed in the last 100 days |
find /usr/bin -type f -mtime -10 | Search for files created or modified within the last 10 days in '/usr/bin' |
find / -name \*.rpm -exec chmod 755 '{}' \; | Search for files ending with '.rpm' and set their permissions to 755 |
find / -xdev -name \*.rpm | Search for files ending with '.rpm', excluding removable devices like CD-ROMs and USB drives |
locate \*.ps | Locate files ending with '.ps' (PostScript format) - run 'updatedb' command first |
whereis halt | Display location of binary, source, or man pages for 'halt' |
which halt | Display the full path of an executable binary file 'halt' |
Command | Explanation |
---|---|
mount /dev/hda2 /mnt/hda2 | Mount a disk named hda2 - ensure directory '/mnt/hda2' exists |
umount /dev/hda2 | Unmount a disk named hda2 - first exit from mount point '/mnt/hda2' |
fuser -km /mnt/hda2 | Force unmount when device is busy |
umount -n /mnt/hda2 | Perform unmount operation without writing to /etc/mtab file - useful when file is read-only or 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 pen drive or flash drive |
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share | Mount a Windows network share |
Command Code | Explanation |
---|---|
df -h | Display a list of mounted partitions |
ls -lSr | more | List files and directories sorted by size |
du -sh dir1 | Estimate disk usage of directory 'dir1' |
du -sk * | sort -rn | Display sizes of files and directories in descending order |
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n | List installed RPM packages sorted by size (Fedora, Red Hat systems) |
dpkg-query -W -f='${Installed-Size;10}t${Package}n' | sort -k1,1n | List installed DEB packages sorted by size (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 'user1' belonging to the 'admin' group |
useradd user1 | Create a new user 'user1' |
userdel -r user1 | Delete a user 'user1' (excluding home directory with '-r') |
usermod -c "User FTP" -g system -d /ftp/user1 -s /bin/nologin user1 | Modify user properties for 'user1' |
passwd | Change password |
passwd user1 | Change password for user 'user1' (root only) |
chage -E 2020-12-31 user1 | Set password expiration date for user 'user1' |
pwck | Check and repair the /etc/passwd file format and syntax, and verify existing users |
grpck | Check and repair the /etc/passwd file format and syntax, and verify existing groups |
newgrp group_name | Log in to a new group to change the default group for newly created files |
Command Code | Description |
---|---|
ls -lh | Display permissions |
ls /tmp | pr -T5 -W$COLUMNS | Divide terminal into 5 columns for output |
chmod ugo+rwx directory1 | Set read (r), write (w), and execute (x) permissions for owner (u), group (g), and others (o) on directory1 |
chmod go-rwx directory1 | Remove read (r), write (w), and execute (x) permissions for group (g) and others (o) on directory1 |
chown user1 file1 | Change owner of file1 to user1 |
chown -R user1 directory1 | Change owner of directory1 and all files within it to user1 |
chgrp group1 file1 | Change group of file1 to group1 |
chown user1:group1 file1 | Change owner and group of file1 to user1 and group1 respectively |
find / -perm -u+s | List all files on the system with setuid (SUID) set |
chmod u+s /bin/file1 | Set the setuid (SUID) bit on /bin/file1 - allows users to execute the file with owner's permissions |
chmod u-s /bin/file1 | Disable the setuid (SUID) bit on /bin/file1 |
chmod g+s /home/public | Set the setgid (SGID) bit on /home/public - applies permissions of the group to new files created in the directory |
chmod g-s /home/public | Disable the setgid (SGID) bit on /home/public |
chmod o+t /home/public | Set the sticky bit on /home/public - allows only the owner of a file to delete it |
chmod o-t /home/public | Disable the sticky bit on /home/public |
Command Code | Explanation |
---|---|
chattr +a file1 | Only allows appending to a file, prohibits other modifications |
chattr +c file1 | Enables automatic compression/decompression by the kernel |
chattr +d file1 | Excludes the file from being backed up by the dump program |
chattr +i file1 | Sets a file as immutable; cannot be deleted, modified, renamed, or linked |
chattr +s file1 | Allows a file to be securely deleted |
chattr +S file1 | Immediately synchronizes changes to the file to disk after modification by an application |
chattr +u file1 | Allows recovery of a deleted file in the future |
lsattr | Displays special attributes of files |
Command Code | 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 | Maximum compression level |
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' simultaneously |
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 file containing 'file1', 'file2', and 'dir1' |
tar -tf archive.tar | Display contents of an archive |
tar -xvf archive.tar | Extract an archive |
tar -xvf archive.tar -C /tmp | Extract a tarball 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 multiple files and directories into a zip archive |
unzip file1.zip | Extract a zip compressed archive |
Command Code | Description |
---|---|
rpm -ivh package.rpm | Install an RPM package |
rpm -ivh --nodeeps package.rpm | Install an RPM package, ignoring dependencies |
rpm -U package.rpm | Upgrade an RPM package without changing its configuration files |
rpm -F package.rpm | Update an RPM package that is already installed |
rpm -e package_name.rpm | Remove an RPM package |
rpm -qa | Display all installed RPM packages on the system |
rpm -qa | grep httpd | Display RPM packages containing "httpd" in their names |
rpm -qi package_name | Get specific information about an installed package |
rpm -qg "System Environment/Daemons" | Display RPM packages belonging to a group |
rpm -ql package_name | List files provided by an installed RPM package |
rpm -qc package_name | List configuration files provided by an installed RPM package |
rpm -q package_name --whatrequires | Show dependencies for an RPM package |
rpm -q package_name --whatprovides | Show what an RPM package provides |
rpm -q package_name --scripts | Display scripts executed during install/remove of an RPM package |
rpm -q package_name --changelog | Show changelog for an RPM package |
rpm -qf /etc/httpd/conf/httpd.conf | Identify which RPM package provides a given file |
rpm -qp package.rpm -l | List files provided by an uninstalled RPM package |
rpm --import /media/cdrom/RPM-GPG-KEY | Import a GPG public key |
rpm --checksig package.rpm | Verify integrity of an RPM package |
rpm -qa gpg-pubkey | Verify integrity of all installed RPM packages |
rpm -V package_name | Check file size, permissions, type, owner, group, MD5 checksum, and modification time |
rpm -Va | Check all installed RPM packages on the system - use with caution |
rpm -Vp package.rpm | Check an uninstalled RPM package |
rpm2cpio package.rpm | cpio --extract --make-directories *bin* | Execute binaries from an RPM package |
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm | Install a pre-built package from RPM source |
rpmbuild --rebuild package_name.src.rpm | Build an RPM package from source |
Command Code | Description |
---|---|
yum install package_name | Download and install an RPM package |
yum localinstall package_name.rpm | Install an RPM package using your own software repository to resolve all dependencies |
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 | Remove an RPM package |
yum list | List all installed packages in the current system |
yum search package_name | Search for a package in the RPM repository |
yum clean packages | Clean the RPM cache by removing downloaded packages |
yum clean headers | Remove all header files |
yum clean all | Remove all cached packages and headers |
Command Code | Explanation |
---|---|
dpkg -i package.deb | Install/update a deb package |
dpkg -r package_name | Remove a deb package from the system |
dpkg -l | List all installed deb packages on the system |
dpkg -l | grep httpd | Show all deb packages with names containing "httpd" |
dpkg -s package_name | Get information about a specific package installed on the system |
dpkg -L package_name | List files provided by an installed deb package |
dpkg --contents package.deb | List contents of an uninstalled package |
dpkg -S /bin/ping | Determine which deb package provides a given file |
Command Code | Comment Description |
---|---|
apt-get install package_name | Install/update a deb package |
apt-cdrom install package_name | Install/update a deb package from CD-ROM |
apt-get update | Update the list of available packages |
apt-get upgrade | Upgrade all installed packages |
apt-get remove package_name | Remove a deb package from the system |
apt-get check | Verify the correctness of dependencies |
apt-get clean | Clean up downloaded package files from the cache |
apt-cache search searched-package | Return package names containing the searched string |
Command Code | Comment Description |
---|---|
cat file1 | View the contents of a file from the beginning. |
tac file1 | View the contents of a file in reverse starting from the last line. |
more file1 | View the contents of a long file interactively. |
less file1 | Similar to 'more' command but allows backward as well as forward navigation within 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 contents of a file in real-time as new lines are added to it. |
Command Code | Description |
---|---|
cat file1 | command (sed, grep, awk, grep, etc...) > result.txt | Merge detailed description text from file1 and write summary into a new file |
cat file1 | command (sed, grep, awk, grep, etc...) >> result.txt | Merge detailed description text from file1 and append summary to an existing file |
grep Aug /var/log/messages | Search for keyword "Aug" in file '/var/log/messages' |
grep ^Aug /var/log/messages | Search for lines starting with "Aug" in file '/var/log/messages' |
grep [0-9] /var/log/messages | Select lines in file '/var/log/messages' containing numbers |
grep Aug -R /var/log/* | Search string "Aug" recursively in directory '/var/log' and subdirectories |
sed 's/stringa1/stringa2/g' example.txt | Replace "string1" with "string2" in file example.txt |
sed '/^$/d' example.txt | Delete all blank lines from file example.txt |
sed '/ *#/d; /^$/d' example.txt | Delete all comments and blank lines from file example.txt |
echo 'esempio' | tr '[:lower:]' '[:upper:]' | Convert content of upper and lower cells |
sed -e '1d' result.txt | Exclude first line from file example.txt |
sed -n '/stringa1/p' | Display lines containing only "string1" |
sed -e 's/ *$//' example.txt | Remove trailing whitespace from each line in example.txt |
sed -e 's/stringa1//g' example.txt | Delete only "string1" from document and retain the rest |
sed -n '1,5p;5q' example.txt | Display content from line 1 to line 5 |
sed -n '5p;5q' example.txt | Display line 5 |
sed -e 's/00*/0/g' example.txt | Replace multiple zeros with a single zero |
cat -n file1 | Number the lines of a file |
cat example.txt | awk 'NR%2==1' | Delete all even lines from example.txt |
echo a b c | awk '{print $1}' | Display the first column of a line |
echo a b c | awk '{print $1,$3}' | Display the first and third columns of a line |
paste file1 file2 | Merge content of two files or columns |
paste -d '+' file1 file2 | Merge content of two files or columns with '+' as separator |
sort file1 file2 | Sort the content of two files |
sort file1 file2 | uniq | Extract union of two files (keep only one copy of duplicate lines) |
sort file1 file2 | uniq -u | Remove intersection, keep other lines |
sort file1 file2 | uniq -d | Extract intersection of two files (keep lines present in both files) |
comm -1 file1 file2 | Compare contents of two files, delete what is included in 'file1' |
comm -2 file1 file2 | Compare contents of two files, delete what is included in 'file2' |
comm -3 file1 file2 | Compare contents of two files, delete common part of both files |
Command Code | Description |
---|---|
dos2unix filedos.txt fileunix.txt | Convert the format of a text file from MSDOS to UNIX |
unix2dos fileunix.txt filedos.txt | Convert the format of a text file from UNIX to MSDOS |
recode ..HTML < page.txt> page.html | Convert a text file to HTML |
recode -l | more | Display all allowed conversion formats |
Command Code | Description |
---|---|
badblocks -v /dev/hda1 | Check for bad blocks on disk /dev/hda1 |
fsck /dev/hda1 | Repair/check the integrity of Linux file system on disk hda1 |
fsck.ext2 /dev/hda1 | Repair/check the integrity of ext2 file system on disk hda1 |
e2fsck /dev/hda1 | Repair/check the integrity of ext2 file system on disk hda1 |
e2fsck -j /dev/hda1 | Repair/check the integrity of ext3 file system on disk hda1 |
fsck.ext3 /dev/hda1 | Repair/check the integrity of ext3 file system on disk hda1 |
fsck.vfat /dev/hda1 | Repair/check the integrity of FAT file system on disk hda1 |
fsck.msdos /dev/hda1 | Repair/check the integrity of DOS file system on disk hda1 |
dosfsck /dev/hda1 | Repair/check the integrity of DOS file system on disk hda1 |
Command Code | Description |
---|---|
mkfs /dev/hda1 | Create a file system on partition hda1 |
mke2fs /dev/hda1 | Create a Linux ext2 file system on hda1 partition |
mke2fs -j /dev/hda1 | Create a Linux ext3 (journaling) file system on 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 | Explanation |
---|---|
mkswap /dev/hda3 | Create a swap file system on /dev/hda3 |
swapon /dev/hda3 | Enable a new swap file system |
swapon /dev/hda2 /dev/hdb3 | Enable two swap partitions |
Command Code | Comment Description |
---|---|
dump -0aj -f /tmp/home0.bak /home | Create a full backup of the '/home' directory |
dump -1aj -f /tmp/home0.bak /home | Create 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 | Sync a remote directory to a local directory via SSH with compression |
rsync -az -e ssh --delete /home/local ip_addr:/home/public | Sync a local directory to a remote directory via SSH with compression |
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' | Backup local disk via SSH on a remote host |
dd if=/dev/sda of=/tmp/file1 | Backup disk contents to a file |
tar -Puf backup.tar /home/user | Perform an interactive backup of '/home/user' directory |
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' | Copy contents of a directory via SSH to a remote directory |
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x -p' | Copy a local directory to a remote directory via SSH |
tar cf - . | (cd /tmp/backup ; tar xf - ) | Copy a directory locally to another place, preserving permissions and links |
find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ --parents | Find and copy all '*.txt' files from one directory to another |
find /var/log -name '*.log' | tar cv --files-from=- | bzip2 > log.tar.bz2 | Find '*.log' files and create a bzip archive |
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 | Backup 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 backup on a floppy disk |
Command Code | Explanation |
---|---|
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force | Clears the content of a rewritable CD. |
mkisofs /dev/cdrom > cd.iso | Creates an ISO image file of a CD on disk. |
mkisofs /dev/cdrom | gzip > cd_iso.gz | Creates 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 | Creates an ISO image file of a directory. |
cdrecord -v dev=/dev/cdrom cd.iso | Burns an ISO image file to a CD. |
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom - | Burns a compressed ISO image file to a CD. |
mount -o loop cd.iso /mnt/iso | Mounts an ISO image file. |
cd-paranoia -B | Transcribes audio tracks from a CD to WAV files. |
cd-paranoia -- "-3" | Transcribes audio tracks from a CD to WAV files with parameter -3. |
cdrecord --scanbus | Scans the bus to identify SCSI channels. |
dd if=/dev/hdc | md5sum | Checks the md5sum encoding of a device, such as a CD. |
Command Code | Comment Description |
---|---|
dhclient eth0 | Enable 'eth0' network device in DHCP mode |
ethtool eth0 | Display traffic statistics for the 'eth0' network card |
host www.example.com | Lookup hostname to resolve names with IP addresses and mirrors |
hostname | Display the hostname |
ifconfig eth0 | Display configuration for an Ethernet card |
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 | Control IP address for 'eth0' |
ifconfig eth0 promisc | Set 'eth0' into promiscuous mode to sniff packets |
ifdown eth0 | Disable 'eth0' network device |
ifup eth0 | Enable 'eth0' network device |
ip link show | Show the connection status of all network devices |
iwconfig eth1 | Display configuration for a wireless network card |
iwlist scan | Display wireless networks |
mii-tool eth0 | Display 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 in the system |
netstat -rn | Display the routing table, similar to the "route -n" command |
nslookup www.example.com | Lookup hostname to resolve names with IP addresses and mirrors |
route -n | Display the routing table |
route add -net 0/0 gw IP Gateway | Control default 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_forward | Enable IP forwarding |
tcpdump tcp port 80 | Display all HTTP traffic |
whois www.example.com | Search in the Whois database |
Command Code | Comment Description |
---|---|
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share | Mount a Windows network share |
nbtscan ip_addr | NetBIOS name resolution |
nmblookup -A ip_addr | NetBIOS name resolution |
smbclient -L ip_addr/hostname | List remote shares of a Windows host |
smbget -Rr smb://ip_addr/share | Download files from a Windows host via SMB similar to wget |
Command Code | Comment 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 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 forwarded chains |
iptables -t filter -A INPUT -j LOG --log-prefix | Log packets dropped in all chains |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE | Set up Port Address Translation (PAT) on eth0 to mask 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 a host address to another host |
Command | Description |
---|---|
free -m | Display 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 loaded kernel modules |
lsof -p process id | List files opened by a process |
lsof /home/user1 | List files opened in a given system path |
ps -eafw | List Linux tasks |
ps -e -o pid,args --forest | List Linux tasks in a hierarchical way |
pstress | Display processes in a tree view |
smartctl -A /dev/hda | Monitor hard disk device reliability using SMART |
smartctl -i /dev/hda | Check if SMART is enabled on a hard disk device |
strace -c ls >/dev/null | Trace system calls made by a process |
strace -f -e open ls >/dev/null | Trace library calls |
tail /var/log/dmesg | Display internal events during kernel boot |
tail /val/log/messages | Display system messages |
top | Display top CPU-consuming Linux tasks |
watch -n1 'cat /proc/interrupts' | Monitor real-time interrupts |
Command Code | Description |
---|---|
alias hh='history' | Set an alias for the command 'history' |
apropos ...keyword | List commands containing keywords, useful when you know what a program does but not its exact command |
chsh | Change shell command |
chsh --list-shells | Check which shells are available for remote connections |
gpg -c file | Encrypt a file using GNU Privacy Guard |
gpg file.gpg | Decrypt a file encrypted with GNU Privacy Guard |
Our Linux Command Reference provides a comprehensive list of commonly used commands in Linux systems, covering navigation, file management, system information, process management, networking, package management, and system administration tasks.
Using our Linux Command Reference is straightforward:
Key features of our Linux Command Reference include:
Explore our Linux Command Reference to streamline your Linux system management and improve your command-line proficiency.
Links: google