You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

263 lines
9.8 KiB

9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
  1. \documentclass[8pt, letter, landscape]{extarticle}
  2. \usepackage{extsizes}
  3. \usepackage[
  4. margin=0.5in,
  5. top=2cm,
  6. bottom=2cm
  7. ]{geometry}
  8. \usepackage{lmodern}
  9. \usepackage[os=win]{menukeys}
  10. % Using this, but see other solution below
  11. % This option works better with small font sizes
  12. \usepackage{ragged2e} % Make right margin look better
  13. \raggedright
  14. \usepackage{titlesec}
  15. \titleformat{\section}[display]
  16. {\large\scshape}{\thesection}{}{\hrule\vspace{3pt}}{}
  17. % Define a date the way we like it
  18. \usepackage[en-AU]{datetime2}
  19. \usepackage{enumitem}
  20. \setlist[description]{
  21. style=nextline,
  22. font={\bfseries\ttfamily},
  23. itemsep=1pt,
  24. parsep=0pt
  25. }
  26. \usepackage{fancyhdr}
  27. \pagestyle{fancy}
  28. \fancyhf{}
  29. \fancyhead[L]{\textbf{A Linux Cheat Sheet}}
  30. \fancyhead[R]{\texttt{}}
  31. \fancyfoot[L]{Version 1.0.0 • \today}
  32. \fancyfoot[R]{Page \thepage}
  33. \renewcommand{\footrulewidth}{0.4pt}
  34. % Redefining headrule
  35. % See
  36. \makeatletter
  37. \renewcommand{\headrule}{\hrule height 1pt \vspace{1pt}\hrule height 0.25pt}
  38. \usepackage{multicol}
  39. \setlength{\columnseprule}{0.3pt}
  40. \setlength{\columnsep}{1cm}
  41. \usepackage[T1]{fontenc}
  42. \usepackage[utf8]{inputenc}
  43. \usepackage{tikz}
  44. \usetikzlibrary{shadows}
  45. % Not currently used; using «menukeys» package instead
  46. % See
  47. \newcommand*\keystroke[1]{%
  48. \tikz[baseline=(key.base)]
  49. \node[%
  50. draw,
  51. fill=white,
  52. drop shadow={shadow xshift=0.4ex,shadow yshift=-0.2ex,fill=black,opacity=0.35},
  53. rectangle,
  54. rounded corners=2pt,
  55. inner xsep=3pt,
  56. inner ysep=0.5pt,
  57. line width=0.5pt,
  58. font=\footnotesize\ttfamily
  59. ](key) {#1\strut}
  60. ;
  61. }
  62. % See for versioning meaning
  63. \begin{document}
  64. \begin{multicols*}{4}
  65. As always, check the \texttt{man} files for additional options and parameters.
  66. \section*{Disk Usage}
  67. \begin{description}
  68. \item[df] Get a report on the system's disk space usage
  69. \item[du] Check the disk space usage of a file or directory
  70. \item[du -ah] Show disk usage for all files and directories in human readable sizes
  71. \item[du -sh] Show disk usage of the current directory
  72. \item[fdisk -l] Show disk partitions, sizes, and types
  73. \item[findmnt] Show target mount point for all filesystems
  74. \end{description}
  75. \section*{Files}
  76. \begin{description}
  77. \item[ls] List files in a directory
  78. \item[ls -R] List all files in all subdirectories
  79. \item[ls -a] List hidden files
  80. \item[ls -l] List detailed information in a tabular format
  81. \item[ls -h] List sizes in human-readable format
  82. \item[cat] List the contents of a file on \texttt{stdout}
  83. \item[cat <file>] Create a new file
  84. \item[cat file1 file2 > file3] Joins two files and stores the output as a new file
  85. \item[cat <file.txt> | tr a-z A-Z output.txt] Convert a file to upper or lower case
  86. \item[diff] Compare the contents of two files line by line
  87. \item[rm] Delete (permanently) a file
  88. \item[cp] Copy files
  89. \item[cp file1 file2] Copy the contents of the first file to the second one
  90. \item[cp -r <directorya> <directory2>] Copy recursively the contents of the first directory into the second directory.
  91. \item[mv] Move or rename files
  92. \item[mv file1 file2] Rename a file
  93. \item[ln -s <path/to/file> <link name>] Create a symbolic link to a file
  94. \item[touch <newfile>] Create a new file
  95. \item[touch <oldfile>] Update the modification time of an existing file
  96. \item[more <file>] Show the contents of a file
  97. \item[head <file>] Show the first 10 lines of a file
  98. \item[head -<n> <file>] Show the first \texttt{n} lines of a file
  99. \item[tail <file>] Show the last 10 lines of a file
  100. \item[tail -<n> <file>] Show the last \texttt{n} lines of a file
  101. \item[locate] Search for a file or directory
  102. \item[find] Locate files within a directory
  103. \end{description}
  104. \section*{Directories}
  105. \begin{description}
  106. \item[cd] Change the current directory
  107. \item[cd..] Move one directory up
  108. \item[cd-] Move to your previous directory
  109. \item[pwd] Show the current directory (relative to \texttt{\$HOME})
  110. \item[scp <file> <server/file>] Securely copy a specific file to a server directory
  111. \item[mkdir] Create a new directory
  112. \item[rmdir] Delete an empty directory
  113. \item[rsync -a </path/to/file> </file>] Synchronize the contents of a specific direcotry with a backup directory
  114. \item[rm -r <directory>] Remove a non-empty directory
  115. \item[rm -ri <directory>] Remove a non-empty directory recursively, and require confirmation of each item
  116. \end{description}
  117. \section*{Archives}
  118. \begin{description}
  119. \item[tar]Archive multiple files into a common Linux file format (\textbf{Note:} \texttt{tar} files are \textit{not} compressed.)
  120. \item[tar -xf file.tar] Extract an archived file
  121. \item[tar -cf file.tar file1.txt file2.txt] Create an archive from one or more files
  122. \item[tar -czf file.txt file.tar.gz] Create a gzip-compressed file (\textbf{Note:} the file extensions \texttt{.tar.gz} and \texttt{.tgz} are equivalent.)
  123. \item[gzip file] Compress a file with the \texttt{.gz} extension
  124. \item[gpg -c <file>] Encrypt a file
  125. \item[gpg <file>] Decrypt a file
  126. \item[zip <> <file1> <file2>] Compress files into a zip archive
  127. \item[unzip <>] Extract zipped files from a zip archive
  128. \end{description}
  129. \section*{System}
  130. \begin{description}
  131. \item[history] Review previously entered commands
  132. \item[uname] Print information about your Linux system
  133. \item[uname -a] Show system and kernel
  134. \item[head -n1 /etc/issue] Show the current system software
  135. \item[jobs] Display currently running jobs
  136. \item[top] Monitor system resource usage
  137. \item[ps] Show a snapshot of active processes
  138. \item[kill <pid>] Terminate a process with process id <pid>
  139. \item[man <command>] Display the manual pages for a given command
  140. \item[uname -r] Show system information
  141. \item[timedatectl] Query and change the system clock
  142. \item[last reboot] Show the system reboot history
  143. \item[uptime] Show how long the system has been running, including load average
  144. \item[echo \$<variable>] Show the value of a variable
  145. \item[echo \$PATH] Show the current value of the \texttt{\$PATH} variable
  146. \end{description}
  147. \section*{Network}
  148. \textbf{Note:} Many of these are not installed by default on most systems.
  149. \begin{description}
  150. \item[hostname] Display the name of your host or network
  151. \item[ip addr show] Show IP addresses and network interfaces
  152. \item[ping] Check connectivity to a server
  153. \item[ifconfig] Show IP addresses of all network interfaces
  154. \item[netstat -pnltu] Show active ports
  155. \item[netstat -nutlp] Show more information about a domain
  156. \item[whois <domain>] Show more information about a domain
  157. \item[dig <domain>] Show DNS information about a domain
  158. \item[host <domain>] Do an IP lookup for a domain
  159. \item[hostname -i] Show the IP address of the system
  160. \end{description}
  161. \section*{Users, Groups, and Permissions}
  162. \begin{description}
  163. \item[id] Show information about the current user
  164. \item[useradd] Create a new user
  165. \item[passwrd] Add a password to a user's account
  166. \item[last] Show last logins
  167. \item[userdel <user>] Delete a user
  168. \item[chmod] Change the read, write, and execute permissions of files and directories
  169. \item[chmod u + x <file>] Give the user execute permissions on a file
  170. \item[chmod u+rw,go+r <file>] Give read and write permissions to the owner, and read-only permissions to the group and others.
  171. \item[chmod -R 755 <directory>] Change the permissions of a directory and its files recursively
  172. \item[chown] Change or transfer file ownership
  173. \item[chown <user> <file>] Change the ownership of a file to a given user
  174. \item[chown :<group> <file>] Change the group of a file to a given group (\textbf{Note:} Instead of the group permissions, the user permissions will apply if the owner user is in this group.)
  175. \item[sudo] Perform tasks as the root user
  176. \end{description}
  177. Permissions are always in the order: owner, group, others.
  178. \hspace{1em} Calculate permission digits by adding these numbers:
  179. \begin{itemize}[noitemsep]
  180. \item 4 — read (r)
  181. \item 2 — write (w)
  182. \item 1 — execute (x)
  183. \end{itemize}
  184. \section*{Pipes and Redirection}
  185. \begin{description}
  186. \item[cmd1 | cmd2] Pipe the \texttt{stdout} of the first command to the second command
  187. \item[cmd1 |\& cmd2] Pipe the \texttt{stderr} of the first command to the second command
  188. \item[cmd1 > file.txt] Redirect the \texttt{stdout} of a command to a file
  189. \item[cmd1 2>error.log] Redirect the \texttt{stderr} of a commmand to a log file
  190. \end{description}
  191. \section*{Command Lists}
  192. \begin{description}
  193. \item[cmd1 ; cmd2] Run \textit{cmd1} and then run \textit{cmd2}
  194. \item[cmd1 \&\& cmd2] Run \textit{cmd2} if \textit{cmd1} is successful
  195. \item[cmd1 || cmd2] Run \textit{cmd2} if \textit{cmd1} is not successful
  196. \end{description}
  197. \section*{Keyboard Shortcuts}
  198. \begin{description}
  199. \item[\keys{ctrl + a}] Move to the beginning of a line
  200. \item[\keys{ctrl + e}] Move to the end of the line
  201. \item[\keys{ctrl + w}] Cut one word before the cursor and add it to the clipboard
  202. \item[\keys{ctrl + u}] Cut part of the line before the cursor and add it to the clipboard
  203. \item[\keys{ctrl + k}] Cut part of the line after the cursor and add it to the clipboard
  204. \item[\keys{ctrl + y}] Paste from the clipboard
  205. \item
  206. \item[\keys{ctrl + z}] Pause the command
  207. \item[\keys{ctrl + c}] Stop and terminate the current command
  208. \item
  209. \item[\keys{ctrl + s}] Freeze the terminal
  210. \item[\keys{ctrl + q}] Unfreeze the terminal
  211. \item
  212. \item[\keys{$uparrow$}] Review the command history
  213. \item[\keys{ctrl + o}] Run the previously recalled command
  214. \item[\keys{ctrl + g}] Exit the command history without running a command
  215. \item[\keys{ctrl + r}] Recall the last command that matches the provided characters
  216. \item[\keys{Tab}] Autofill typing
  217. \item[\keys{!}\keys{!}] Repeat the last command
  218. \item[\keys{alt + /}] Move to the end of the file
  219. \item[exit] Log out of the current session
  220. \end{description}
  221. \end{multicols*}
  222. \end{document}