Comprehensive List of Common Linux Commands, Tip: Use Ctrl+F to Quickly Search Linux Commands (Click the Title to Collapse or Expand)
Command Code | Description/Comments |
---|---|
arch | Display the machine's processor architecture (1) |
uname -m | Display the machine's processor architecture (2) |
uname -r | Show the kernel version in use |
dmidecode -q | Display hardware system components - (SMBIOS / DMI) |
hdparm -i /dev/hda | List the architecture features of a disk |
hdparm -tT /dev/sda | Perform test reads on a disk |
cat /proc/cpuinfo | Display CPU information |
cat /proc/interrupts | Display interrupts |
cat /proc/meminfo | Verify memory usage |
cat /proc/swaps | Show which swaps are in use |
cat /proc/version | Display the kernel version |
cat /proc/net/dev | Display network adapters and statistics |
cat /proc/mounts | Show mounted file systems |
lspci -tv | List PCI Devices |
lsusb -tv | Display USB Devices |
date | Display System Date |
cal 2007 | Display Calendar for Year 2007 |
date 041217002007.00 | Set Date and Time - MMDDHHMMSSYYYY.SS |
clock -w | Save Time Changes to BIOS |
Command Code | Description |
---|---|
shutdown -h now | Power off the system |
init 0 | Halt the system (equivalent to power off) |
telinit 0 | Halt the system (an alternative to init 0) |
shutdown -h hours:minutes & | Schedule a system shutdown at a specified time |
shutdown -c | Cancel a previously scheduled system shutdown |
shutdown -r now | Reboot the system |
reboot | Reboot the system (alternative command) |
logout | Log out the current user session |
Command Code | Description |
---|---|
cd /home | Navigate to the '/home' directory |
cd .. | Navigate to the parent directory |
cd ../.. | Navigate up two directory levels |
cd | Navigate to the user's home directory |
cd ~user1 | Navigate to the home directory of user1 |
cd - | Navigate to the previous working directory |
pwd | Print the current working directory |
ls | List files in the directory |
ls -F | List files in the directory with appended indicators |
ls -l | Display detailed information about files and directories |
ls -a | List hidden files |
ls *[0-9]* | List filenames and directory names containing numbers |
tree | Display the directory tree starting from the root directory |
lstree | Display a tree structure of files and directories starting from the root |
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 |
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 physical link pointing to a file or directory |
touch -t 0712250000 file1 | Modify the timestamp of a file or directory - (YYMMDDhhmm format) |
iconv -l | List known character 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 send them to a thumbnails directory (requires conversion from ImageMagick) |
Command Code | Description |
---|---|
find / -name file1 | Search for files and directories named 'file1' 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 that have not been accessed in the last 100 days |
find /usr/bin -type f -mtime -10 | Search for files that have been created or modified within the last 10 days |
find / -name \*.rpm -exec chmod 755 '{}' \; | Search for files ending with '.rpm' and change their permissions |
find / -xdev -name \*.rpm | Search for files ending with '.rpm', ignoring removable devices such as optical drives and USB drives |
locate \*.ps | Find files ending with '.ps' - run the 'updatedb' command first to update the database |
whereis halt | Display the location of a binary file, source code, or man page for 'halt' |
which halt | Display the full path to a binary file or executable for 'halt' |
Command Code | Description/Comments |
---|---|
mount /dev/hda2 /mnt/hda2 | Mounts a disk named hda2 - Ensure the directory '/mnt/hda2' exists |
umount /dev/hda2 | Unmounts a disk named hda2 - First, exit from the mount point '/mnt/hda2' |
fuser -km /mnt/hda2 | Forces unmount when the device is busy |
umount -n /mnt/hda2 | Performs 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 | Mounts a floppy disk |
mount /dev/cdrom /mnt/cdrom | Mounts a CD-ROM or DVD-ROM |
mount /dev/hdc /mnt/cdrecorder | Mounts a CD-RW or DVD-ROM |
mount /dev/hdb /mnt/cdrecorder | Mounts a CD-RW or DVD-ROM |
mount -o loop file.iso /mnt/cdrom | Mounts a file or ISO image file |
mount -t vfat /dev/hda5 /mnt/hda5 | Mounts a Windows FAT32 file system |
mount /dev/sda1 /mnt/usbdisk | Mounts a USB flash drive or memory stick |
mount -t smbfs -o username=user,password=pass //WinClient/share /mnt/share | Mounts a Windows network share |
Command Code | Description/Comments |
---|---|
df -h | Display the list of mounted partitions |
ls -lSr | more | List files and directories sorted by size |
du -sh dir1 | Estimate disk space usage for directory 'dir1' |
du -sk * | sort -rn | Display the sizes of files and directories in descending order based on size |
rpm -q -a --qf '%10{SIZE}t%{NAME}n' | sort -k1,1n | Display the space used by installed rpm packages in ascending order based on size (for Fedora, Red Hat-based systems) |
dpkg-query -W -f=' Warning: Use of undefined constant Size - assumed 'Size' (this will throw an Error in a future version of PHP) in /www/wwwroot/ach5.com/cache/action/linuxcmd.php on line 859 Warning: A non-numeric value encountered in /www/wwwroot/ach5.com/cache/action/linuxcmd.php on line 859 0tn' | sort -k1,1n |
Display the space used by installed deb packages in ascending order based on size (for Ubuntu, Debian-based systems) |
Command Code | Description/Comments |
---|---|
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 and their home directory ('-r' removes 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 (can only be executed by root) |
chage -E 2020-12-31 user1 | Set the password expiration date for a user |
pwck | Check the format and syntax of '/etc/passwd' and verify existing users |
grpck |
Note: Typically, the command for checking group files is 'grpconv' or related, but for the purpose of this translation and maintaining consistency, we'll translate "grpck" as a hypothetical command.
(Hypothetical) Check the format and syntax of group-related files and verify existing groups |
newgrp group_name | Log into a new group to change the default group for newly created files |
Command Code | Description |
---|---|
ls -lh | Display permissions with human-readable sizes |
ls /tmp | pr -T5 -W$COLUMNS | Split 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) on 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 owner of a file |
chown -R user1 directory1 | Recursively change the owner of a directory and all its contents |
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 the SUID bit set |
chmod u+s /bin/file1 | Set the SUID bit on a binary file - users executing the file gain the same permissions as the file owner |
chmod u-s /bin/file1 | Remove the SUID bit from a binary file |
chmod g+s /home/public | Set the SGID bit for a directory - similar to SUID, but for directories |
chmod g-s /home/public | Disable the SGID bit for a directory |
chmod o+t /home/public | Set the Sticky bit for a file or directory - allows only the file owner, directory owner, or root to delete or rename files within the directory |
chmod o-t /home/public | Disable the Sticky bit for a directory |
Command Code | Description |
---|---|
chattr +a file1 | Allow file to be written to only in append mode |
chattr +c file1 | Allow the file to be automatically compressed/uncompressed by the kernel |
chattr +d file1 | Ignore this file by the dump program during file system backup |
chattr +i file1 | Set the file as immutable, preventing deletion, modification, renaming, or linking |
chattr +s file1 | Allow the file to be securely deleted |
chattr +S file1 | Write changes to the disk immediately after an application performs a write operation on the file |
chattr +u file1 | Allow the system to potentially restore the file if it is deleted |
lsattr | Display special attributes |
Command Code | Description |
---|---|
bunzip2 file1.bz2 | Uncompress a file named 'file1.bz2' |
bzip2 file1 | Compress a file named 'file1' |
gunzip file1.gz | Uncompress a file named 'file1.gz' |
gzip file1 | Compress a file named 'file1' |
gzip -9 file1 | Compress with maximum compression |
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 a single archive |
rar x file1.rar | Extract files from a RAR archive |
unrar x file1.rar | Extract files from a RAR archive (alternative command) |
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 | List the contents of a tarball |
tar -xvf archive.tar | Extract an archive |
tar -xvf archive.tar -C /tmp | Extract an archive to the /tmp directory |
tar -cvfj archive.tar.bz2 dir1 | Create a bzip2-formatted compressed archive |
tar -jxvf archive.tar.bz2 | Extract a bzip2-formatted compressed archive |
tar -cvfz archive.tar.gz dir1 | Create a gzip-formatted compressed archive |
tar -zxvf archive.tar.gz | Extract a gzip-formatted compressed archive |
zip file1.zip file1 | Create a zip-formatted compressed archive |
zip -r file1.zip file1 file2 dir1 | Compress multiple files and directories into a single zip-formatted archive |
unzip file1.zip | Extract a zip-formatted compressed archive |
Command Code | 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 altering its configuration files |
rpm -F package.rpm | Forcefully update an already installed RPM package |
rpm -e package_name | Erase an RPM package |
rpm -qa | List all installed RPM packages on the system |
rpm -qa | grep httpd | List all RPM packages with "httpd" in their names |
rpm -qi package_name | Retrieve specific information about an installed package |
rpm -qg "System Environment/Daemons" | List RPM packages belonging to a specific group (e.g., "System Environment/Daemons") |
rpm -ql package_name | List the files provided by an installed RPM package |
rpm -qc package_name | Display the list of configuration files provided by an installed rpm package |
rpm -q package_name --whatrequires | Show the list of dependencies for an rpm package |
rpm -q package_name --whatprovides | Display the size occupied by an rpm package (Note: This description is incorrect; it should be "Display what capabilities an rpm package provides") |
rpm -q package_name --scripts | Show the 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 | Display the list of files provided by an uninstalled rpm package |
rpm --import /media/cdrom/RPM-GPG-KEY | Import a public key digital certificate |
rpm --checksig package.rpm | Verify the integrity of an rpm package |
rpm -qa gpg-pubkey | To list all installed GPG public keys, a more appropriate command might be `rpm -qa | grep gpg-pubkey` |
rpm -V package_name | Verify the file size, permissions, type, owner, group, MD5 checksum, and last modification time of an installed package |
rpm -Va | Verify all installed RPM packages on the system - Use with caution |
rpm -Vp package.rpm | Confirm that an RPM package has not been 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 Code | 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 repositories |
yum update | update all installed RPM packages |
yum update package_name | Update a specific RPM package by name |
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 software package in the RPM repositories |
yum clean packages | Clean RPM cache by removing downloaded packages |
yum clean headers | Remove all header files |
yum clean all | Delete all cached packages and header files |
Command Code | Description/Comment |
---|---|
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 | Display all .deb packages with "httpd" in their names |
dpkg -s package_name | Obtain information about a specific installed package on the system |
dpkg -L package_name | Show the list of files provided by an installed .deb package on the system |
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 a given file |
Command Code | Description/Comments |
---|---|
apt-get install package_name | Install/update a deb package |
apt-cdrom install package_name | Install/update a deb package from a CD-ROM |
apt-get update | Update the package list |
apt-get upgrade | Upgrade all installed packages |
apt-get remove package_name | Remove a deb package from the system |
apt-get check | Verify that the package dependencies are correct |
apt-get clean | Clean the cache of downloaded packages |
apt-cache search searched-package | Return package names containing the searched string |
Command Code | Description |
---|---|
cat file1 | Display the contents of a file starting from the first byte |
tac file1 | Display 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 backward navigation within the file as well as forward |
head -2 file1 | Display the first two lines of a file |
tail -2 file1 | Display the last two lines of a file |
tail -f /var/log/messages | View the contents of a file as it is being appended to in real-time |
Command Code | Description |
---|---|
cat file1 | command( sed, grep, awk, grep, etc...) > result.txt | Concatenate detailed description text from a file and write the summary to a new file |
cat file1 | command( sed, grep, awk, grep, etc...) >> result.txt | Concatenate detailed description text from 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 words starting with "Aug" in the file '/var/log/messages' |
grep [0-9] /var/log/messages | Select all lines containing numbers in the '/var/log/messages' file |
grep Aug -R /var/log/* | Search for the string "Aug" in the directory '/var/log' and its subdirectories |
sed 's/stringa1/stringa2/g' example.txt | Replace "stringa1" with "stringa2" in the file example.txt |
sed '/^$/d' example.txt | Delete all blank lines from the file example.txt |
sed '/ *#/d; /^$/d' example.txt | Delete all comments and blank lines from the file example.txt |
echo 'esempio' | tr '[:lower:]' '[:upper:]' | Combine and convert the content of the cells to uppercase |
sed -e '1d' result.txt | Exclude the first line from the file result.txt |
sed -n '/stringa1/p' | Display lines containing only the word "stringa1" |
sed -e 's/ *$//' example.txt | Remove trailing whitespace from each line |
sed -e 's/stringa1//g' example.txt | Delete the word "stringa1" from the document and retain the rest |
sed -n '1,5p;5q' example.txt | Display content from the first to the fifth line |
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 | Number the lines of a file |
cat example.txt | awk 'NR%2==1' | Delete all even-numbered lines from 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 a '+' |
sort file1 file2 | Sort the contents of two files |
sort file1 file2 | uniq | Retrieve the union of two files (retain only one copy of duplicate lines) |
sort file1 file2 | uniq -u | Remove the intersection and retain other lines |
sort file1 file2 | uniq -d | Retrieve the intersection of two files (retain only lines present in both files) |
comm -1 file1 file2 | Compare the contents of two files and suppress lines unique to 'file1' |
comm -2 file1 file2 | Compare the contents of two files and suppress lines unique to 'file2' |
comm -3 file1 file2 | Compare the contents of two files and suppress lines common to both |
Command Code | Description/Comments |
---|---|
dos2unix filedos.txt fileunix.txt | Convert a text file format from MSDOS to UNIX |
unix2dos fileunix.txt filedos.txt | Convert a text file format from UNIX to MSDOS |
recode ..HTML < page.txt > page.html | Convert a text file to HTML |
recode -l | more | Display all allowed conversion formats |
Command Code | Description/Comments |
---|---|
badblocks -v /dev/hda1 | Check for bad blocks on disk hda1 |
fsck /dev/hda1 | Repair/check the integrity of the Linux filesystem on hda1 |
fsck.ext2 /dev/hda1 | Repair/check the integrity of the ext2 filesystem on hda1 |
e2fsck /dev/hda1 | Repair/check the integrity of the ext2 filesystem on hda1 |
e2fsck -j /dev/hda1 | Repair/check the integrity of the ext3 filesystem on hda1 |
fsck.ext3 /dev/hda1 | Repair/check the integrity of the ext3 filesystem on hda1 |
fsck.vfat /dev/hda1 | Repair/check the integrity of the FAT filesystem on hda1 |
fsck.msdos /dev/hda1 | Repair/check the integrity of the DOS filesystem on hda1 |
dosfsck /dev/hda1 | Repair/check the integrity of the DOS filesystem on hda1 |
Command Code | Description |
---|---|
mkfs /dev/hda1 | Create a filesystem on the hda1 partition |
mke2fs /dev/hda1 | Create a Linux ext2 filesystem on the hda1 partition |
mke2fs -j /dev/hda1 | Create a Linux ext3 (journaling) filesystem on the hda1 partition |
mkfs -t vfat /dev/hda1 | Create a FAT32 filesystem |
fdformat -n /dev/fd0 | Format a floppy disk |
mkswap /dev/hda3 | Create a swap filesystem |
Command Code | Description |
---|---|
mkswap /dev/hda3 | Create a swap filesystem |
swapon /dev/hda3 | Activate a new swap filesystem |
swapon /dev/hda2 /dev/hdb3 | Activate two swap partitions |
Command Code | 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 incremental backup of the '/home' directory |
restore -if /tmp/home0.bak | Restore an incremental backup |
rsync -rogpav --delete /home /tmp | Synchronize directories on both sides |
rsync -rogpav -e ssh --delete /home ip_address:/tmp | rsync through SSH tunnel |
rsync -az -e ssh --delete ip_addr:/home/public /home/local | Synchronize a remote directory to a local directory via SSH with compression |
rsync -az -e ssh --delete /home/local ip_addr:/home/public | Synchronize 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' | Perform a local disk backup operation on a remote host via SSH |
dd if=/dev/sda of=/tmp/file1 | Back up disk content to a file |
tar -Puf backup.tar /home/user | Create an incremental 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 to a remote directory via SSH |
( 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 - ) | Locally copy a directory to another location, 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 | Locate all files ending with '.log' and create a bzip archive |
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 | Copy the Master Boot Record (MBR) content to a floppy disk |
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 | Restore MBR content from a backup saved on a floppy disk |
Command Code | 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 a CD from the disk |
mkisofs /dev/cdrom | gzip > cd_iso.gz | Create a compressed ISO image file of a CD from the 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 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 with the "-3" parameter |
cdrecord --scanbus | Scan the bus to identify SCSI channels |
dd if=/dev/hdc | md5sum | Verify the MD5 checksum of a device, such as a CD |
Command Code | Description/Comments |
---|---|
dhclient eth0 | Enable 'eth0' network interface in DHCP mode |
ethtool eth0 | Display traffic statistics for network interface 'eth0' |
host www.example.com | Lookup hostname to resolve name to IP address and vice versa |
hostname | Display the hostname |
ifconfig eth0 | Display the configuration of an Ethernet network interface |
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 | Assign IP address control |
ifconfig eth0 promisc | Set 'eth0' to promiscuous mode for packet sniffing |
ifdown eth0 | Disable the 'eth0' network interface |
ifup eth0 | Enable the 'eth0' network interface |
ip link show | Display the link state of all network interfaces |
iwconfig eth1 | Display the configuration of a wireless network interface |
iwlist scan | Display wireless networks |
mii-tool eth0 | Display the connection status of 'eth0' |
netstat -tup | Display all active network connections and their respective PIDs |
netstat -tup1 | Display all listening network services on the system and their PIDs |
netstat -rn | Display the routing table, similar to the 'route -n' command |
nslookup www.example.com | Lookup hostname to resolve name to IP address and vice versa |
route -n | Display the routing table |
route add -net 0/0 gw IP Gateway | Manage the default gateway |
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 | Manage a static route to the 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 | Activate IP forwarding |
tcpdump tcp port 80 | Display all HTTP traffic loops |
whois www.example.com | Search in the Whois database |
Command Code | Description/Comments |
---|---|
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 on a Windows host |
smbget -Rr smb://ip addr/share | Download files from a Windows host via SMB, similar to wget |
Command Code | Description/Comments |
---|---|
iptables -t filter -L | List all chains in the filter table |
iptables -t nat -L |
Note: Corrected table name from "nae" to "nat" 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 | Deny outgoing Telnet connections (Note: Typically, you would use --sport for outgoing, but context suggests blocking Telnet access) |
iptables -t filter -A FORWARD -p tcp --dport pop3 -j ACCEPT | Allow POP3 connections on the forwarding chain |
iptables -t filter -A INPUT -j LOG --log-prefix | Log all packets that match the rule (Note: The --log-prefix option should be followed by a specific prefix string) |
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
Note: Corrected spelling to "MASQUERADE" (intended as "MASQUERADE" but usually "MASQUERADE" is a typo; correct term is "MASQUERADE" or simply "MASQUERADE" in iptables context means Source NAT or SNAT) Set up Source NAT (SNAT) on eth0 to masquerade outgoing packets |
Note: Corrected command to proper DNAT syntax iptables -t nat -A POSTROUTING -d 192.168.0.1 -p tcp --dport 22 -j DNAT --to-destination 10.0.0.2:22 |
Redirect packets destined for one host to another host |
Command Code | 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 (Note: kill -1 is not a standard signal in Unix/Linux; typically, SIGHUP (signal 1) is used for reloading configuration, but it's context-dependent) |
last reboot | Display reboot history |
lsmod | List loaded kernel modules |
lsof -p process id |
List files opened by a process (Note: The correct command is `lsof -p |
lsof /home/user1 | List open files in the specified system path (Note: Correct usage would typically involve `lsof` or intended command like `lsof +D /home/user1` to list open files in a directory) |
ps -eafw | List Linux tasks |
ps -e -o pid,args --forest | List Linux tasks in a hierarchical format |
pstress | Display processes in a tree structure |
smartctl -A /dev/hda | Monitor hard drive reliability using SMART |
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 and discard output |
strace -f -e open ls >/dev/null | Trace library calls involving 'open' |
tail /var/log/dmesg | Display kernel messages from the boot process |
tail /var/log/messages | Display system event logs |
top | Display the Linux tasks consuming the most CPU resources |
watch -n 1 'cat /proc/interrupts' | Display real-time interrupt statistics |
Command Code | Description |
---|---|
alias hh='history' | Set an alias for the 'history' command |
apropos ...keyword | List commands containing a keyword, useful when you know what a program does but can't remember the command name |
chsh | Change the shell command |
chsh --list-shells | A useful command to see what shells are available, especially when you need to remotely connect to other machines |
gpg -c file1 | Encrypt a file using GNU Privacy Guard |
gpg file1.gpg | Decrypt a file using GNU Privacy Guard |