COMMAND | DESCRIPTION | More details | |
---|---|---|---|
System information | |||
arch | show architecture of the machine | Example | |
uname -m | show architecture of the machine | Example | |
uname -r | show kernel version used | Example | |
dmidecode -q | show hardware system components - (SMBIOS / DMI) | Example | |
hdparm -i /dev/hda | displays the characteristics of a hard-disk | Example | |
hdparm -tT /dev/sda | perform t est reading on a hard-disk | Example | |
cat /proc/cpuinfo | shows information CPU info | Example | |
cat /proc/interrupts | show interrupts | Example | |
cat /proc/meminfo | verify memory use | Example | |
cat /proc/swaps | show file(s) swap | Example | |
cat /proc/version | show version of the kernel | Example | |
cat /proc/net/dev | show network adpters and statistics | Example | |
cat /proc/mounts | show mounted file system(s) | Example | |
lspci -tv | display PCI devices | Example | |
lsusb -tv | show USB devices | Example | |
date | show system date | Example | |
cal 2007 | show the timetable of 2007 | Example | |
date 041217002007.00 | set date and time - MonthDayhoursMinutesYear.Seconds | Example | |
clock -w | save changes of date on BIOS | Example | |
Shutdown, Restart of a system and Logout | |||
shutdown -h now | shutdown system | Example | |
init 0 | shutdown system | Example | |
shutdown -r hours:minutes & | planned shutdown ofthe system | Example | |
shutdown -c | cancel a planned shutdown of the system | Example | |
shutdown -r now | reboot | Example | |
reboot | reboot | Example | |
logout | leaving session | Example | |
Files and Directory | |||
cd /home | enter to directory '/ home' | Example | |
cd .. | go back one level | Example | |
cd ../.. | go back two levels | Example | |
cd | go to home directory | Example | |
cd ~utente | go to home directory | Example | |
cd - | go to previous directory | Example | |
pwd | show the path of work directory | Example | |
ls | view files of directory | Example | |
ls -F | view files of directory | Example | |
ls -l | show details of files and directory | Example | |
ls -a | show hidden files | Example | |
ls *[0-9]* | show files and directory containing numbers | Example | |
tree | show files and directories in a tree starting from root | Example | |
lstree | show files and directories in a tree starting from root | Example | |
mkdir dir1 | create a directory called 'dir1' | Example | |
mkdir dir1 dir2 | create two directories simultaneously | Example | |
mkdir -p /tmp/dir1/dir2 | create a directory tree | Example | |
rm -f file1 | delete file called 'file1' | Example | |
rmdir dir1 | delete directory called 'dir1' | Example | |
rm -rf dir1 | remove a directory called 'dir1' and contents recursively | Example | |
rm -rf dir1 dir2 | remove two directories and their contents recursively | Example | |
mv dir1 new_dir | rename / move a file or directory | Example | |
cp file1 file2 | copying a file | Example | |
cp dir/* . | copy all files of a directory within the current work directory | Example | |
cp -a /tmp/dir1 . | copy a directory within the current work directory | Example | |
cp -a dir1 dir2 | copy a directory | Example | |
ln -s file1 lnk1 | create a symbolic link to file or directory | Example | |
ln file1 lnk1 | create a physical link to file or directory | Example | |
touch -t 0712250000 fileditest | modify timestamp of a fileor directory - (YYMMDDhhmm) | Example | |
File search | |||
find / -name file1 | search file and directory into root filesystem from '/' | Example | |
find / -user user1 | search files and directories belonging to 'user1' | Example | |
find /home/user1 -name *.bin | search files with '. bin' extension within directory '/ home/user1' | Example | |
find /usr/bin -type f atime +100 | search bynary files are not used in the last 100 days | Example | |
find /usr/bin -type f mtime 10 | search files created or changed within 10 days | Example | |
find / -name *.rpm exec chmod 755 {} ; | search files with '.rpm' extension and modify permits | Example | |
find / -xdev name *.rpm | search files with '.rpm'extension ignoring removable partitions as cdrom, pen-drive, etc.… | Example | |
locate *.ps | find files with the '.ps' extension - first run 'updatedb' command | Example | |
whereis halt | show location of a binary file, source or man | Example | |
which halt | show full path to a binary / executable | Example | |
Mounting a Filesystem | |||
mount /dev/hda2 /mnt/hda2 | mount disk called hda2 - verify existence of the directory '/ mnt/hda2' | Example | |
umount /dev/hda2 | unmount disk called hda2 - exit from mount point '/ mnt/hda2' first | Example | |
fuser -km /mnt/hda2 | force umount when the device is busy | Example | |
umount -n /mnt/hda2 | run umount without writing the file /etc/mtab - useful when the file is read-only or the hard disk is full | Example | |
mount /dev/fd0 /mnt/floppy | mount a floppy disk | Example | |
mount /dev/cdrom /mnt/cdrom | mount a cdrom / dvdrom | Example | |
mount /dev/hdc /mnt/cdrecorder | mount a cdrw / dvdrom | Example | |
mount /dev/hdb /mnt/cdrecorder | mount a cdrw / dvdrom | Example | |
mount -o loop file.iso /mnt/cdrom | mount a file or iso image | Example | |
mount -t vfat /dev/hda5 /mnt/hda5 | mount a Windows FAT32 file system | Example | |
mount /dev/sda1 /mnt/usbdisk | mount a usb pen-drive or flashdrive | Example | |
mount -t smbfs o username=user,password=pass //winclient/share /mnt/share | mount a windows network share | Example | |
Disk Space | |||
df -h | show list of partitions mounted | Example | |
ls -lSr |more | show size of the files and directories ordered by size | Example | |
du -sh dir1 | estimate space used by directory 'dir1' | Example | |
du -sk * | sort rn | show size of the files and directories sorted by size | Example | |
rpm -q a qf '%10{SIZE}t%{NAME}n' | sort k1,1n | show space used by rpm packages installed sorted by size (fedora, redhat and like) | Example | |
dpkg-query W f='${InstalledSize;10}t${Package}n' | sort -k1,1n | show space used by deb packages installed sorted by size (ubuntu, debian and like) | Example | |
Users and Groups | |||
groupadd group_name | create a new group | Example | |
groupdel group_name | delete a group | Example | |
groupmod -n new_group_name old_group_name | rename a group | Example | |
useradd -c Nome Cognome" g admin d /home/user1 s /bin/bash user1 " | create a new user belongs admin" group" | Example | |
useradd user1 | create a new user | Example | |
userdel -r user1 | delete a user ( '-r' eliminates home directory) | Example | |
usermod -c User FTP" g system d /ftp/user1 s /bin/nologin user1 " | change user attributes | Example | |
passwd | change password | Example | |
passwd user1 | change a user password (only by root) | Example | |
chage -E 20051231 user1 | set deadline for user password | Example | |
pwck | check correct syntax and file format of '/etc/pasws d' and users existence | Example | |
grpck | check correct syntax and file format of '/etc/group' and groups existence | Example | |
newgrp group_name | log in to a new group to change default group of newly created files | Example | |
Permits on File - use +" to set permissions and "-" to remove" | |||
ls -lh | show permits | Example | |
ls /tmp | pr -T5 W$COLUMNS | divide terminal into 5 columns | Example | |
chmod ugo+rwx directory1 | set permissions reading (r), write (w) and (x)access to users owner (u) group (g) and others (o) | Example | |
chmod go-rwx directory1 | remove permits reading (r), write (w) and (x) access to users group (g) and others (or | Example | |
chown user1 file1 | change owner of a file | Example | |
chown user1 -R directory1 | change user owner of a directory and allthe files and directories contained inside | Example | |
chgrp gruppo1 file1 | change group of files | Example | |
chown user1:gruppo1 file1 | change user and group ownership of a file | Example | |
find / -perm u+s | view all files on the system with SUID configured | Example | |
chmod u+s /bin/file_eseguibile | set SUID bit on a binary file - the user that running that file gets same privileges as owner | Example | |
chmod u-s /bin/file_binario | disable SUID bit on a binary file | Example | |
chmod g+s /home/public | set SGID bit on a directory - similar to SUID but for directory | Example | |
chmod g-s /home/public | disable SGID bit on a directory | Example | |
chmod o+t /home/comune | set STIKY bit on a directory - allows files deletion only to legitimate owners | Example | |
chmod o-t /home/comune | disable STIKY bit on a directory | Example | |
Special Attributes on file - use +" to set permissions and "-" to remove" | |||
chattr +a file1 | allows write opening of a file only append mode | Example | |
chattr +c file1 | allows that a file is compressed / decompressed automatically by the kernel | Example | |
chattr +d file1 | makes sure that the program ignores Dump the files during backup | Example | |
chattr +i file1 | makes it an immutable file, which cannot be removed, altered, renamed or linked | Example | |
chattr +s file1 | allows a file to be deleted safely | Example | |
chattr +S file1 | makes sure that if a file is modified changes are written in synchronous mode as with sync | Example | |
chattr +u file1 | allows you to recover the contents of a file even if it is canceled | Example | |
lsattr | show specials attributes | Example | |
Archives and compressed files | |||
bunzip2 file1.bz2 | decompress a file called 'file1.bz2' | Example | |
bzip2 file1 | compress a file called 'file1' | Example | |
gunzip file1.gz | decompress a file called 'file1.gz' | Example | |
gzip file1 | compress a file called 'file1' | Example | |
gzip -9 file1 | compress with maximum compression | Example | |
rar a file1.rar test_file | create an archive rar called'file1.rar' | Example | |
rar a file1.rar file1 file2 dir1 | compress 'file1', 'file2' and 'dir1' simultaneously | Example | |
rar x file1.rar | decompress rar archive | Example | |
unrar x file1.rar | decompress rar archive | Example | |
tar -cvf archive.tar file1 | create a uncompressed tarball | Example | |
tar -cvf archive.tar file1 file2 dir1 | create an archive containing 'file1', 'file2' and 'dir1' | Example | |
tar -tf archive.tar | show contents of an archive | Example | |
tar -xvf archive.tar | extract a tarball | Example | |
tar -xvf archive.tar C /tmp | extract a tarball into / tmp | Example | |
tar -cvfj archive.tar.bz2 dir1 | create a tarball compressed into bzip2 | Example | |
tar -xvfj archive.tar.bz2 | decompress a compressed tar archive in bzip2 | Example | |
tar -cvfz archive.tar.gz dir1 | create a tarball compressed into gzip | Example | |
tar -xvfz archive.tar.gz | decompress a compressed tar archive in gzip | Example | |
zip file1.zip file1 | create an archive compressed in zip | Example | |
zip -r file1.zip file1 file2 dir1 | compress in zip several files and directories simultaneously | Example | |
unzip file1.zip | decompress a zip archive | Example | |
RPM Packages - Fedora, Red Hat and like | |||
rpm -ivh package.rpm | install a rpm package | Example | |
rpm -ivh nodeeps package.rpm | install a rpm package ignoring dependencies requests | Example | |
rpm -U package.rpm | upgrade a rpm package without changing configuration files | Example | |
rpm -F package.rpm | upgrade a rpm package only if it is already installed | Example | |
rpm -e package_name.rpm | remove a rpm package | Example | |
rpm -qa | show all rpm packagesinstalled on the system | Example | |
rpm -qa | grep httpd | show all rpm packageswith the name httpd"" | Example | |
rpm -qi package_name | obtain information on a specific package installed | Example | |
rpm -qg System Environment/Daemons" " | show rpm packages of a groupsoftware | Example | |
rpm -ql package_name | show list of files provided by a rpm package installed | Example | |
rpm -qc package_name | show list of configuration files provided by a rpm package installed | Example | |
rpm -q package_name whatrequires | show list of dependencies required fora rpm packet | Example | |
rpm -q package_name whatprovides | show capability provided by a rpm package | Example | |
rpm -q package_name scripts | show scripts started during installation / removal | Example | |
rpm -q package_name changelog | show history of revisions of a rpm package | Example | |
rpm -qf /etc/httpd/conf/httpd.conf | verify which rpm package belongs to a given fiel | Example | |
rpm -qp package.rpm -l | show list of files provided by a rpm package not yet installed | Example | |
rpm -import /media/cdrom/RPMGPGKEY | import public-key digital signature | Example | |
rpm -checksig package.rpm | verify the integrityof a rpm package | Example | |
rpm -qa gpgpubkey | verify integrity of all rpm packages installed | Example | |
rpm -V package_name | check file size, permissions, type, owner, group, MD5 checksum and last modification | Example | |
rpm -Va | check all rpm packages installed on the system - use with caution | Example | |
rpm -Vp package.rpm | verify a rpm package not yet installed | Example | |
rpm2cpio package.rpm | cpio -extract -make-directories *bin* | extract executable file from a rpm package | Example | |
rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm | install a package built from a rpm source | Example | |
rpmbuild -rebuild package_name.src.rpm | build a rpm package from a rpm source | Example | |
YUM packages updater - Fedora, RedHat and like | |||
yum install package_name | download and install a rpm package | Example | |
yum update | update all rpm packages installed on the system | Example | |
yum update package_name | upgrade a rpm package | Example | |
yum remove package_name | remove a rpm package | Example | |
yum list | list all packages installed on the system | Example | |
yum search package_name | find a package on rpm repository | Example | |
yum clean packages | clean up rpm cache erasing downloaded packages | Example | |
yum clean headers | remove all files headers that the system uses to resolve dependency | Example | |
yum clean all | remove from the cache packages and headers files | Example | |
DEB packages - Debian, Ubuntu and like | |||
dpkg -i package.deb | install / upgrade a deb package | Example | |
dpkg -r package_name | remove a deb package from the system | Example | |
dpkg -l | show all deb packages installed on the system | Example | |
dpkg -l | grep httpd | show all rpm packageswith the name httpd"" | Example | |
dpkg -s package_name | obtain information on a specific package installed on system | Example | |
dpkg -L package_name | show list of files provided by a package installed on system | Example | |
dpkg -contents package.deb | show list of files provided by a package not yet installed | Example | |
dpkg -S /bin/ping | verify which package belongs to a given file | Example | |
APT packages updater - Debian, Ubuntu e like | |||
apt-get install package_name | install / upgrade a deb package | Example | |
apt-cdrom install package_name | install / upgrade a deb package from cdrom | Example | |
apt-get update | update all deb packages installed on system | Example | |
apt-get remove package_name | remove a deb package from system | Example | |
apt-get check | verify correct resolution of dependencies | Example | |
apt-get clean | clean up cache from packages downloaded | Example | |
View file content | |||
cat file1 | view the contents of a file starting from the first row | Example | |
tac file1 | view the contents of a file starting from the last line | Example | |
more file1 | view content of a file along | Example | |
less file1 | similar to 'more' command but which allows backward movement in the file as well as forwardmovement | Example | |
head -2 file1 | view first two lines of a file | Example | |
tail -2 file1 | view last two lines of a file | Example | |
tail -f /var/log/messages | view in real time what is added to a file | Example | |
Text Manipulation | |||
cat file_test | [operation: sed, grep, awk, grep, etc] > result.txt | syntax to elaborate the text of a file, and write result to a new file | Example | |
cat file_originale | [operazione: sed, grep, awk, grep, etc] >> result.txt | syntax to elaborate the text of a file and append result onto existing file | Example | |
grep Aug /var/log/messages | look up words Aug" in the file onto 'messages'" | Example | |
grep ^Aug /var/log/messages | look up words that begin with Aug" onto file 'messages'" | Example | |
grep [0-9] /var/log/messages | select from file 'messages' all lines that contain numbers | Example | |
grep Aug -R /var/log/* | search string Aug" at directory '/var/log' and below" | Example | |
sed 's/stringa1/stringa2/g' example.txt | replace string1" with "string2" onto example.txt" | Example | |
sed '/^$/d' example.txt | remove all blank lines from example.txt | Example | |
sed '/ *#/d; /^$/d' example.txt | remove comments andblank lines from example.txt | Example | |
echo 'esempio' | tr '[:lower:]' '[:upper:]' | convert from lower case in upper case | Example | |
sed -e '1d' result.txt | eliminates the first line from file example.txt | Example | |
sed -n '/stringa1/p' | view only lines that contain the word string1"" | Example | |
sed -e 's/ *$//' example.txt | remove empty characters at the end of each row | Example | |
sed -e 's/stringa1//g' example.txt | remove only the word string1" from text and leave intact all" | Example | |
sed -n '1,5p;5q' example.txt | view from 1th to 5th row | Example | |
sed -n '5p;5q' example.txt | view row number 5 | Example | |
sed -e 's/00*/0/g' example.txt | replace more zeros with a single zero | Example | |
cat -n file1 | number row of a file | Example | |
cat example.txt | awk 'NR%2==1' | remove all lines even from examplet.xt | Example | |
echo a b c | awk '{print $1}' | view the first column of line | Example | |
echo a b c | awk '{print $1,$3}' | view the first and third column of line | Example | |
paste file1 file2 | merging contents of two files for columns | Example | |
paste -d '+' file1 file2 | merging contents of two files for columns with '+' delimiter on the center | Example | |
sort file1 file2 | sort contents of two files | Example | |
sort file1 file2 | uniq | sort contents of two files omitting lines repeated | Example | |
sort file1 file2 | uniq -u | sort contents of two files by viewing only unique line | Example | |
sort file1 file2 | uniq -d | sort contents of two files by viewing only duplicate line | Example | |
comm -1 file1 file2 | compare contents of two files by deleting only unique lines from 'file1' | Example | |
comm -2 file1 file2 | compare contents of two files by deleting only unique lines from 'file2' | Example | |
comm -3 file1 file2 | compare contents of two files by deleting only the lines that appear on both files | Example | |
Character set and Format file conversion | |||
dos2unix filedos.txt fileunix.txt | convert a text file format from MSDOS to UNIX | Example | |
unix2dos fileunix.txt filedos.txt | convert a text file format from UNIX to MSDOS | Example | |
recode ..HTML < page.txt > page.html | convert a text file to html | Example | |
recode -l | more | show all available formats conversion | Example | |
Filesystem Analysis | |||
badblocks -v /dev/hda1 | check bad blocks onto disk hda1 | Example | |
fsck /dev/hda1 | repair / check integrity of linux filesystem on disk hda1 | Example | |
fsck.ext2 /dev/hda1 | repair / check integrity of ext2 filesystem on disk hda1 | Example | |
e2fsck /dev/hda1 | repair / check integrity of ext2 filesystem on disk hda1 | Example | |
e2fsck -j /dev/hda1 | repair / check integrity of ext3 filesystem on disk hda1 | Example | |
fsck.ext3 /dev/hda1 | repair / check integrity of ext3 filesystem on disk hda1 | Example | |
fsck.vfat /dev/hda1 | repair / check integrity of fat filesystem on disk hda1 | Example | |
fsck.msdos /dev/hda1 | repair / check integrity of dos filesystem on disk hda1 | Example | |
dosfsck /dev/hda1 | repair / check integrity of dos filesystems on disk hda1 | Example | |
Format a Filesystem | |||
mkfs /dev/hda1 | create a filesystem type linux on hda1 partition | Example | |
mke2fs /dev/hda1 | create a filesystem type linux ext2 on hda1 partition | Example | |
mke2fs -j /dev/hda1 | create a filesystem type linux ext3 (journal) on hda1 partition | Example | |
mkfs -t vfat 32 F /dev/hda1 | create a FAT32 filesystem | Example | |
fdformat -n /dev/fd0 | format a floppy disk | Example | |
mkswap /dev/hda3 | create a swap filesystem | Example | |
SWAP filesystem | |||
mkswap /dev/hda3 | create a swap filesystem | Example | |
swapon /dev/hda3 | activating a new swap partition | Example | |
swapon /dev/hda2 /dev/hdb3 | activate two swap partitions | Example | |
Backup | |||
dump -0aj f /tmp/home0.bak /home | make a full backup of directory '/home' | Example | |
dump -1aj f /tmp/home0.bak /home | make a incremental backup of directory '/home' | Example | |
restore -if /tmp/home0.bak | restoring a backup interactively | Example | |
rsync -rogpav delete /home /tmp | synchronization between directories | Example | |
rsync -rogpav e ssh delete /home ip_address:/tmp | rsync via SSH tunnel | Example | |
rsync -az e ssh delete ip_addr:/home/public /home/local | synchronize a local directory with a remote directory via ssh and compression | Example | |
rsync -az -e ssh -delete /home/local ip_addr:/home/public | synchronize a remote directory with a local directory via ssh and compression | Example | |
dd bs=1M if=/dev/hda | gzip | ssh user@ip_addr 'dd of=hda.gz' | make a backup of a local hard disk on remote host via sh | Example | |
tar -Puf backup.tar /home/user | make a incremental backup of directory '/home/user' | Example | |
( cd /tmp/local/ && tar c . ) | ssh -C user@ip_addr 'cd /home/share/ && tar x -p' | copy content of a directory on remote directory via ssh | Example | |
( tar c /home ) | ssh -C user@ip_addr 'cd /home/backup-home && tar x p' | copy a local directory on remote directory via ssh | Example | |
tar cf - . | (cd /tmp/backup ; tar xf ) | local copy preserving permits and links from a directoryto another | Example | |
find /home/user1 -name '*.txt' | xargs cp -av --target-directory=/home/backup/ parents | find and copy all files with '.txt' extention from a directory to another | Example | |
find /var/log -name '*.log' | tar cv -filesfrom= | bzip2 > log.tar.bz2 | find all files with '.log' extention and make an bzip archive | Example | |
dd if=/dev/hda of=/dev/fd0 bs=512 count=1 | make a copy of MBR (Master Boot Record) to floppy | Example | |
dd if=/dev/fd0 of=/dev/hda bs=512 count=1 | restore MBR from backup copy saved to floppy | Example | |
CDROM | |||
cdrecord -v gracetime=2 dev=/dev/cdrom -eject blank=fast -force | clean a rewritable cdrom | Example | |
mkisofs /dev/cdrom > cd.iso | create an iso image of cdrom on disk | Example | |
mkisofs /dev/cdrom | gzip > cd_iso.gz | create a compressed iso image of cdrom on disk | Example | |
mkisofs -J -allowleadingdots -R -V Label CD" -iso-level 4 -o ./cd.iso data_cd " | create an iso image of a directory | Example | |
cdrecord -v dev=/dev/cdrom cd.iso | burn an ISO image | Example | |
gzip -dc cd_iso.gz | cdrecord dev=/dev/cdrom | burn a compressed ISO image | Example | |
mount -o loop cd.iso /mnt/iso | mount an ISO image | Example | |
cd-paranoia B | rip audio tracks from a CD to wav files | Example | |
cd-paranoia 3" " | rip first three audio tracks froma CD to wav files | Example | |
cdrecord -scanbus | scan bus to identify the channel scsi | Example | |
Networking - LAN and WiFi | |||
ifconfig eth0 | show configuration ofan ethernet network card | Example | |
ifup eth0 | activate an interface 'eth0' | Example | |
ifdown eth0 | disable an interface 'eth0' | Example | |
ifconfig eth0 192.168.1.1 netmask 255.255.255.0 | configure IP Address | Example | |
ifconfig eth0 promisc | configure 'eth0' inpromiscuous mode to gather packets (sniffing) | Example | |
dhclient eth0 | active interface 'eth0' in dhcp mode | Example | |
route -n | show routing table | Example | |
route add -net 0/0 gw IP_Gateway | configura default gateway | Example | |
route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1 | configure static route to reach network '192.168.0.0/16' | Example | |
route del 0/0 gw IP_gateway | remove static route | Example | |
echo 1" > /proc/sys/net/ipv4/ip_forward " | activate ip routing | Example | |
hostname | show hostname | Example | |
host linuxtutorials.net | lookup hostname to resolve name to ip addressand viceversa | Example | |
ip link show | show link status of all interfaces | Example | |
mii-tool eth0 | show link status of 'eth0' | Example | |
ethtool eth0 | show statistics of network card 'eth0' | Example | |
netstat -tup | show all active network connections and their PID | Example | |
netstat -tupl | show all network services listening on the system and their PID | Example | |
tcpdump tcp port 80 | show all HTTP traffic | Example | |
iwlist scan | show wireless networks | Example | |
iwconfig eth1 | show configuration of a wireless network card | Example | |
Microsoft Windows networks - SAMBA | |||
nbtscan ip_addr | netbios name resolution | Example | |
nmblookup -A ip_addr | netbios name resolution | Example | |
smbclient -L ip_addr/hostname | show remote shares of a windows host | Example | |
smbget -Rr smb://ip_addr/share | like wget can download files from a host windows via smb | Example | |
mount -t smbfs o username=user,password=pass //winclient/share /mnt/share | mount a windows network share | Example | |
IPTABLES - firewall | |||
iptables -t filter L | show all chains of filtering table | Example | |
iptables -t nat L | show all chains of nat table | Example | |
iptables -t filter F | clear all rules from filtering table | Example | |
iptables -t nat F | clear all rules from table nat | Example | |
iptables -t filter X | delete any chains created by user | Example | |
iptables -t filter -A INPUT -p tcp -dport telnet -j ACCEPT | allow telnet connections to input | Example | |
iptables -t filter -A OUTPUT -p tcp -dport http -j DROP | block HTTP connections to output | Example | |
iptables -t filter -A FORWARD -p tcp -dport pop3 -j ACCEPT | allow POP3 connections to forward chain | Example | |
iptables -t filter -A INPUT -j LOG -logprefix DROP INPUT" " | logging sulla chain di input Logging on chain input | Example | |
iptables -t nat A POSTROUTING o eth0 j MASQUERADE | configure a PAT (Port Address Traslation) on eth0 masking outbound packets | Example | |
iptables -t nat A PREROUTING d 192.168.0.1 p tcp -m tcp -dport 22 -j DNAT -todestination 10.0.0.2:22 | redirect packets addressed to a host to another host | Example | |
Monitoring and debugging | |||
top | display linux tasks using most cpu | Example | |
ps -eafw | displays linux tasks | Example | |
ps -e o pid,args forest | displays linux tasks in a hierarchical mode | Example | |
pstree | mostra un albero dei processi sistema Shows a tree system processes | Example | |
kill -9 ID_Processo | force closure of the process and finish it | Example | |
kill -1 ID_Processo | force a process to reload configuration | Example | |
lsof -p $$ | display a list of files opened by processes | Example | |
lsof /home/user1 | displays a list of open files in a given path system | Example | |
strace -c ls >/dev/null | display system calls made and received by a process | Example | |
strace -f e open ls >/dev/null | display library calls | Example | |
watch -n1 'cat /proc/interrupts' | display interrupts in real-time | Example | |
last reboot | show history reboot | Example | |
lsmod | display kernel loaded | Example | |
free -m | displays status of RAM in megabytes | Example | |
smartctl -A /dev/hda | monitoring reliability of a hard-disk through SMART | Example | |
smartctl -i /dev/hda | check if SMART is active on a hard-disk | Example | |
tail /var/log/dmesg | show events inherent to the process of booting kernel | Example | |
tail /var/log/messages | show system events | Example | |
Other useful commands | |||
apropos …keyword | display a list of commands that pertainto keywords of a program , useful when youknow what your program does, but you don't know the name of the command | Example | |
man ping | display the on-line manual pages for example on ping command | Example | |
whatis …keyword | displays description of what a program does | Example | |
mkbootdisk -device /dev/fd0 `uname r` | create a boot floppy | Example | |
gpg -c file1 | encrypt a file with GNU Privacy Guard | Example | |
gpg file1.gpg | decrypt a file with GNU Privacy Guard | Example | |
wget -r www.example.com | download an entire web site | Example | |
wget -c www.example.com/file.iso | download a file with the ability to stop the download and resume later | Example | |
echo 'wget -c www.example.com/files.iso' | at 09:00 | start a download at any given time | Example | |
ldd ssh | show shared libraries required by ssh program | Example | |
alias hh='history' | set an alias for a command - hh = history | Example | |
$ ip a | Show current IP address | Check the Current IP Address |
Subscribe
0 Comments