Linux cheat sheet

A Standard Linux Directory Structure

Below is a reference to the basic structure of directories for most Linux distributions. Find more at the Linux Filesystem Hierarchy Standard, on Wikipedia.

  • / – the root or base of the filesystem
  • /bin – operating system binaries
  • /boot – Linux kernel and programs run at startup
  • /dev – devices
  • /etc – system configuration files
  • /home – user working directories
  • /lib – library files shared across installed programs
  • /media – removable media devices
  • /mnt – removable device mount points
  • /opt – for optional software
  • /proc – Linux kernel files
  • /root – home directory for root user
  • /sbin – system binaries
  • /usr – program and support files
    • /usr/bin – programs installed by the Linux distribution
    • /usr/lib – shared libraries
    • /usr/local – programs for system-wide use
    • /usr/sbin – system administration binaries
    • /usr/share – shared data used by programs including documentation
  • /var – dynamic data, including mail, databases and log files

Commonly Used Wildcards

Linux offers extensive search capabilities using wildcards and the following characters are frequently used.

  • * – matches any character
  • ? – matches a single character
  • [set] – matches a set of characters
  • [!set] – matches those not in the set

Metacharacters

These 10 metacharacters have special meaning to the bash shell program and must be quoted with ' or " to not be interpreted as metacharacters.

space  tab  newline  |  &  ;  (  )  <  >

Keystroke Combinations

These keystroke combinations are helpful in the bash shell.

  • Ctrl-c – stop a process
  • Ctrl-d – exit the terminal
  • Ctrl-z – pause a process
  • Ctrl-a – go to start of line
  • Ctrl-e – go to end of line

Reserved Words

Reserved words are commonly used for looping and conditional constructs when writing functions and scripts.

  • ! – negation or not
  • [[ ]] – conditional expression
  • { } – command grouping
  • function – define a function
  • select do done – create a menu
  • time – for timing statistics
  • case in esac – conditional construct
  • if then elif else fi – conditional construct
  • for in do done – looping construct
  • until do done – looping construct
  • while do done – looping construct

File and Directory Modes and Permissions

Permissions can be set with any one of three modes: octal, binary and mode.

OctalBinaryMode
0000
1001–x
2010-w-
3011-wx
4100r–
5101r-x
6110rw-
7111rwx

Non-Alphanumeric Characters and Meanings

The following 32 non-alphanumeric characters have special meaning in the bash shell depending on context. The Context Key below is used to cross-reference the context under which each character has special meaning. See GNU Bash Manual for more complete information.

SymbolName(s)Context
`backtickI
~tildeM
!exclamation, bangO, S
@ampersand, at symbolH, O
#number, pound, sharp, hashB, H
$dollar symbolH, I, L, O, Q, S
%percentJ, H, U
^caretH, J
&ampersand, and symbolD, J
*asterisk, starJ, H, L, O
(open parenthesisH, J, S
)close parenthesisH, J, S
_underscore(no special meaning)
dash, minus, hyphenJ, M, O, S, U
+plusJ, O, P, U
=equalJ, Q, R, S
|pipe, vertical barD, J
\backslashI, T
/forward slashJ, H, M
{open brace, curly bracketF, H, S
}close brace, curly bracketD, H, L, O, S
[open bracketD, H, L, O, S
]close bracketD, H, L, O, S
quote, double quoteA, P, S, T
apostrophe, single quoteA, O, P, S, T
:colonC, F, H, S, T
;semi-colonE, S
?question markO
<less thanD, N
>greater thanD, N
.period, dotC, M
,commaJ
Context Key
  1. quoting
  2. comments
  3. command shortcuts
  4. redirection
  5. compound commands
  6. brace expansion
  7. tilde expansion
  8. parameter and variable expansion
  9. command substitution
  10. arithmetic expansion
  11. word splitting
  12. filename expansion
  13. directories
  14. process substitution
  15. pattern matching
  16. command options
  17. environment
  18. variables
  19. expessions
  20. escape sequences
  21. job control

!External content + my content! – source link https://factorpad.com/tech/linux-cheat-sheet.html