1. SYSTEM INFORMATION
    1. Display Linux system information
      1. # uname -a
    2. Display kernel release information
      1. # uname -r
    3. Show how long the system has been running + load
      1. # uptime
    4. Show system host name
      1. # hostname
    5. Show system reboot history
      1. # last reboot
    6. Display who is online
      1. # w
    7. Who you are logged in as
      1. # whoami
  2. HARDWARE INFORMATION
    1. Display messages in kernel ring buffer
      1. # dmesg
    2. Display CPU information
      1. # cat /proc/cpuinfo
    3. Display memory information
      1. # cat /proc/meminfo
    4. Display free and used memory (-h for human readable, -m for MB, -g for GB.)
      1. # free -h
    5. Display DMI/SMBIOS (hardware info) from the BIOS
      1. # dmidecode
  3. PERFORMANCE MONITORING AND STATISTICS
    1. Display and manage the top processes
      1. # top
    2. Display processor related statistics
      1. # mpstat 1
    3. Display virtual memory statistics
      1. # vmstat 1
    4. Display the last 100 syslog messages (Use /var/log/syslog for Debian based systems.)
      1. # tail 100 /var/log/messages
    5. Capture and display all packets on interface eth0
      1. # tcpdump -i eth0
    6. Monitor all traffic on port 80 ( HTTP )
      1. # tcpdump -i eth0 port 80
    7. Execute "df -h", showing periodic updates
      1. # watch df –h
  4. USER INFORMATION AND MANAGEMENT
    1. Display the user and group ids of your current user.
      1. # id
    2. Display the last users who have logged onto the system.
      1. # last
    3. Show who is logged in and what they are doing (w or who).
      1. # w
    4. Create a group named "test"
      1. # groupadd test
    5. Create an account named john, with a comment of "John Smith" and create the user's home directory
      1. # useradd -c "John Smith" -m john
    6. Delete the john account
      1. # userdel john
    7. Add the john account to the sales group
      1. # usermod -aG sales john
  5. FILE AND DIRECTORY COMMANDS
    1. List all files in a long listing (detailed) format
      1. # ls –al
    2. Display the present working directory
      1. # pwd
    3. Create a directory
      1. # mkdir directory
    4. Remove (delete) file
      1. # rm file
    5. Remove the directory and its contents recursively
      1. # rm -r directory
    6. Force removal of file without prompting for confirmation
      1. # rm -f file
    7. Forcefully remove directory recursively
      1. # rm -rf directory
    8. Copy file1 to file2
      1. # cp file1 file2
    9. Copy source_directory recursively to destination. If destination exists, copy source_directory into destination, otherwise create destination with the contents of source_directory
      1. # cp -r source_directory destination
    10. Rename or move file1 to file2. If file2 is an existing directory, move file1 into directory file2
      1. # mv file1 file2
    11. Create symbolic link to linkname
      1. # ln -s /path/to/file linkname
    12. Create an empty file or update the access and modification times of file
      1. # touch file
    13. View the contents of file
      1. # cat file
    14. Browse through a text file
      1. # less file
    15. Display the first 10 lines of file
      1. # head file
    16. Display the last 10 lines of file
      1. # tail file
    17. Display the last 10 lines of file and "follow" the file as it grows
      1. # tail –f file
  6. PROCESS MANAGEMENT
    1. Display your currently running processes
      1. # ps
    2. Display all the currently running processes on the system
      1. # ps -ef
    3. Display and manage the top processes
      1. # top
    4. Kill process with process ID of pid
      1. # kill <PID>
    5. Kill all processes named processname
      1. # kill <process name>
    6. Start program/script in the background
      1. # <program name>&
    7. Display stopped or background jobs
      1. # bg
    8. Brings the most recent background job to foreground
      1. # fg
    9. Brings job n to the foreground
      1. # fg n
  7. FILE PERMISSIONS
    1. Linux chmod example
      1. PERMISSION
        1. rwx rwx rwx
          1. # chmod 777 filename
        2. rwx rwx r-x
          1. # chmod 775 filename
        3. rwx r-x r-x
          1. # chmod 755 filename
        4. rw- rw- r--
          1. # chmod 664 filename
        5. rw- r-- r--
          1. # chmod 644 filename
      2. LEGEND
        1. u= User
        2. g= Group
        3. o= Others
        4. r = Read
        5. w = write
        6. x = execute
        7. s = setuid
        8. - = no access
  8. NETWORKING
    1. Display all network interfaces and ip address
      1. # ifconfig -a
    2. Display eth0 address and details
      1. # ifconfig <eth0>
    3. Query or control network driver and hardware settings
      1. # ethtool <eth0>
    4. Send ICMP echo request to host
      1. # ping <host-ip>
    5. Display whois information for domain
      1. # whois <domain>
    6. Display DNS information for domain
      1. # dig <domain>
    7. Reverse lookup of IP_ADDRESS
      1. # dig -x <IP_ADDRESS>
    8. Display DNS ip address for domain
      1. # host <domain>
    9. Display the network address of the host name
      1. # hostname -i
    10. Download http://domain.com/file
      1. # wget http://domain.com/file
    11. Display listening tcp and udp ports and corresponding programs
      1. # netstat -nutlp
  9. EDITING THE FILES
    1. To enter vi, nano and editi file
      1. # vi filename <Return>
        1. - To enter insert mode, use: i key or Ins Key. - Type in the text. - To leave insert mode and return to command mode, press: <Esc> - In command mode, save changes and exit vi by typing: :wq <Return> You are back at the Unix prompt. - To exit without saving changes, use :q. To override changes and exit without saving, use :q!
      2. # nano filename
  10. DIRECTORY NAVIGATION
    1. To go up one level of the directory tree (Change into the parent directory.)
      1. # cd ..
    2. Go to the $HOME directory
      1. # cd ~/
    3. Change to the /etc directory
      1. # cd /etc
  11. DISK USAGE
    1. Show free and used space on mounted filesystems
      1. # df -h
    2. Show free and used inodes on mounted filesystems
      1. # df -i
    3. Display disks partitions sizes and types
      1. # fdisk -l
    4. Display disk usage for all files and directories in human readable format
      1. # du -ah
    5. Display total disk usage off the current directory
      1. # du -sh
  12. FILE TRANSFERS
    1. Secure copy file.txt to the /tmp folder on server
      1. # scp file.txt server:/tmp
    2. Copy *.html files from server to the local /tmp folder.
      1. # scp server:/var/www/*.html /tmp
    3. Copy all files and directories recursively from server to the current system's /tmp folder.
      1. # scp -r server:/var/www /tmp
    4. Synchronize /home to /backups/home
      1. # rsync -a /home /backups/
    5. Synchronize files/directories between the local and remote system with
      1. # rsync -avz /home server:/backups/
  13. SSH LOGINS
    1. Connect to host as your local username
      1. # ssh host
    2. Connect to host as user
      1. # ssh user@host
    3. Connect to host using port
      1. # ssh -p port user@host
  14. SEARCH
    1. Search for pattern in file
      1. # grep pattern file
    2. Search recursively for pattern in directory
      1. # grep -r pattern directory
    3. Find files and directories by name
      1. # locate name
    4. Find files in /home/john that start with "prefix"
      1. # find /home/john -name 'prefix*'
    5. Find files larger than 100MB in /home
      1. # find /home -size +100M
  15. INSTALLING PACKAGES
    1. (RPM based distributions)
      1. Search for a package by keyword
        1. # yum search keyword
      2. Install package
        1. # yum install package
      3. Display description and summary information about package
        1. # yum info package_name
      4. Install package from local file named package.rpm
        1. # rpm -i package.rpm
      5. Remove/uninstall package
        1. # yum remove package
      6. Install software from source code
        1. # tar zxvf sourcecode.tar.gz # cd sourcecode #./configure # make # make install
    2. (DPM based distributions)
      1. Search for a package by keyword
        1. # apt-cache search keyword
      2. Install package
        1. # apt install package_name
      3. Display description and summary information about package
        1. # apt show package_name
      4. Remove/uninstall package
        1. # apt remove --purge package_name
      5. Install software from source code
        1. # dpkg -i <package_name.deb>
  16. ARCHIVES (TAR FILES)
    1. Create tar named archive.tar containing directory
      1. # tar cf archive.tar directory
    2. Extract the contents from archive.tar
      1. # tar xf archive.tar
    3. Create a gzip compressed tar file name archive.tar.gz
      1. # tar czf archive.tar.gz directory
    4. Extract a gzip compressed tar file
      1. # tar xzf archive.tar.gz
    5. Create a tar file with bzip2 compression
      1. # tar cjf archive.tar.bz2 directory
    6. Extract a bzip2 compressed tar file
      1. # tar xjf archive.tar.bz2
  17. Created by @0xCyberY