400-commands-for-GNU-Linux-1

To perform different tasks on your computer it is important to use tools, for this reason, know more than 400 commands for GNU/Linux.

Introduction: Learn more than 400 commands for GNU/Linux

If you want to carry out tasks with your computer, you should know that there are currently more than 400 commands that can help you with this, and even make the process easier. Of course, each of them fulfills a specific function.

The list that we will show you today is established by the Group of Users of Free Technologies of Cuba or also known by its acronym as GUTL. What guarantees good information, and interesting programming data.

Next, we leave you the list of more than 400 commands that you can use to carry out your tasks correctly, in addition, each of them is organized according to the area of ​​interest.

System information

  • file: To show the entire architecture of the machine.
  • join me -m: Shows the architecture of the machine.
  • join me -r: Shows you the kernel version being used.
  • join me -a: Meystra all the complete information.
  • lsb_release -a: Shows the complete information of the distribution.
  • cat/etc/issue: Shows you the name of the distribution.
  • dmidecode -q: It is to show all the components of the system, in this case hardware.
  • hdparm -i /dev/hda: Shows the characteristics of a hard drive.
  • hdparm -tT /dev/sda: It works specifically to test read on a hard drive.
  • cat /proc/cpuinfo: It shows you the CPU information.
  • grep -c ^processor /proc/cpuinfo: Shows the number of processors.
  • cat /proc/interrupts: Show interruptions.
  • cat /proc/meminfo: To check memory usage.
  • cat /proc/swaps: Show swap files.
  • cat /proc/version: Show kernel version.
  • cat /proc/net/dev: Teaches network adapters and statistics.
  • cat /proc/mounts: Shows the mounted filesystem.
  • iscpu: It shows you information about the microprocessor.
  • Ispci-tv: Shows the different PCI devices.
  • lsusb -tv: It shows you the devices connected to USB.
  • etc: Place the list of hardware.
  • discover: It works the same as the previous one.
  • at your place: It shows you the system date.
  • cal 2011: He shows you the almanac for the year 2011.
  • cal 07 2011: It shows you the calendar for the month of July of the year 2011.
  • date 041217002011.00: It writes the date and time, and even allows you to adjust them.
  • clock -w: Save the date modifications in the BIOS.
  • BLKI: Displays all the information of the block devices, including their names, labels, UUID, partition type, etc.

Commands to shutdown, reboot, or log off

  • shutdown-h now: To turn off the system.
  • init 0: It also works to turn off the system.
  • telinit 0: Same as above.
  • stop: To turn off the system.
  • power off: Another command to shut down the system.
  • shutdown -h hours: minutes &: Planned shutdown of the system.
  • shutdown -c: Abort or cancel a previously scheduled system shutdown.
  • shutdown -r now: Reboot the system (1).
  • reboot: The same as the previous.
  • logout: Sign off.
  • skill username: Likewise, to log out
  • exit: To exit the shell. In case there is only one, it works the same to log out.

Manage files and directories

  • CD: Command to go to home directory.
  • cd /home: change to directory "/home".
  • Cd ..: Go back one level.
  • cd ../ ..:Go back two levels.
  • cd ~user1: To go to the directory user1.
  • cd -: To return to the previous directory.
  • pwd: Show the path of the current directory.
  • ls: Display a list of the contents of a directory.
  • ls -F: List the contents of a directory.
  • ls -l: List the contents of a directory, showing every detail.
  • ls -lh: List the contents of a directory, showing the details, including the size in a format known as humanized.
  • ls -a: List the contents of a directory, including hidden files.
  • ls[0-9]: Sort files and folders that contain numbers.
  • ls-laR | less: Recursively list the contents of the current directory and all subdirectories and files, including hidden ones that are separated by page.
  • tree: It shows you the files and folders in the form of a tree starting from the root.
  • lstree: It works the same as the previous one.
  • 17.mkdir dir1: Create a directory named 'dir1'.
  • mkdir dir1 dir2: Create two directories at once.
  • mkdir -p / tmp / dir1 / dir2: Create a directory structure, if it does not exist.
  • rm file1: Delete the file 'file1'.
  • rm -f file1: Delete the file 'file1' forcefully.
  • rmdir dir1: Delete the directory 'dir1'.
  • rm -rf dir1: Delete recursively and in forced mode the directory 'dir1' with everything it contains.
  • rm -rf dir1 dir2: Delete two directories with their content recursively.
  • mv dir1 new_dir: Rename or move a file or folder.
  • cp file1 destination/: Copy a file to the chosen destination.
  • cp file1 file2 destination/: Copy two files to the same directory at the same time.
  • cp file1 file2: Copy file1 to file2.
  • cp dir / .: Copy all files from a directory into the working directory
    figure.
  • cp -a / tmp / dir1.: Copy a directory within the current working directory.
  • cp -a dir1: Copy a directory.
  • cp -a dir1 dir2: Copy two directories at once.
  • ln -s file1 LNK1: Create a symbolic link to the file or directory.
  • ln file1 lnk1: Create a hard link to the file or directory.
  • touch file1: Update file1's modification date, or create it if it doesn't exist.
  • touch -t 0712250000 file1: Modify the real time (creation time) of a file or directory.
  • file file1: Output of the mime type of a text file.
  • iconv -l: Lists of known ciphers.
  • iconv -f fromEncoding -t toEncoding inputFile > outputFile: Create a new shape from the input file assuming it is encoded in fromEncoding and converting it to ToEncoding.

Find files

  • find / -name file1: Allows you to search for files and directories from the root of the system.
  • find / -user user1: To search for files and directories that are part of the user 'user1'.
  • find / home / user1 -name \ *. bin: Search for files with extension '. bin' inside the '/home/user1' directory.
  • find / usr / bin -type f -atime +100: Search for binary files that have not been used 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 with '.rpm' extension and change the permissions.
  • find / -xdev -name \ *. rpm: Search for files with '.rpm' extension ignoring removable devices such as cdrom, pen-drive, etc. ...
  • locate \ *. ps: Find all files with '.ps' extension executed with the 'updatedb' command.
  • where's halt: Shows you the location of a binary, help or source file.
  • which stops: Shows you the full path to an executable binary.

Mounting a filesystem

  • mount / dev / hda2 / mnt / hda2: Mount a disk called hda2. But, first you need to check that the '/mnt/hda2' directory exists; and, in case it is not there, it is important to create it.
  • umount / dev / hda2: Unmount a disk named hda2. Exit first from point '/mnt/hda2.
  • fuser -km / mnt / hda2: Force unmount when device is busy.
  • umount -n / mnt / hda2: Run the unmount without reading the /etc/mtab file. This command is widely used, especially when the hard drive has no more storage space, or when the file is read-only.
  • mount / dev / fd0 / mnt / floppy: Mount a floppy disk.
  • mount / dev / cdrom / mnt / cdrom: To mount a cdrom / dvdrom.
  • mount / dev / hdc / mnt / cdrecorder: Mount a rewritable cd or a dvdrom.
  • mount / dev / hdb / mnt / cdrecorder: Mount a rewritable cd / dvdrom (a dvd).
  • mount -o loop file.iso / mnt / cdrom: Mount a file or an iso image.
  • mount -t vfat / dev / hda5 / mnt / hda5: Mount a FAT32 file system.
  • mount / dev / sda1 / mnt / usbdisk: Mount a usb pen-drive or memory.

Disk space

  • df -h: Display a list of mounted partitions.
  • ls -lSr | more: Shows you the size of the files and directories ordered by size.
  • du -sh dir1: Helps you estimate the space used by the 'dir1' directory.
  • du sk * | sort -rn: Shows the size of files and directories ordered by size.
  • rpm -q -a –qf '% 10 {SIZE} t% {NAME} n' | sort -k1,1n: Shows the space used by installed rpm packages organized by size
  • dpkg-query -W -f = '$ {Installed-Size; 10} t $ {Package} n' | sort -k1,1n: Shows the space used by installed packages, organized by size.

Users and Groups

  • groupadd group_name: Create a new group.
  • groupdel group_name: Delete a group.
  • groupmod -n new_group_name old_group_name: Rename a group.
  • useradd -c “Name Surname” -g admin -d / home / user1 -s / bin / bash user1: Create a new user belonging to the group "admin".
  • user add user1: Create a new user.
  • userdel -r user1: Delete a user ('-r' removes the Home directory).
  • usermod -c “User FTP” -g system -d /ftp/user1 -s /bin/nologin user1: Change user attributes.
  • Passwd: To change the password.
  • password user1: Change the password of a user, only by root.
  • change -E 2011-12-31 user1: Set a term for the user's password. This example refers to the fact that the key expires on December 31, 2011.
  • pwck: Check the correct syntax, the file format of '/etc/passwd' and the existence of users.
  • grpck: Check the correct syntax and format of the '/etc/group' file and the existence of groups.
  • newgrp group_name: Register a new group to change the default of newly created files.

File Permissions (Use + to add permissions and – to remove)

  • ls -lh: Show permissions.
  • ls / tmp | pr -T5 -W $ COLUMNS: Split the terminal into five columns.
  • chmod ugo + rwx directory1: Add read ®, write (w) and execute(x) permissions to owner (u), group (g) and others (o) on directory 'directory1'.
  • chmod go-rwx directory1: Remove permission to read ®, write (w) and (x) execute to the group (g) and others (o) on the directory 'directory1'.
  • chown user1 file1: Change the owner of a file.
  • chown -R user1 directory1: Change the owner of a directory, that of all the files and of the directories that are inside.
  • chgrp group1 file1: Change group of files.
  • chown user1: group1 file1: Change user and group owner of a file.
  • find / -perm -u + s: View all system files with SUID configured.
  • chmod u + s / bin / file1: Set the SUID bit in a binary file. The user who is modifying that file has the same opportunities as the owner.
  • chmod us / bin / file1: Disable the SUID bit in a binary file.
  • chmod g + s / home / public: Set an SGID bit in a directory. Similar to SUID but per directory.
  • chmod gs / home / public: Disable an SGID bit on a directory.
  • chmod o + t / home / public: Put a STIKY bit in a directory. Allows file deletion only to legitimate owners.
  • chmod ot / home / public: Disable a STIKY bit on a directory.

Special attributes on files (Use + to add permissions and – to remove)

  • chattr + to file1: Allows you to write by opening a file only append mode.
  • chattr + c file1: Converts a file to compressed or decompressed automatically.
  • chattr + d file1: Ensures that the program does not delete any of the files while performing the backup.
  • chattr + i file1: Makes the file invariable, so it cannot be deleted, altered, renamed, or linked.
  • chattr + s file1: Allows a file to be safely and safely deleted.
  • chattr + S file1: Ensures that a file is modified, the changes are written in synchronous mode as with sync.
  • chattr + u file1: Allows you to recover the content of a file, even if it is cancelled.
  • lsattr: Teaches you all special attributes.

Archives and compressed files

  • bunzip2 file1.bz2: Unzip a file called 'file1.bz2'.
  • bzip2 file1: Compresses a file named 'file1'.
  • Gunzip File1.gz: Unzip a file called 'file1.gz'.
  • gzip file1: Compresses a file named 'file1'.
  • gzip -9 file1: Compresses with maximum compression.
  • rar to file1.rar test_file: Create a rar file called 'file1.rar'.
  • rar to file1.rar file1 file2 dir1: Compress 'file1', 'file2' and 'dir1' simultaneously.
  • rar x file1.rar: Unzip rar file.
  • UNRAR X FILE1.RAR: Unzip rar file.
  • tar -cvf archive.tar file1: Create an uncompressed tarball.
  • tar -cvf archive.tar file1 file2 dir1: Create a file containing 'file1', 'file2' and 'dir1'.
  • tar tf archive.tar: Shows you the contents of a file.
  • tar -xvf archive.tar: Helps you extract a tarball.
  • tar -xvf archive.tar -C / tmp: To extract a tarball into /tmp.
  • tar -cvfj archive.tar.bz2 dir1: Create a compressed tarball inside bzip2.
  • -xvfj tar archive.tar.bz2: Uncompress a bzip2 compressed tar file
  • tar -cvfz archive.tar.gz dir1: Create a gzipped tarball.
  • tar -xvfz archive.tar.gz: Uncompress a gzip-compressed tar file.
  • zip file1.zip file1: Create a zipped file.
  • zip -r file1.zip file1 file2 dir1: Compress in zip, several files and directories simultaneously.
  • unzip file1.zip: Unzip a zip file.

RPM packages (Red Hat, Fedora, and the like)

  • rpm ivh package.rpm: Install an rpm package.
  • rpm -ivh –nodeeps package.rpm: Install an rpm package, regardless of dependency requests.
  • rpm -U package.rpm: Update a rpm package without modifying the configuration files.
  • rpm -F package.rpm: Update an rpm package only if it is installed.
  • rpm -e package_name.rpm: Remove an rpm package.
  • rpm -qa: Show all rpm packages installed on the system.
  • rpm -qa | grep httpd: List all rpm packages with the name “httpd”.
  • rpm -qi package_name: Get information on a specific installed package.
  • rpm -qg "System Environment / Daemons": Show the rpm packages of a software group.
  • rpm -ql package_name: Show list of files given by an installed rpm package.
  • rpm -qc package_name: Show list of configuration files given by an installed rpm package.
  • rpm -q package_name --whatrequires: Show list of dependencies requested for an rpm package.
  • rpm -q package_name -whatprovides: Display the capacity given by an rpm package.
  • rpm -q package_name --scripts: Show scripts started during install/remove.
  • rpm -q package_name --changelog: Show the revision history of an rpm package.
  • rpm -qf /etc/httpd/conf/httpd.conf: Check which rpm package belongs to a given file.
  • rpm -qp package.rpm -l: Show list of files given by an rpm package that has not been installed yet.
  • rpm –import / media / cdrom / RPM-GPG-KEY: Import the digital signature of the public key.
  • 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, licenses, types, owner, group, MD5 digest check and last modification.
  • rpm -Va: Check all rpm packages installed on the system. Use with care.
  • Vp rpm package.rpm: Check for an rpm package not yet installed.
  • rpm2cpio package.rpm | cpio –extract –make-directories * bin*: Extract executable file from rpm package.
  • rpm -ivh /usr/src/redhat/RPMS/`arch`/package.rpm: Install a package built from rpm source.
  • rpmbuild –rebuild package_name.src.rpm: Build an rpm package from rpm source.

YUM Package Updater (Red Hat, Fedora and the like)

  • yum install package_name: Download and install an rpm package.
  • yum localinstall package_name.rpm: This will install an RPM and try to resolve all dependencies for you, using your repositories.
  • yum update package_name.rpm: update all rpm packages installed on the system.
  • yum update package_name: modernize / update an rpm package.
  • yum remove package_name: remove a rpm package.
  • yum list: list all packages installed on the system.
  • yum search package_name: Find a package in rpm repository.
  • yum clean packages: Clear an rpm cache by deleting downloaded packages.
  • yum clean headers: Remove all header files that the system uses to resolve the dependency.
  • yum clean all: Remove from packages cache and header files.

Deb packages (Debian, Ubuntu and derivatives)

  • dpkg -i package.deb: Install/update a deb package.
  • dpkg -r package_name: Remove a deb package from the system.
  • dpkg -l: Show all deb packages installed on the system.
  • dpkg -l | grep httpd: Show all deb packages with name “httpd”
  • dpkg -s package_name: To get information on a specific package installed on the system.
  • dpkg -L package_name: Display the list of files given by a package installed on the system.
  • dpkg -contents package.deb: To show list of files given by a package not installed yet.
  • dpkg -S / bin / ping: Check the package that belongs to a specific file.

APT Package Updater (Debian, Ubuntu and derivatives)

  • apt-get install package_name: Install/update a deb package.
  • apt-cdrom install package_name: Install/update a deb package from a cdrom.
  • apt-get update: Update the list of packages.
  • apt-get upgrade: update all installed packages.
  • apt-get remove package_name: Remove a deb package from the system.
  • apt get check: Verify the correct resolution of the dependencies.
  • apt-get clean: Clear cache from downloaded packages.
  • apt-cache search searched-package: Returns the list of packages corresponding to the string "searched packages".

View the content of a file

  • cat file1: View the contents of a file starting from the first row.
  • tock file1: View the contents of a file starting from the last line.
  • more file1: View the content throughout a file.
  • less file1: Very similar to the 'more' command, but allows you to save the move to the file, as well as the move backwards.
  • 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: See in real time what is added to a file.

Text manipulation

  • cat file1 file2 .. | command <> file1_in.txt_or_file1_out.txt: General syntax for text manipulation, using PIPE, STDIN and STDOUT.
  • cat file1 | command (sed, grep, awk, grep, etc ...)> result.txt: General syntax for manipulating text from a file and writing the result to a new one.
  • cat file1 | command (sed, grep, awk, grep, etc ...) »result.txt: General syntax for manipulating text from a file and adding output to one that already exists.
  • grep Aug / var / log / messages: Look for words “Aug” in the file '/var/log/messages'.
  • grep ^ Aug / var / log / messages: Search for words beginning with “Aug” in file '/var/log/messages'
  • grep [0-9] / var / log / messages: Select all the lines of the file '/var/log/messages' that contain numbers.
  • grep Aug -R / var / log /*: Look for the string “Aug” in the '/var/log' directory and below.
  • sed 's / stringa1 / stringa2 / g' example.txt: Relocate “string1” with “string2” in example.txt
  • sed '/ ^ $ / d' example.txt: Remove all blank lines from example.txt
  • sed '/ * # / d; / ^ $ / d 'example.txt: Remove comments and blank lines from example.txt
  • echo 'esempio' | tr '[: lower:]' '[: upper:]': Convert lowercase to uppercase.
  • sed -e '1d' result.txt: Deletes the first line of the file example.txt
  • sed -n '/ stringa1 / p': Display only the lines that contain the word “string1”.

Set character and file conversion

  • dos2unix filesos.txt fileunix.txt: Convert a text file format from MSDOS to UNIX.
  • unix2dos fileunix.txt files.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: Show all available format conversions.

File system analysis

  • badblocks -v / dev / hda1: Check for bad blocks on disk hda1.
  • fsck / dev / hda1: Repair / check the integrity of the Linux system file on the hda1 drive.
  • fsck.ext2 / dev / hda1: Repair / check the integrity of the ext 2 file system on the hda1 drive.
  • e2fsck / dev / hda1: Repair / Check the integrity of the ext 2 system file on the hda1 disk.
  • e2fsck -j / dev / hda1: Repair / Verify the integrity of the ext 3 system file on the hda1 drive.
  • fsck.ext3 / dev / hda1: Repair / check the integrity of the ext 3 file system on the hda1 drive.
  • fsck.vfat / dev / hda1: Repair / Check the integrity of the fat system file on the hda1 disk.
  • fsck.msdos / dev / hda1: Repair / check the integrity of a system dos file on disk hda1.
  • dosfsck / dev / hda1: Repair / check the integrity of a system dos file on disk hda1.

Format a filesystem

  • mkfs / dev / hda1: Create a Linux-like system file on partition hda1.
  • mke2fs / dev / hda1: Create a system file like Linux ext 2 on hda1.
  • mke2fs -j / dev / hda1: Create a Linux ext3 (periodic) file system on partition hda1.
  • mkfs -t vfat 32 -F / dev / hda1: Create a FAT32 filesystem on hda1.
  • fdformat -n / dev / fd0: Format a flooply disk.
  • mkswap / dev / hda3: Create a system file swap.

I work with the SWAP

  • mkswap / dev / hda3: Create system file swap.
  • swapon / dev / hda3: Activating a new swap partition.
  • swapon / dev / hda2 / dev / hdb3: Activate two swap partitions.

Saves (Backup)

  • dump -0aj -f /tmp/home0.bak / home: Do a full save of the '/home' directory.
  • dump -1aj -f /tmp/home0.bak / home: Do an incremental save of the '/home' directory.
  • restore -if /tmp/home0.bak: Restore a salvo interactively.
  • rsync -rogpav –delete / home / tmp: Synchronization between directories.
  • rsync -rogpav -e ssh –delete / home ip_address: / tmp: Rsync through the SSH tunnel.
  • rsync -az -e ssh –delete ip_addr: / home / public / home / local: Synchronize a local directory with a remote one via ssh and zip.
  • rsync -az -e ssh –delete / home / local ip_addr: / home / public: Synchronize a remote directory with a local one through ssh and compression.
  • dd bs = 1M if = / dev / hda | gzip | ssh user @ ip_addr 'dd of = hda.gz': Backup a hard drive to a remote host via ssh.
  • dd if = / dev / sda of = / tmp / file1: Save the contents of a hard drive to a file.
  • tar -Puf backup.tar / home / user: Make an incremental save of the '/home/user' directory.
  • (cd / tmp / local / && tar c.) | ssh -C user @ ip_addr 'cd / home / share / && tar x -p': Copy the contents of a directory to a remote one 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 -): Make a local copy keeping the licenses and links from one directory to another.
  • find / home / user1 -name '* .txt' | xargs cp -av –target-directory = / home / backup / –parents: Get and copy all files with '.txt' extension from one directory to another.
  • find / var / log -name '* .log' | tar cv –files-from = - | bzip2> log.tar.bz2: Find all files with '.log' extension and make a bzip file.
  • dd if = / dev / hda of = / dev / fd0 bs = 512 count = 1: Make a copy of the MRB (Master Boot Record) to a floppy disk.
  • dd if = / dev / fd0 of = / dev / hda bs = 512 count = 1: Restore the copy of the MBR (Master Boot Record) saved on a floppy.

CD-ROM

  • cdrecord -v gracetime = 2 dev = / dev / cdrom -eject blank = fast -force: Clean or erase a rewritable cd.
  • mkisofs / dev / cdrom> cd.iso: Create an iso image of cdrom on disk.
  • mkisofs / dev / cdrom | gzip> cd_iso.gz: Create a compressed iso image of cdrom on disk.
  • mkisofs -J -allow-leading-dots -R -V "Label CD" -iso-level 4 -o ./cd.iso data_cd: Create an iso image of a directory.
  • cdrecord -v dev = / dev / cdrom cd.iso: Burn an iso image.
  • gzip -dc cd_iso.gz | cdrecord dev = / dev / cdrom -: Burn a compressed iso image.
  • mount -o loop cd.iso / mnt / iso: Mount an iso image.
  • cd-paranoia -B: Transfer songs from a cd to wav files.
  • cd-paranoia - "-3": Transfer the first 3 songs from a cd to wav files.
  • Cdrecord –Scanbus: Scan bus to identify the scsi channel.
  • dd if = / dev / hdc | md5sum: Run an md5sum on a device, such as a CD.

Work with the NETWORK (LAN and Wi-Fi)

  • ifconfig eth0: Show the configuration of an Ethernet network card.
  • ifup eth0: Activate an 'eth0' interface.
  • ifdown eth0: Disable an 'eth0' interface.
  • ifconfig eth0 192.168.1.1 netmask 255.255.255.0: Set an IP address.
  • ifconfig eth0 promisc: Set 'eth0' to common mode to sniff packets.
  • dhclient eth0: Activate interface 'eth0' in dhcp mode.
  • route: Show traversal table.
  • route add -net 0/0 gw IP_Gateway: Set default input.
  • route add -net 192.168.0.0 netmask 255.255.0.0 gw 192.168.1.1: Configure static route to search for the network '192.168.0.0/16'.
  • route 0/0 gw IP_gateway: Delete the static route.
  • echo "1"> / proc / sys / net / ipv4 / ip_forward: Activate ip traversal.
  • hostname: Display the host name of the system.
  • ip link show: Show the link status of all interfaces.
  • mii-tool eth0: Show the link status of 'eth0'.
  • ethtool eth0: Show the statistics of network card 'eth0'.
  • netstat-tup: Show all active network connections and their PIDs.
  • netstat-tupl: Show all network listening services on the system and their PIDs.
  • tcp dump tcp port 80: Show all HTTP traffic.
  • iwlist scan: Show wireless networks.
  • iwconfig eth1: Show the settings of a wireless network card.

Microsoft Windows Networks (SAMBA)

  • nbtscan ip_addr: bios network name resolution.
  • nmblookup -A ip_addr: bios network name resolution.
  • smbclient -L ip_addr / hostname: Show remote actions of a host in windows.

IP tables (FIREPLACES)

  • iptables -t filter -L: Show all strings in the filter table.
  • iptables -t nat -L: Show all strings in the nat table.
  • iptables -t filter -F: Clear all filter table rules.
  • iptables -t nat -F: Clear all rules from the nat table.
  • iptables -t filter -X: Delete any string created by the user.
  • iptables -t filter -A INPUT -p tcp telnet -j ACCEPT -dport: Allow telnet connections to enter.
  • iptables -t filter -A OUTPUT -p tcp -dport http -j DROP: Block HTTP connections to exit.
  • iptables -t filter -A FORWARD -p tcp –dport pop3 -j ACCEPT: Allow POP connections to a forward chain.
  • iptables -t filter -A INPUT -j LOG --log-prefix “DROP INPUT”: Registering an input string.
  • iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE: Configure a PAT (Port Address Translation) on eth0, hiding forced-out packets.
  • iptables -t nat -A PREROUTING -d 192.168.0.1 -p tcp -m tcp –dport 22 -j DNAT –to-destination 10.0.0.2:22: Redirect packets directed from one host to another.

Monitoring and debugging

  • top: Show linux tasks using most cpu.
  • ps-eafw: Shows Linux tasks.
  • ps -e -o pid, args –forest: Teaches Linux tasks according to their importance.
  • ptree: Shows a process system tree.
  • kill -9 Process_ID: Forces a process to close and terminate it.
  • kill -1 Process_ID: Force a process to reload the configuration.
  • lsof -p $$: Display a list of files opened by processes.
  • lsof / home / user1: Displays a list of open files in a given system path.
  • strace -c ls> / dev / null: Show system calls made and received by a process.
  • strace -f -e open ls> / dev / null: Show the calls to the library.
  • watch -n1 'cat / proc / interrupts': Show interruptions in real time.
  • last reboot: Show reboot history.
  • lsmod: Show the loaded kernel.
  • free -m: Displays the status of RAM in megabytes.
  • smartctl -A / dev / hda: Monitor the reliability of a hard drive through SMART.
  • smartctl -i / dev / hda: Check if SMART is enabled on a hard drive.
  • tail / var / log / dmesg: Show events inherent to the kernel loading process.
  • tail / var / log / messages: Show system events.

Other useful commands

  • apropos ... keyword: To display a list of commands that belong to the keywords of a program. They are widely used when you know the name of the program, but do not have information about the commands.
  • manping: Show the pages of the online manual.
  • whatis… keyword: Shows you the description of what the program does.
  • mkbootdisk –device / dev / fd0 `uname -r`: Create a bootable floppy.
  • gpg -c file1: Encrypt a file with GNU security guard.
  • gpg file1.gpg: Decode a file with GNU Security Guard.
  • wget -r www.example.com: Download an entire website.
  • wget -c www.example.com/file.iso: Download a file with the possibility to pause the download and resume later.
  • echo 'wget -c www.example.com/files.iso' | at 09:00: Start a download at any time. In this case it would start at 9 o'clock.
  • ldd / usr / bin / ssh: Show the shared libraries required by the ssh program.
  • alias hh = 'history': Set an alias for a command –hh= History.
  • chsh: Change the shell command.
  • chsh --list-shells: It is an adequate command to know if you have to do remote in another terminal.
  • WHO -a: Show who is logged in, and print last system import time, dead processes, system log processes, active processes produced by init, current running, and last system clock changes.