General
whoami: Displays current username.id: Returns users identityhostname: 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 deviceslsof: Lists opened files.lspci: Lists PCI devices.ls -d */ | wc -l: count total folders in current directorywc -l access.log: Count total lines in file, for example in fileaccess.log
Useful control combination
Control+r: searching command history for commands we run beforeControl+l: clear the terminalControl+d: send an end of fileControl+c: kill a processControl+z: put a process to a sleep
Reading big files
more /path/to/file: useful when read big/long file, commandmoreis similar toless.
Navigation
lsls -lls -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
- 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?
locate- Case 1 - Submit the full path of the “xxd” binary.
which xxd
- Case 1 - Submit the full path of the “xxd” binary.
find -name *.txt: Find file based on extension using wildcard (*), for example search file that has.txtat the endfind -name note.txt: Find file based on filename, for example find file namednote.txtgrep "127.0.0.1" access.log: Search entire contents in file, for example search"127.0.0.1"in fileaccess.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
mancommand, for example if you want to read about how to usefindcommand you can useman findin your terminal.