\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{vezril} \pdfinfo{ /Title (linux-bash.pdf) /Creator (Cheatography) /Author (vezril) /Subject (Linux/Bash Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{A3A3A3} \definecolor{LightBackground}{HTML}{F3F3F3} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Linux/Bash Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{vezril} via \textcolor{DarkBackground}{\uline{cheatography.com/19611/cs/2601/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}vezril \\ \uline{cheatography.com/vezril} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 13th May, 2016.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Navigation et Filesystem}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `cd` {[}DIR{]} & Permet de changer de répertoire \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{`ls` {[}FILE{]}} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} `touch` FILE & Créé un fichier vide \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `mkdir` DIR & Créé un répertoire vide \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} `rm` FILE & Suprime un fichier \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} `rmdir` DIR & Suprime un répertoire \tn % Row Count 11 (+ 2) % Row 7 \SetRowColor{white} `rm -rf` DIR & Suprime un répertoire et tous son contenu \tn % Row Count 13 (+ 2) % Row 8 \SetRowColor{LightBackground} `cp` FILE & Copie un fichier \tn % Row Count 14 (+ 1) % Row 9 \SetRowColor{white} `cp -r` DIR & Copie un répertoire et tout son contenu \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Chemin relatif: ../chemin/./relatif \newline Chemin absolu: /chemin/absolu \newline -{}-{}-{}-{}-{}- \newline Les commandes avec des crochets ({[}{]}) sont des options non-obligatoire} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.96 cm} x{5.04 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Lecture/Ecriture et Recherche}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `cat` FILE & Permet de concatener deux fichier, ou d'imprimer le fichier sur l'écran \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} grep PATTERN FILE & Permet de trouver du texte (PATTERN) dans un fichier \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `more` FILE & Permet de lire les fichier \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} `less` FILE & Comme `more` mais avec l'option de remonter la page \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} `hexdump -C` FILE & Imprime un fichier ou binaire en hexa sur l'écran \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} `nano` FILE & Un éditeur de texte \tn % Row Count 15 (+ 1) % Row 7 \SetRowColor{white} `sed` SCRIPT {[}INPUT{]} & Un éditeur et transormateur de texte extrèmement puissant \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{LightBackground} `dd` of=OUTPUT if=INPUT & Death and Destroy. Une commande très puissante de bas niveau pour écrire sur des disques ou des fichiers. \tn % Row Count 23 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.6 cm} x{4.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{De/Compression}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `tar cvf` my\_archive.tar DIR & Archive un répertoire \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `tar cvfz` \seqsplit{my\_archive.tar.gz} DIR & Comme plus haut, mais applique la compression gzip \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} `tar cvfj` \seqsplit{my\_archive.tar.bz2} DIR & Comme plus haut, mais applique la compression bzip2 \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} `tar xvf` my\_archive.tar & Décompresse l'archive \tn % Row Count 11 (+ 2) % Row 5 \SetRowColor{white} `tar cvfz` \seqsplit{my\_archive.tar.gz} DIR & Comme plus haut, sauf ça décompresse un archive gzip \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} `tar cvfj` \seqsplit{my\_archive.tar.bz2} DIR & Comme plus haut, sauf ça décompresse un archive bzip2 \tn % Row Count 17 (+ 3) % Row 7 \SetRowColor{white} `gzip` FILE & Compresse un fichier avec gzip \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} `bzip2` FILE & Compresse un fichier avec bzip2 \tn % Row Count 21 (+ 2) % Row 9 \SetRowColor{white} `gunzip` FILE & Décompresse un gzip \tn % Row Count 22 (+ 1) % Row 10 \SetRowColor{LightBackground} `bunzip2` FILE & Décompresse un bzip2 \tn % Row Count 23 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Redirection}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{{\bf{Pipe}} \newline % Row Count 1 (+ 1) On peut ce servir du pipe (|) pour envoyé la sortie d'une application dans l'entré d'une autre. Example: `ps -ef | grep firefox`, me permet de faire une recherche textuelle pour `firefox` dans la sortie de `ps`. \newline % Row Count 6 (+ 5) {\bf{Waka (Redirection)}} \newline % Row Count 7 (+ 1) On peut redirigé les sorties de `stdout` et `stderr` dans des fichier textes avec le symbole `\textgreater{}`. \newline % Row Count 9 (+ 2) Example: `cat my\_file.txt \textgreater{} my\_new\_file.txt`. Ceci redirige le toute la sortie du `cat` dans un nouveau fichier. \newline % Row Count 12 (+ 3) Par contre, ceci écrase le fichier s'il exite déjà, donc on peut ce servir de `\textgreater{}\textgreater{}` pour rajouté au fichier. \newline % Row Count 15 (+ 3) Example: `cat my\_file \textgreater{}\textgreater{} my\_appended\_file` \newline % Row Count 16 (+ 1) Pour redigiré le stderr, c'est la même méthode, sauf que nous rajoutons un 2. \newline % Row Count 18 (+ 2) Example: `cat / 2\textgreater{} my\_errors.txt`. \newline % Row Count 19 (+ 1) Un truc intéressant est la redirection du `stderr` dans le `stdout`, comme ceci: \newline % Row Count 21 (+ 2) Example: `cat / 2\textgreater{}\&1 | grep dir`. Il y a beaucoup d'application à faire ceci, donc c'est bien de reconnaitre la syntaxe. Mais ceci fait en sorte que les les erreures ce retrouvent dans le `stdout`% Row Count 25 (+ 4) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Permission}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `chmod` MODE FILE & Change les permissions d'accès d'un fichier \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `chown` USER FILE & Change à qui appartient le fichier \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `chgrp` GROUP FILE & Change le groupe du fichier \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `sudo` CMD & Donne des priviledges administratif temporaire pour la commande \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{MODE: r (lecture), w (écriture), x (execution), u (utilisateur), g (groupe), o (autre) \newline `chmod +x-r mon\_fichier.txt` - donne des permissions d'exécution et enlève les permissions de lecture. `chmod u+r test.txt` donne des permissions de lecture seulement pour l'utilisateur du fichier. Note importante, pour pouvoir `exécuter`, on doit pouvoir le `lire`.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.48 cm} x{5.52 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Les Modules}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `lsmod` & Permet de voir les modules de chargé dans le noyeau \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} `insmod` MODULE.ko & Insère un module dans le noyeau \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `rmmod` MODULE & Enlève un module du noyeau \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.2 cm} x{4.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Collecte d'information et Administration}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{cmd}} & {\bf{Description}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `apt-cache search APP\_NAME` & Permet de chercher dans les repos pour un programme \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} `apt-get install APP\_NAME` & Permet d'installer à partir des repo un programme \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} `ifconfig {[}interface{]}` & Permet de configuré les interfaces de réseau \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} `iwconfig {[}interface{]}` & Permet la configuration avancé des interfaces de réseau sans-fil \tn % Row Count 12 (+ 3) % Row 5 \SetRowColor{white} `ps -ef` & Permet de voir les processus de tous les utilisateurs \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} `top` & Permet de voir les processus de manière interactive \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} `free` & Permet de voir la mémoire utilisé du système \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} `dmesg` & Permet de voir les logs de systèmes \tn % Row Count 22 (+ 2) % Row 9 \SetRowColor{white} `df` {[}DIR{]} & Permet de voir l'utilisation d'espace d'un ou plusieurs partitions \tn % Row Count 25 (+ 3) % Row 10 \SetRowColor{LightBackground} `du` {[}DIR{]} & Permet de voir la tailles des fichier d'un répertoire et sous-répertoire \tn % Row Count 29 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Note importante: Les commandes de apt sont seulement pour des distributions à base de `Debian`, tel que `Ubuntu`.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Device interessant}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Mount point}} & {\bf{Description}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `/dev/null` & Un trou sans fond. Pratique pour redirigé ce dont nous n'avons pas besoin. \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} `/dev/zero` & Lorsque lu, nous retourne des zéros. \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} `/dev/hd{[}a-z{]}{[}1-9{]}` & Nos disque dur PATA de A à Z. Les numéros dénotes les partitions. \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} `/dev/sd{[}a-z{]}{[}1-9{]}` & Comme précédents mais pour nos disque dur SATA. \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \seqsplit{`/dev/random`} & Générateur de nombre aléatoire du noyau \tn % Row Count 14 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}