\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{AnnVals} \pdfinfo{ /Title (bash-linux.pdf) /Creator (Cheatography) /Author (AnnVals) /Subject (Bash 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{Bash Linux Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{AnnVals} via \textcolor{DarkBackground}{\uline{cheatography.com/201609/cs/42692/}}} \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}AnnVals \\ \uline{cheatography.com/annvals} \\ \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 17th March, 2024.\\ 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*}{4} \begin{tabularx}{3.833cm}{x{1.30454 cm} x{2.12846 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Basics}} \tn % Row 0 \SetRowColor{LightBackground} \textasciitilde{} & indica que está en el directorio home \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \$ & indica si es un usuario normal \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \# & indica si es el administrador del sistema \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} root & es el usuario administrador del sistema y puede realizar cualquier tarea de administración \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} sudo -l & muestra toda la información \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} exit & salir \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} /home & directorio del usuario \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} pwd & muestra la ruta donde estoy \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} cd & cambia de directorio \tn % Row Count 17 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{cd \seqsplit{/directorio/subdirectorioA}} \tn % Row Count 18 (+ 1) % Row 10 \SetRowColor{LightBackground} cd .. & va al directorio de atrás \tn % Row Count 20 (+ 2) % Row 11 \SetRowColor{white} cd & va al home del usuario \tn % Row Count 21 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{cd \seqsplit{./directorio/subdirectorioB}} \tn % Row Count 22 (+ 1) % Row 13 \SetRowColor{white} . & hace referencia al directorio actual \tn % Row Count 24 (+ 2) % Row 14 \SetRowColor{LightBackground} .. & hace referencia al directorio padre (al anterior) \tn % Row Count 27 (+ 3) % Row 15 \SetRowColor{white} tree & ver directorios en árbol \tn % Row Count 29 (+ 2) % Row 16 \SetRowColor{LightBackground} info "comando" & info del comando \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.30454 cm} x{2.12846 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Basics (cont)}} \tn % Row 17 \SetRowColor{LightBackground} apt-get update & instala una actualización \tn % Row Count 2 (+ 2) % Row 18 \SetRowColor{white} apt clean & instala el paquete sin instalarlo \tn % Row Count 4 (+ 2) % Row 19 \SetRowColor{LightBackground} apt purge \seqsplit{nombre\_paquete} & purga paquetes \tn % Row Count 6 (+ 2) % Row 20 \SetRowColor{white} apt remove \seqsplit{nombre\_paquete} & elimina paquetes \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.54485 cm} x{1.88815 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Buscar, filtrar, ordenar, contar}} \tn % Row 0 \SetRowColor{LightBackground} find ruta/ -name loquequiera & busca texto \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} find ruta/ -name a* & busca en la ruta todo lo que empiece por a \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} find ruta/ -name a* -exec rm \{\} \textbackslash{} & borra todo lo que ha encontrado en ese fichero que empiece por a \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} aclaración & para añadir que haga algo con el resultado añadimos los comandos y al final " \{\} \textbackslash{}; \tn % Row Count 11 (+ 4) % Row 4 \SetRowColor{LightBackground} find ruta/ -type f & ficheros \tn % Row Count 12 (+ 1) % Row 5 \SetRowColor{white} find ruta/ -type d & directorios \tn % Row Count 13 (+ 1) % Row 6 \SetRowColor{LightBackground} find ruta/ -type l & enlaces simbolicos \tn % Row Count 14 (+ 1) % Row 7 \SetRowColor{white} find ruta/ -user nombreusuario & usuario \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} find ruta/ -perm XXX & permisos \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} find ruta/ -size +512c & tamaño \tn % Row Count 20 (+ 2) % Row 10 \SetRowColor{LightBackground} -not -path '{\emph{/\textbackslash{}.}}' & No muestra en el resultado archivos ocultos .hidden\_files \tn % Row Count 23 (+ 3) % Row 11 \SetRowColor{white} & IMPORTANTE si añades un -exec para realizar alguna accion con lo encontrado: hay que añadir al final \{\} \textbackslash{} \tn % Row Count 28 (+ 5) % Row 12 \SetRowColor{LightBackground} find / | grep .conf & equivale a find / -type f -name *.conf \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.54485 cm} x{1.88815 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Buscar, filtrar, ordenar, contar (cont)}} \tn % Row 13 \SetRowColor{LightBackground} & find /home/javi/ -type f -name {\emph{\_practica\_SMR\_21}} -exec ls -l \{\} \textbackslash{} \tn % Row Count 4 (+ 4) % Row 14 \SetRowColor{white} & find / -type f -size +4M -size -7M \tn % Row Count 6 (+ 2) % Row 15 \SetRowColor{LightBackground} & find / -type f -atime -1 \tn % Row Count 8 (+ 2) % Row 16 \SetRowColor{white} & find / -type f -mmin -5 \tn % Row Count 10 (+ 2) % Row 17 \SetRowColor{LightBackground} grep Eva fichero.tx & buscar palabra. Muestra la linea completa donde aparece Eva \tn % Row Count 13 (+ 3) % Row 18 \SetRowColor{white} grep "Garcia Eva" fichero.txt & buscar conjunto palabras en ese orden \tn % Row Count 15 (+ 2) % Row 19 \SetRowColor{LightBackground} wc & contar el número de líneas, palabras y caracteres \tn % Row Count 18 (+ 3) % Row 20 \SetRowColor{white} wc -w (words) & wc -l (lines) \tn % Row Count 19 (+ 1) % Row 21 \SetRowColor{LightBackground} sort fichero.txt & ordena un fichero \tn % Row Count 20 (+ 1) % Row 22 \SetRowColor{white} sort -k2 fichero.txt & ordena por la 2º columna \tn % Row Count 22 (+ 2) % Row 23 \SetRowColor{LightBackground} sort -n fichero.txt & ordena por numeros \tn % Row Count 24 (+ 2) % Row 24 \SetRowColor{white} sort -r fichero.txt & ordena al reves \tn % Row Count 26 (+ 2) % Row 25 \SetRowColor{LightBackground} sort -u fichero.txt & elimina lineas duplicadas \tn % Row Count 28 (+ 2) % Row 26 \SetRowColor{white} | unir varias opciones & ls -l fichero.txt | grep 2020 | sort -k2 \tn % Row Count 30 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.37763 cm} x{3.05537 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Estructura de directorios}} \tn % Row 0 \SetRowColor{LightBackground} ls & muestra contenido del directorio \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ls -a & muestra todos los archivos y directorios, incluso aquellos que están ocultos \tn % Row Count 4 (+ 3) % Row 2 \SetRowColor{LightBackground} ls -C & muestra resultados en formato columna \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} ls -d & muestra solo el nombre del directorio en lugar de su contenido \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} ls -F & agrega caracteres especiales al final del nombre de cada archivo para indicar su tipo (por ejemplo, una barra diagonal para un directorio) \tn % Row Count 12 (+ 4) % Row 5 \SetRowColor{white} ls -G & muestra los archivos y directorios en color, lo que puede facilitar la lectura \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} ls -h & muestra los tamaños de los archivos en un formato legible por humanos, como "1K" o "1G" \tn % Row Count 18 (+ 3) % Row 7 \SetRowColor{white} ls -I & i, formato de lista larga \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} ls -i & muestra el número de inodo de cada archivo o directorio \tn % Row Count 22 (+ 2) % Row 9 \SetRowColor{white} ls -l & muestra detalles detallados sobre los archivos y directorios, incluyendo sus permisos, propietarios, tamaños y fechas de modificación \tn % Row Count 26 (+ 4) % Row 10 \SetRowColor{LightBackground} ls -m & separa el contenido del directorio con comas \tn % Row Count 28 (+ 2) % Row 11 \SetRowColor{white} ls -R & muestra todos los archivos y subdirectorios en una ubicación dada, incluyendo los que están en subdirectorios \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{p{0.37763 cm} x{3.05537 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Estructura de directorios (cont)}} \tn % Row 12 \SetRowColor{LightBackground} ls -r & invierte el orden de visualización de los archivos \tn % Row Count 2 (+ 2) % Row 13 \SetRowColor{white} ls -S & ordenar por tamaño de archivo \tn % Row Count 4 (+ 2) % Row 14 \SetRowColor{LightBackground} ls -s & muestra el tamaño de los archivos en bloques de disco \tn % Row Count 6 (+ 2) % Row 15 \SetRowColor{white} ls -t & muestra los archivos ordenados por fecha de modificación, con los más recientes primero \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Usuarios y Grupos SIEMPRE CON SUDO}} \tn % Row 0 \SetRowColor{LightBackground} sudo su & cambia usuario \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} sudo useradd & crear usuarios \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} sudo useradd -g & asociar a un grupo princiapl (adm) \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} sudo useradd -d & asociar ruta absoluta para su home \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} sudo useradd -m & por si no ha sido creada la home \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} sudo useradd -s & asociar la shell ( /bin/bash ) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{sudo useradd -g adm -d /home/pepe -m -s /bin/bash pepe} \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} sudo passwd usuario & establece contraseña \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} sudo passwd usuario -d & borra contraseña \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} sudo passwd usuario -e & fuerza caducidad contraseña \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} sudo passwd usuario -i & si la contraseña de la cuenta lleva caducada INACTIVE días, la cuenta será desactivada \tn % Row Count 23 (+ 5) % Row 11 \SetRowColor{white} sudo passwd usuario -i & si la contraseña de la cuenta lleva caducada INACTIVE días, la cuenta será desactivada. \tn % Row Count 28 (+ 5) % Row 12 \SetRowColor{LightBackground} sudo passwd usuario -l & bloque de la cuenta \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Usuarios y Grupos SIEMPRE CON SUDO (cont)}} \tn % Row 13 \SetRowColor{LightBackground} sudo passwd usuario -n MIN\_DAYS & obliga a que la contraseña se cambie como pronto a los MIN\_DAYS \tn % Row Count 4 (+ 4) % Row 14 \SetRowColor{white} sudo passwd usuario -x MAX\_DAYS & obliga a que la contraseña se cambie como tarde a los MAX\_DAYS \tn % Row Count 8 (+ 4) % Row 15 \SetRowColor{LightBackground} sudo passwd usuario -S & informa estado contraseña \tn % Row Count 10 (+ 2) % Row 16 \SetRowColor{white} sudo passwd usuario -u & desbloquea cuenta \tn % Row Count 12 (+ 2) % Row 17 \SetRowColor{LightBackground} sudopasswd usuario -w & preaviso de la fecha de caducidad \tn % Row Count 14 (+ 2) % Row 18 \SetRowColor{white} sudo chpasswd & cambia contraseña \tn % Row Count 15 (+ 1) % Row 19 \SetRowColor{LightBackground} sudo usermod & modifica algo de ese usuario \tn % Row Count 17 (+ 2) % Row 20 \SetRowColor{white} sudo userdel & borrar usuarios (no las carpetas) \tn % Row Count 19 (+ 2) % Row 21 \SetRowColor{LightBackground} sudo userdel -r usuario & borra todo \tn % Row Count 21 (+ 2) % Row 22 \SetRowColor{white} sudo groupadd & crear grupo \tn % Row Count 22 (+ 1) % Row 23 \SetRowColor{LightBackground} sudo adduser usuario grupo & añade el usuario al grupo \tn % Row Count 24 (+ 2) % Row 24 \SetRowColor{white} sudo deluser usuario grupo & borra el usuario del grupo \tn % Row Count 26 (+ 2) % Row 25 \SetRowColor{LightBackground} sudo groupmod & modifica grupo \tn % Row Count 27 (+ 1) % Row 26 \SetRowColor{white} sudo groupmod -n nombrefin nombreinicial & cambia nombre al grupo \tn % Row Count 29 (+ 2) % Row 27 \SetRowColor{LightBackground} sudo groupdel & borra grupo \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Usuarios y Grupos SIEMPRE CON SUDO (cont)}} \tn % Row 28 \SetRowColor{LightBackground} sudo chsh & cambia la shell de un grupo \tn % Row Count 2 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.3433 cm} x{3.0897 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Metacaracteres}} \tn % Row 0 \SetRowColor{LightBackground} * & empieza, termna, contiene \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ? & equivale a un caracter \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \{\} & varias opciones separadas por comas \{az,ro{]}* \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} {[}{]} & es válido lo que haya dentro de ellos \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} ! & negación/lo contrario \tn % Row Count 7 (+ 1) % Row 5 \SetRowColor{white} | & la salida estándar (pantalla) de un comando se convierte en la entrada estándar del siguiente comando \tn % Row Count 10 (+ 3) % Row 6 \SetRowColor{LightBackground} \textless{} & redirecciona la entrada estándar sustituyéndola por el archivo que le indique \tn % Row Count 13 (+ 3) % Row 7 \SetRowColor{white} \textgreater{} & redirecciona la salida estándar de un proceso al fichero o dispositivo que se le indique, borrando la información que el fichero contenía. Si es un fichero que no existe, lo crea \tn % Row Count 19 (+ 6) % Row 8 \SetRowColor{LightBackground} \textgreater{}\textgreater{} & redirecciona la salida estándar de un proceso al fichero que se le indique. No borra el contenido del fichero, sino que añade la información al final del fichero. \tn % Row Count 24 (+ 5) % Row 9 \SetRowColor{white} 2\textgreater{} & redirecciona la salida de errores de un proceso al fichero que se le indique, borrando la información que el fichero contenía \tn % Row Count 28 (+ 4) % Row 10 \SetRowColor{LightBackground} 2\textgreater{}\textgreater{} & redirecciona la salida de errores de un proceso al fichero que se le indique pero añadiendo al final de la información del fichero la salida, con lo que no se borra el contenido del fichero \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{p{0.3433 cm} x{3.0897 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Metacaracteres (cont)}} \tn % Row 11 \SetRowColor{LightBackground} \&\textgreater{} & redirecciona tanto la salida de errores como la salida estándar a un fichero o dispositivo \tn % Row Count 3 (+ 3) % Row 12 \SetRowColor{white} \&\textgreater{}\textgreater{} & redirecciona tanto la salida de errores como la salida estándar a un fichero o dispositivo, pero añadiendo la información al final del contenido del fichero \tn % Row Count 8 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.09856 cm} x{2.33444 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Enlaces}} \tn % Row 0 \SetRowColor{LightBackground} Enlaces simbólicos & ln -s "ruta absoluta origen" "nombre del enlace" \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Enlaces simbólicos & ln -s "ruta abolsuta origen" "ruta absoluta destino" "nombre enlace" \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} Enlaces físicos & ln "ruta fichero" "nombre enlace" \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.20155 cm} x{2.23145 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Fechas y Mantenimiento Equipo}} \tn % Row 0 \SetRowColor{LightBackground} date & fecha completa \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} date +\%d & día \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} date +\%m & mes \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} date +\%y & año \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} date \seqsplit{+\%d/+\%m/+\%y} & día, mes, año \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} date -{}-date="tomorrow" & muestra mañana \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} date -{}-date="next mon" & muestra el próximo lunes \tn % Row Count 10 (+ 2) % Row 7 \SetRowColor{white} cal & calendario \tn % Row Count 11 (+ 1) % Row 8 \SetRowColor{LightBackground} cal -m 11 & muestra calendario noviembre \tn % Row Count 13 (+ 2) % Row 9 \SetRowColor{white} cal -m 11 2023 & muestra calendario noviembre del 2023 \tn % Row Count 15 (+ 2) % Row 10 \SetRowColor{LightBackground} cal -y 2021 & muestra un calendario del año 2021 \tn % Row Count 17 (+ 2) % Row 11 \SetRowColor{white} ncal -M-b & calendario empieza en lunes estilo clásico \tn % Row Count 19 (+ 2) % Row 12 \SetRowColor{LightBackground} who & muestra el usuario que ha iniciado sesión \tn % Row Count 21 (+ 2) % Row 13 \SetRowColor{white} whoami & muestra el usuario actual \tn % Row Count 22 (+ 1) % Row 14 \SetRowColor{LightBackground} id usuario & saber datos del usuario \tn % Row Count 23 (+ 1) % Row 15 \SetRowColor{white} shutdown & apagar \tn % Row Count 24 (+ 1) % Row 16 \SetRowColor{LightBackground} shutdown -h +10 & apagar dentro de 10h \tn % Row Count 26 (+ 2) % Row 17 \SetRowColor{white} reboot & Reiniciar \tn % Row Count 27 (+ 1) % Row 18 \SetRowColor{LightBackground} reboot -p & apagar \tn % Row Count 28 (+ 1) % Row 19 \SetRowColor{white} uptime & saber cuanto tiempo lleva encendida la máquina \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.20155 cm} x{2.23145 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Fechas y Mantenimiento Equipo (cont)}} \tn % Row 20 \SetRowColor{LightBackground} free & saber cantidad RAM libre \tn % Row Count 1 (+ 1) % Row 21 \SetRowColor{white} free -h & la h humaniza las unidades \tn % Row Count 2 (+ 1) % Row 22 \SetRowColor{LightBackground} df & saber espacio disponible en disco (disk free) \tn % Row Count 4 (+ 2) % Row 23 \SetRowColor{white} du & saber espacio usado en disco (disk used) \tn % Row Count 6 (+ 2) % Row 24 \SetRowColor{LightBackground} history & muestra el historial completo de comandos usados \tn % Row Count 8 (+ 2) % Row 25 \SetRowColor{white} uname & muestra info sobre el equipo y sistema operativo \tn % Row Count 10 (+ 2) % Row 26 \SetRowColor{LightBackground} lsb\_release & muestra info distribución y versión instalada \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Atributos y Permisos}} \tn % Row 0 \SetRowColor{LightBackground} lsattr & nos servirá para listar atributos de ficheros y directorios \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} lsattr -Ra | more & se ven todos los atributos extendidos de todos los archivos y directorios en el directorio actual, mostrándolos página por página \tn % Row Count 10 (+ 7) % Row 2 \SetRowColor{LightBackground} chattr +A prueba.txt & nos servirá para cambiar los atributos \tn % Row Count 12 (+ 2) % Row 3 \SetRowColor{white} chattr +c prueba.txt & comprime automaticamente el fichero / lo descomprime cuando se vaya a usar. \tn % Row Count 16 (+ 4) % Row 4 \SetRowColor{LightBackground} chattr +u prueba.txt & permite recuperación aunque sea eliminado \tn % Row Count 19 (+ 3) % Row 5 \SetRowColor{white} chattr +e prueba.txt & al ser eliminado todos sus bloques se sobreescriben con 0 \tn % Row Count 22 (+ 3) % Row 6 \SetRowColor{LightBackground} ls -l (- no tiene r lectura w escritura x ejecución) & nos podemos dar cuenta que a un lado aparecen unos pequeños atributos, estos son los permisos que tiene cada archivo. Ej: ls -las (large + all + size) \tn % Row Count 30 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Atributos y Permisos (cont)}} \tn % Row 7 \SetRowColor{LightBackground} chmod (- elimina, + añade, = asigna) &  Se utiliza para cambiar los permisos del archivo o directorioSe pueden modificar en formato simbólico o numérico (con letras o con números.) Existe la opción -R, que hace cambie de forma recursiva, es decir, que también afectará el cambio al contenido de directorios. \tn % Row Count 14 (+ 14) % Row 8 \SetRowColor{white} chmod (u user, g grupo, o resto, a todos) & En resumen, la primera cifra (7, 5 o 6) representa los permisos del propietario, la segunda cifra (7, 5 o 4) representa los permisos del grupo y la tercera cifra (7, 5 o 4) representa los permisos de otros usuarios que no son el propietario ni están en el grupo. \tn % Row Count 28 (+ 14) % Row 9 \SetRowColor{LightBackground} chmod u+rw & Otorga permisos de lectura y escritura al propietario (usuario) \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Atributos y Permisos (cont)}} \tn % Row 10 \SetRowColor{LightBackground} chown & se utiliza para cambiar el propietario del fichero o directorio \tn % Row Count 4 (+ 4) % Row 11 \SetRowColor{white} chgrp & es como la anterior pero así cambiamos el grupo. \tn % Row Count 7 (+ 3) % Row 12 \SetRowColor{LightBackground} umaks & Este comando es la abreviatura de user file-creation mode mask, y sirve para establecer los permisos por defecto que tendrán los uevos ficheros y directorios que creemos. \tn % Row Count 16 (+ 9) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.61351 cm} x{1.81949 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Contraseñas y Seguridad}} \tn % Row 0 \SetRowColor{LightBackground} cat /etc/passwd & podemos ver info de los usuarios (no sus contraseñas). \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} cat /etc/shadow | grep nombreusuario & archivo ASCII de acceso restringido que almacena para cada usuario las contraseñas encriptadas y más info \tn % Row Count 9 (+ 6) % Row 2 \SetRowColor{LightBackground} cat /etc/profile & contiene el perfil igual para todos los usuarios, en su interior podemos poner comandos que se ejecutarán al iniciar sesión cualquier usuario \tn % Row Count 16 (+ 7) % Row 3 \SetRowColor{white}  ls /etc/profile.d/ & ejecuta todos los script que se encuentran en el directorio \tn % Row Count 19 (+ 3) % Row 4 \SetRowColor{LightBackground} nano .profile & Modifica tu perfil. Sitúate en tu directorio home y edita el fichero .profile \tn % Row Count 23 (+ 4) % Row 5 \SetRowColor{white} chage -l usuario & obtiene información sobre la contraseña de un usuario \tn % Row Count 26 (+ 3) % Row 6 \SetRowColor{LightBackground} chage -M 0 -W 560 ann & Si queremos obligar al usuario ann a modificar la contraseña cada 60 días, y que mande un aviso 5 días antes de que la contraseña va a caducar, puedo hacerlo así \tn % Row Count 34 (+ 8) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.61351 cm} x{1.81949 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Contraseñas y Seguridad (cont)}} \tn % Row 7 \SetRowColor{LightBackground} pwunconv & se elimina el \seqsplit{fichero shadow pasando} las contraseñas cifradas al fichero passwd \tn % Row Count 4 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.16722 cm} x{2.26578 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Directorios y Ficheros}} \tn % Row 0 \SetRowColor{LightBackground} mkdir & crear directorio (carpeta) \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} rmdir & borrar directorio vacío \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} rmdir a/b/c & borra el último directorio \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} rmdir a/b/c -p & borra todos \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} rm & eliminar directorios o ficheros \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} rm -i & pide confirmación (iteraction) \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} rm -r & lo hace recursivo. Si es directorio usar siempre -r \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} mv & cambiar nombre fichero a.txt b.txt \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} mv & mueve directorios mv spiderman ../../DC/ \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} touch & crea fichero \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} echo & escribe texto dentro de un fichero "..." \textgreater{} a.txt \tn % Row Count 19 (+ 2) % Row 11 \SetRowColor{white} cat & mostrar contenido archivo \tn % Row Count 20 (+ 1) % Row 12 \SetRowColor{LightBackground} cat \textgreater{} prueba.txt & crea fichero con ese nombre, se escribe lo que sea y luego ctrl+d para salir \tn % Row Count 23 (+ 3) % Row 13 \SetRowColor{white} cp hola ../../DC/ -r & copia hola a DC \tn % Row Count 25 (+ 2) % Row 14 \SetRowColor{LightBackground} head \seqsplit{nombre.extension} & muestra las primeras 10 líneas del fichero \tn % Row Count 27 (+ 2) % Row 15 \SetRowColor{white} tail \seqsplit{nombre.extension} & muestra las 10 últimas líneas del fichero \tn % Row Count 29 (+ 2) % Row 16 \SetRowColor{LightBackground} head -num & muestra las num número de líneas primeras pedidas \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.16722 cm} x{2.26578 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Directorios y Ficheros (cont)}} \tn % Row 17 \SetRowColor{LightBackground} tail -num & muestra las num número de líneas últimas pedidas \tn % Row Count 2 (+ 2) % Row 18 \SetRowColor{white} nano \seqsplit{nombre.extension} & muestra contenido de fichero y lo permite editar \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.0299 cm} x{2.4031 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Registros y Archivos}} \tn % Row 0 \SetRowColor{LightBackground} /var/log & encontraras registro de todo lo que sucede en tu máquina. Los principales son: auth | authpriv | cron | kern | lpr | syslog | user \tn % Row Count 6 (+ 6) % Row 1 \SetRowColor{white} ps & muestra los procesos del sistema \tn % Row Count 8 (+ 2) % Row 2 \SetRowColor{LightBackground} ps -ef & Muestra información sobre todos los procesos y proporciona una salida más detallada que incluye información sobre el propietario del proceso, el terminal en el que se está ejecutando, etc. \tn % Row Count 15 (+ 7) % Row 3 \SetRowColor{white} kill -9 & matar/terminar el proceso. Ej: kill -9 1530 (mato el proceso 1530) \tn % Row Count 18 (+ 3) % Row 4 \SetRowColor{LightBackground} top & muestra procesos/recursos \tn % Row Count 19 (+ 1) % Row 5 \SetRowColor{white} htop & muestra procesos mas guay (puede que tengas que instalar algo) :) \tn % Row Count 22 (+ 3) % Row 6 \SetRowColor{LightBackground} tar comprimir & \$ tar -cvf nuevo.tar uno.txt dos.txt tres.txt \tn % Row Count 24 (+ 2) % Row 7 \SetRowColor{white} tar \seqsplit{descomprimir} & \$ tar -xvf archivo.tar \tn % Row Count 26 (+ 2) % Row 8 \SetRowColor{LightBackground} tar ver contenido & \$ tar -tf archivo.tar. \tn % Row Count 28 (+ 2) % Row 9 \SetRowColor{white} zip comprimir & \$ zip nuevo.zip uno.txt dos.txt tres.txt \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.0299 cm} x{2.4031 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Registros y Archivos (cont)}} \tn % Row 10 \SetRowColor{LightBackground} zip \seqsplit{descomprimir} & \$ unzip nuevo.zip \tn % Row Count 2 (+ 2) % Row 11 \SetRowColor{white} zip ver contenido & \$ unzip -v nuevo.zip \tn % Row Count 4 (+ 2) % Row 12 \SetRowColor{LightBackground} rar comprimir & \$ rar a nuevo.rar uno.txt dos.txt tres.txt \tn % Row Count 6 (+ 2) % Row 13 \SetRowColor{white} rar \seqsplit{descomprimir} & \$ rar x nuevo.rar \tn % Row Count 8 (+ 2) % Row 14 \SetRowColor{LightBackground} rar ver contenido & \$ rar v nuevo.rar o \$ rar | nuevo.rar \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}