\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{lucic} \pdfinfo{ /Title (linux.pdf) /Creator (Cheatography) /Author (lucic) /Subject (Linux 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 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{lucic} via \textcolor{DarkBackground}{\uline{cheatography.com/189513/cs/39520/}}} \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}lucic \\ \uline{cheatography.com/lucic} \\ \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 21st July, 2023.\\ 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{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Bash commands}} \tn % Row 0 \SetRowColor{LightBackground} uname -a & Muestra sistema y kernel \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} head -n1 /etc/issue & Muestra distribución \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} mount & Muestra archivos del sistema montados \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} date & Muestra fecha del sistema \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} uptime & Muestra el tiempo transcurrido desde que el sistema se inició y la carga promedio del sistema en los últimos 1, 5 y 15 minutos. \tn % Row Count 11 (+ 5) % Row 5 \SetRowColor{white} man & Acceder al manual de referencia de otro comando. Al ejecutar man seguido del nombre de un comando, se abrirá el manual correspondiente en la terminal. \tn % Row Count 17 (+ 6) \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}{Operaciones directorios}} \tn % Row 0 \SetRowColor{LightBackground} cd & cambiar a home / directorio actual \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cd \{dir\} & Cambia el directorio actual al especificado \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ls & lista archivos y directorios en el directorio actual \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ls -a & incluye archivos ocultos en listado \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} ls -l & muestra los archivos y directorios con información detallada (formato largo) \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} ls -F & incluye el tipo de archivo \tn % Row Count 12 (+ 1) % Row 6 \SetRowColor{LightBackground} ls -laC & Lista todo el formato largo y columnas \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} pwd & Muestra la ruta del directorio actual \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} mkdir \{dir\} & Crea un nuevo directorio con el nombre especificado \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} rmkdir \{dir\} & elimina el directorio especificado \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} rm -r \{dir\} & elimina directorio especificado \tn % Row Count 22 (+ 2) % Row 11 \SetRowColor{white} rm -rf \{dir\} & elimina forzadamente directorio \tn % Row Count 24 (+ 2) % Row 12 \SetRowColor{LightBackground} cp -r \{dir1\} \{dir2\} & copia directorio1 a directorio2 \tn % Row Count 26 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.2 cm} x{6.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{opciones de ls}} \tn % Row 0 \SetRowColor{LightBackground} -a & Todo (Incluye ocultos) . \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} -l & Formato de listado largo \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} -1 & Un archivo por linea \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} -h & Muestra tamaños.\{\{nl\}\}"K" para kilobytes o "M" para megabytes. \tn % Row Count 5 (+ 2) % Row 4 \SetRowColor{LightBackground} -F & Incluye tipo de archivo \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} -r & orden inverso (descendente) \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} -R & recursivamente, con archivos y subdirectorios \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} -t & ordenado por fecha y hora de modificación \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} ls -laC & todo el formato largo y columnas \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} -S & ordenado por tamaño \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} -d & solo los nombres de directorio, sin entrar en ellos \tn % Row Count 16 (+ 2) % Row 11 \SetRowColor{white} -i & número de índice \tn % Row Count 17 (+ 1) % Row 12 \SetRowColor{LightBackground} -F & Agrega un indicador al final de cada entrada para indicar si es un archivo (-), un directorio (/), un enlace simbólico (@), un socket (=), etc. \tn % Row Count 22 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.12 cm} x{4.88 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Operaciones archivos}} \tn % Row 0 \SetRowColor{LightBackground} touch \{file\} & crea o actualiza fecha modificación archivo \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} cat \{file\} & muestra el contenido del archivo \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} cp \{file1\} \{file2\} & copia file1 a file2 \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} cp \{file\} \{dir\} & copia el archivo en el destino especificado \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} mv \{file1\} \{file2\} & renombra / mueve file1 a file2 \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} rm -f \{file\} & elimina forzadamente archivo \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} rm \{file\} & elimina el archivo especificado \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} ln -s \{file\} \{link\} & crea link simbólico a archivo \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} head \{file\} & Muestra las 10 primeras líneas de un archivo. \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} tail \{file\} & Muestra las 10 últimas líneas de un archivo. \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} grep \{"texto"\} \{file\} & Busca la palabra en el archivo y muestra las coincidencias. \tn % Row Count 23 (+ 3) % Row 11 \SetRowColor{white} find / -name \{file\} & Buscar archivo desde la raíz en Linux \tn % Row Count 25 (+ 2) % Row 12 \SetRowColor{LightBackground} find / -name " {\emph{ file }} " & Buscar un archivo que contenga la palabra "file" en su nombre \tn % Row Count 28 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Administración de usuarios}} \tn % Row 0 \SetRowColor{LightBackground} whoami & Muestra el nombre del usuario actualmente autenticado en el sistema \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} useradd {[}nombre{]} & Crea un nuevo usuario con el nombre especificado \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} passwd {[}nombre{]} & establece la contraseña para el usuario especificado \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} usermod & Modifica las propiedades de un usuario.\{\{nl\}\}usermod -aG grupo nombre\_usuario agrega al usuario al grupo especificado. \tn % Row Count 12 (+ 5) % Row 4 \SetRowColor{LightBackground} userdel {[}nombre{]} & Elimina el usuario especificado. \tn % Row Count 14 (+ 2) % Row 5 \SetRowColor{white} su {[}nombre{]} & Cambia al usuario superusuario (root) a usuario especificado. \tn % Row Count 17 (+ 3) % Row 6 \SetRowColor{LightBackground} sudo & Ejecuta un comando con privilegios de superusuario. \tn % Row Count 19 (+ 2) % Row 7 \SetRowColor{white} groups {[}nombre{]} & Muestra los grupos a los que pertenece un usuario. \tn % Row Count 21 (+ 2) % Row 8 \SetRowColor{LightBackground} id {[}nombre{]} & Muestra la información del usuario actual o de un usuario específico. \tn % Row Count 24 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{cambio de permisos}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{chmod \{octal\} \{file\}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Cambia permisos de archivo con octal. \{\{nl\}\}4 - lectura (r)\{\{nl\}\}2 - escritura (w) \{\{nl\}\}1 - ejecución (x)} \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{chmod 7 5 5 R+W+X para el owner y solo R para el resto} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{chmod +x \{file\} Hace el archivo ejecutable para todos los usuarios} \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.72 cm} x{5.28 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{SSH}} \tn % Row 0 \SetRowColor{LightBackground} ssh user@host & Conectarse a host como user \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ssh -p port user@host & Conectarse a host en port como user \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ssh-copy-id user@host & Agregar key de usuario a host para habilitar login por keys \tn % Row Count 7 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Búsqueda}} \tn % Row 0 \SetRowColor{LightBackground} grep pattern files & busca por patron en archivos \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} grep -r pattern dir & busca recursivamente por pattern en dir \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} command | grep pattern & busca por pattern en el output de un comando \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} locate file & busca todas las instancias de file \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Manejo procesos}} \tn % Row 0 \SetRowColor{LightBackground} ps & Muestra los procesos para la sesión de terminal actual. \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ps aux & Muestra todos los procesos para todos los usuarios en un formato detallado. \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} ps -ef & Similar a ps aux, pero con un formato de salida diferente. \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} top & Monitorear procesos del sistema en tiempo real. Muestra info de CPU, memoria y procesos \tn % Row Count 12 (+ 4) % Row 4 \SetRowColor{LightBackground} htop & = top con una interfaz más amigable. Visualizar actividad del sistema y manejar procesos interactivamente \tn % Row Count 16 (+ 4) % Row 5 \SetRowColor{white} kill {[}PID{]} & Termina proceso de PID especificado \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} killall {[}nombre{]} & Termina procesos por nombre \tn % Row Count 20 (+ 2) % Row 7 \SetRowColor{white} pkill & Termina procesos basado en patrón\{\{nl\}\}pkill -f "python" \tn % Row Count 23 (+ 3) % Row 8 \SetRowColor{LightBackground} pgreg {[}nombre{]} & Lista PIDs en base a nombre de proceso \tn % Row Count 25 (+ 2) % Row 9 \SetRowColor{white} renice & Cambiar la prioridad de procesos en ejecución. (Un valor más bajo significa una prioridad más alta) \tn % Row Count 29 (+ 4) % Row 10 \SetRowColor{LightBackground} nice & Ejecutar un comando con una prioridad dada. (Un valor más alto significa una prioridad más baja) \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{2.32 cm} x{5.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Manejo procesos (cont)}} \tn % Row 11 \SetRowColor{LightBackground} bg & Poner un proceso en segundo plano. \tn % Row Count 2 (+ 2) % Row 12 \SetRowColor{white} fg & Traer un proceso en segundo plano al primer plano. \tn % Row Count 4 (+ 2) % Row 13 \SetRowColor{LightBackground} jobs & Lista todos los trabajos en segundo plano. \tn % Row Count 6 (+ 2) % Row 14 \SetRowColor{white} nohup & Ejecutar un comando inmune a las desconexiones del terminal. \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{0.836 cm} x{3.42 cm} x{3.344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Compresión}} \tn % Row 0 \SetRowColor{LightBackground} tar & Archivar archivos y directorios & Crear un archivo comprimido: tar -czvf archivo.tar.gz \seqsplit{carpeta\_archivo/} \{\{nl\}\}Descomprimir un archivo: tar -xzvf archivo.tar.gz \tn % Row Count 8 (+ 8) % Row 1 \SetRowColor{white} gzip & Comprimir archivos. & Comprimir un archivo y conservar el original: gzip archivo (crea archivo.gz) \{\{nl\}\}Descomprimir un archivo comprimido: gzip -d archivo.gz (recupera el archivo original) \tn % Row Count 18 (+ 10) % Row 2 \SetRowColor{LightBackground} \seqsplit{gunzip} & Descomprimir archivos comprimidos con gzip. & Descomprimir un archivo comprimido: gunzip archivo.gz (recupera el archivo original) \tn % Row Count 23 (+ 5) % Row 3 \SetRowColor{white} bzip2 & Comprimir archivos de forma más eficiente. & Comprimir un archivo y conservar el original: bzip2 archivo (crea archivo.bz2) \{\{nl\}\}Descomprimir un archivo comprimido: bzip2 -d archivo.bz2 (recupera el archivo original) \tn % Row Count 34 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{0.836 cm} x{3.42 cm} x{3.344 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Compresión (cont)}} \tn % Row 4 \SetRowColor{LightBackground} \seqsplit{bunzip2} & Descomprimir archivos comprimidos con bzip2. & Descomprimir un archivo comprimido: bunzip2 archivo.bz2 (recupera el archivo original) \tn % Row Count 6 (+ 6) % Row 5 \SetRowColor{white} zip & Comprimir archivos y directorios en formato zip. & Comprimir un archivo o carpeta: zip archivo.zip \seqsplit{archivo\_o\_carpeta} \{\{nl\}\}Descomprimir un archivo zip: unzip archivo.zip \tn % Row Count 13 (+ 7) % Row 6 \SetRowColor{LightBackground} rar & Comprimir archivos en formato RAR (puede que necesites instalar rar) & Comprimir un archivo o carpeta: rar a archivo.rar \seqsplit{archivo\_o\_carpeta} \{\{nl\}\}Descomprimir un archivo RAR: rar x archivo.rar \tn % Row Count 21 (+ 8) % Row 7 \SetRowColor{white} 7z & Comprimir y descomprimir archivos en formato 7z. & Comprimir un archivo o carpeta: 7z a archivo.7z \seqsplit{archivo\_o\_carpeta} \{\{nl\}\}Descomprimir un archivo 7z: 7z x archivo.7z \tn % Row Count 28 (+ 7) % Row 8 \SetRowColor{LightBackground} tar + gzip & Combinar la compresión con tar para obtener archivos .tar.gz. & Comprimir una carpeta: tar -czvf archivo.tar.gz carpeta/ \tn % Row Count 32 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}