General

  • whoami: Displays current username.
  • id: Returns users identity
  • hostname: Sets or prints the name of current host system.
  • uname: Prints basic information about the operating system name and system hardware.
  • pwd: Returns working directory name.
  • ifconfig: The ifconfig utility is used to assign or to view an address to a network interface and/or configure network interface parameters.
  • ip: Ip is a utility to show or manipulate routing, network devices, interfaces and tunnels.
  • netstat: Shows network status.
  • ss: Another utility to investigate sockets.
  • ps: Shows process status.
  • who: Displays who is logged in.
  • env: Prints environment or sets and executes command.
  • lsblk: Lists block devices.
  • lsusb: Lists USB devices
  • lsof: Lists opened files.
  • lspci: Lists PCI devices.
  • ls -d */ | wc -l: count total folders in current directory
  • wc -l access.log: Count total lines in file, for example in file access.log

Useful control combination

  • Control + r: searching command history for commands we run before
  • Control + l: clear the terminal
  • Control + d: send an end of file
  • Control + c: kill a process
  • Control + z: put a process to a sleep

Reading big files

  • more /path/to/file: useful when read big/long file, command more is similar to less.
  • ls
  • ls -l
  • ls -li

Multi command

  • &&: Running multiple command using &&, but the second command only will be executed if first command success.
  • ||: Running multiple command using ||, other command will be executed if other one is failed to execute.
  • ;: Running multiple command using ;, all command will be executed whether first command are failed or success.

Searching

  • find <location> <options>
    • Case 1 - What is the name of the config file that has been created after 2020-03-03 and is smaller than 28k but larger than 25k?
      • find / -type f -name *.conf -size +25k -size -28k -newermt 2020-03-03
    • Case 2 - How many files exist on the system that have the “.bak” extension?
      • find / -type f -name *.bak | wc -l
  • locate
    • Case 1 - Submit the full path of the “xxd” binary.
      • which xxd
  • find -name *.txt: Find file based on extension using wildcard (*), for example search file that has .txt at the end
  • find -name note.txt: Find file based on filename, for example find file named note.txt
  • grep "127.0.0.1" access.log: Search entire contents in file, for example search "127.0.0.1" in file access.log

might useful

  • man ascii: octal, hexadecimal and decimal ASCII character sets, imagine we forgot ascii, and recall with this table here

NOTE: for all command that listed in all sections above, you can find the information about specific command using man command, for example if you want to read about how to use find command you can use man find in your terminal.