\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{ferpaesdias (ferpaesdias)} \pdfinfo{ /Title (linux-o-basico-do-shell.pdf) /Creator (Cheatography) /Author (ferpaesdias (ferpaesdias)) /Subject (Linux - O básico do Shell 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}{2A8FA3} \definecolor{LightBackground}{HTML}{F1F8F9} \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 - O básico do Shell Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{ferpaesdias (ferpaesdias)} via \textcolor{DarkBackground}{\uline{cheatography.com/215506/cs/46968/}}} \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}ferpaesdias (ferpaesdias) \\ \uline{cheatography.com/ferpaesdias} \\ \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 31st August, 2025.\\ 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*}{3} \begin{tabularx}{5.377cm}{p{0.4977 cm} x{4.4793 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comandos comuns}} \tn % Row 0 \SetRowColor{LightBackground} pwd & Mosta o diretório atual \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} cat & Concatena arquivos e mostra o seu conteúdo \tn % Row Count 3 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.54287 cm} x{3.43413 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comando ls (list)}} \tn % Row 0 \SetRowColor{LightBackground} ls & Lista o conteúdo de diretórios \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ls -a , -{}-all & Lista todos os arquivos, incluindo os ocultos \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ls -l & Usa o formato de lista longa (mostra dono, grupo, tamanho, etc.) \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} ls -lh & Usa o formato de lista longa e mostra o tamanho em KB, MB, GB, etc. \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} ls -S & Ordena por tamanho, do maior para o menor \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} ls -t & Ordena por horário, o mais novo primeiro \tn % Row Count 14 (+ 2) % Row 6 \SetRowColor{LightBackground} ls -r, -{}-reverse & Inverte a ordem na ordenação \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} ls -R, -{}-recursive & Lista os subdiretórios recursivamente \tn % Row Count 18 (+ 2) % Row 8 \SetRowColor{LightBackground} ls -1 & Lista um arquivo por linha \tn % Row Count 19 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comando cp (copy)}} \tn % Row 0 \SetRowColor{LightBackground} cp & Copia arquivos e diretórios \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cp -f, -{}-force & Sobreescreve um arquivo de destino se ele já existir \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} cp -i, -{}-interactive & Pergunta antes de sobreescrever \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} cp -R, -r, -{}-recursive & Copia os diretórios recursivamente \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} cp -v, -{}-verbose & Explica o que está sendo feito \tn % Row Count 11 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Como usar o comando: \newline \newline cp {[}OPÇÃO{]} ORIGEM DESTINO} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comando cd (change directory)}} \tn % Row 0 \SetRowColor{LightBackground} cd & Acessa o diretório home do usuário atual \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cd \textasciitilde{} & Acessa o diretório home do usuário atual \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cd / & Navega para o diretório raiz \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} cd \seqsplit{nome\_diretorio} & Navega para um diretório filho \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} cd \seqsplit{/etc/nome\_diretorio} & Navega para um diretório específico usando um caminho absoluto \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} cd - & Retorna para o último diretório visitado \tn % Row Count 13 (+ 2) % Row 6 \SetRowColor{LightBackground} cd .. & Navega para o diretório pai \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Diretório {\bf{pai}} é o diretório que contém outra pasta. Por exemplo, no caminho \seqsplit{`/home/aluno/Documentos`:} \newline \newline - O diretório pai de `Documentos` é `aluno` \newline - O diretório pai de `aluno` é `home`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.79172 cm} x{3.18528 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comando mv (move)}} \tn % Row 0 \SetRowColor{LightBackground} mv & Move e/ou renomeia os arquivos \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} mv -f, -{}-force & Não pergunta antes de sobreescrever \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} mv -i, -{}-interactive & Pergunta antes de sobreescrever \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} mv -v, -{}-verbose & Explica o que está sendo feito \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Como usar o comando: \newline \newline mv {[}OPÇÃO{]} ORIGEM DESTINO} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Aglomerar e comprimir}} \tn % Row 0 \SetRowColor{LightBackground} tar -cvf arquivo.tar /home/usuario & Cria o arquivo `arquivo.tar` com o conteúdo do diretório `/home/usuario` \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} tar -xvf arquivo.tar & Extrai os arquivos de `arquivo.tar` \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} tar -czvf arquivo.tar.gz /home/usuario & Cria o arquivo `arquivo.tar.gz` com o conteúdo do diretório `/home/usuario` compactados \tn % Row Count 11 (+ 5) % Row 3 \SetRowColor{white} tar -xzvf arquivo.tar.gz & Descompacta e extrai os arquivos de `arquivo.tar.gz` \tn % Row Count 14 (+ 3) % Row 4 \SetRowColor{LightBackground} tar -tf arquivo.tar.gz & Lista o conteúdo de `arquivo.tar.gz` \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{A opção `-v` lista os arquivos processados.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.74195 cm} x{3.23505 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Comando rm (remove)}} \tn % Row 0 \SetRowColor{LightBackground} rm & Apaga arquivos e diretórios \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} rm -i & Confirma com o usuário antes de cada remoção \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} rm -f, -{}-force & Remove sem confirmar com o usuário \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} rm -r, -R, -{}-recursive & Remove os diretórios e seus conteúdos recursivamente \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} rm -d, -{}-dir & Remove diretórios vazios \tn % Row Count 10 (+ 1) % Row 5 \SetRowColor{white} rm -v, -{}-verbose & Explica o que está sendo feito \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Por padrão, o comando `rm` não remove diretórios. Use a opção `-{}-recursive` para remover cada diretório listado, junto com o seu conteúdo. \newline \newline Para remover um arquivo cujo o nome inicia com "-" (por exemplo. `-foo`), use um dos seguinte comandos: \newline `rm -{}- -foo` \newline `rm ./-foo` \newline \newline Use o comando `rm` com muito cuidado, a possibilidade de recuperar um arquivo removido é muito baixa.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{0.84609 cm} x{4.13091 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Sistema}} \tn % Row 0 \SetRowColor{LightBackground} date & Mosta a data e hora atual \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{uptime} & Mostra quanto tempo o sistema está em execução \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} free -h & Mostra o uso de memória RAM e Swap \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} df -h & Mostra o uso de disco \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} uname -r & Mostra a versão do kernel \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} uname -a & Mostra informações completas do sistema \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}