====== ls ====== Programa que permite listar ficheros y directorios Ejemplo: $ ls -l /etc/ total 1384 -rw-r--r--. 1 root root 16 mar 10 2016 adjtime -rw-r--r--. 1 root root 1518 jun 7 2013 aliases -rw-r--r--. 1 root root 12288 feb 23 2017 aliases.db drwxr-xr-x. 2 root root 4096 oct 9 2018 alternatives -rw-------. 1 root root 541 abr 21 2015 anacrontab -rw-r--r--. 1 root root 55 sep 16 2014 asound.conf -rw-r--r--. 1 root root 5 mar 10 2016 at.allow drwxr-x---. 3 root root 41 feb 20 2017 audisp drwxr-x---. 3 root root 102 feb 20 2017 audit drwxr-xr-x. 2 root root 33 mar 10 2016 avahi -rw-r--r--. 1 root root 2863 mar 10 2016 bash.20150601 drwxr-xr-x. 2 root root 4096 feb 20 2017 bash_completion.d -rw-r--r--. 1 root root 2863 mar 10 2016 bashrc -rw-r--r--. 1 root root 2835 mar 10 2016 bashrc.20160310 ===== Colores ===== ''ls'' toma los colores que estén definidos en la variable de entorno ''LS_COLORS'' Podemos incluir la personalización de esta variable de entorno en el fichero ''.bashrc'' de nuestro directorio personal: export LS_COLORS="$LS_COLORS:st=38;5;86;48;5;234:ow=38;5;220;1:tw=48;5;235;38;5;139;3:di=38;5;30:bd=38;5;68:cd=38;5;113;1:ex=38;5;208;1:fi=0:no=0:ln=38;5;45:" Aplicamos los cambios saliendo de la sesión y entrando de nuevo o ''source $HOME/.bashrc'' Posibilidades de efectos: ^ Valor ^ Descripción ^ | 0 | Color por defecto | | 1 | Negrita | | 4 | Subrayado | | 5 | Parpadeo | | 7 | Intercambia los colores de texto y de fondo | | 8 | Invisible | Posibilidades de colores: ^ Valor ^ Descripción ^ | 30 | Negro | | 31 | Rojo | | 32 | Verde | | 33 | Naranja | | 34 | Azul | | 35 | Morado | | 36 | Cián | | 37 | Gris | | 90 | Gris oscuro | | 91 | Rojo claro | | 92 | Verde claro | | 93 | Amarillo | | 94 | Azul claro | | 95 | Morado claro | | 96 | Turquesa | | 97 | Blanco | Posibilidades de fondos: ^ Valor ^ Descripción ^ | 40 | Negro | | 41 | Rojo | | 42 | Verde | | 43 | Naranja | | 44 | Azul | | 45 | Morado | | 46 | Cián | | 47 | Gris | | 100 | Gris oscuro | | 101 | Rojo claro | | 102 | Verde claro | | 103 | Amarillo | | 104 | Azul claro | | 105 | Morado claro | | 106 | Turquesa | | 107 | Blanco | Tipos de ficheros: ^ Valor ^ Descripción ^ | ''bd'' | = (BLOCK, BLK) Block device (buffered) special file | | ''cd'' | = (CHAR, CHR) Character device (unbuffered) special file | | ''di'' | = (DIR) Directory | | ''do'' | = (DOOR) [Door][1] | | ''ex'' | = (EXEC) Executable file (ie. has 'x' set in permissions) | | ''fi'' | = (FILE) Normal file | | ''ln'' | = (SYMLINK, LINK, LNK) Symbolic link. If you set this to ‘target’ instead of a numerical value, the color is as for the file pointed to. | | ''mi'' | = (MISSING) Non-existent file pointed to by a symbolic link (visible when you type ls -l) | | ''no'' | = (NORMAL, NORM) Normal (non-filename) text. Global default, although everything should be something | | ''or'' | = (ORPHAN) Symbolic link pointing to an orphaned non-existent file | | ''ow'' | = (OTHER_WRITABLE) Directory that is other-writable (o+w) and not sticky | | ''pi'' | = (FIFO, PIPE) Named pipe (fifo file) | | ''sg'' | = (SETGID) File that is setgid (g+s) | | ''so'' | = (SOCK) Socket file | | ''st'' | = (STICKY) Directory with the sticky bit set (+t) and not other-writable | | ''su'' | = (SETUID) File that is setuid (u+s) | | ''tw'' | = (STICKY_OTHER_WRITABLE) Directory that is sticky and other-writable (+t,o+w) | | ''*.extension'' | = Every file using this extension e.g. *.rpm = files with the ending .rpm | * [[https://geoff.greer.fm/lscolors/|LS_COLORS generator]] * [[https://github.com/trapd00r/LS_COLORS|Colección de definiciones para LS_COLORS]] (GitHub) ==== Script ==== Para comprobar rápidamente cómo se ven todos los colores y estilos en la terminal, se pueden usar los siguientes scripts: for i in 00{2..8} {0{3,4,9},10}{0..7} do echo -e "$i \e[0;${i}mEsto es un texto\e[00m \e[1;${i}mEsto es un texto\e[00m" done {{ :informatica:sistemas_operativos:linux:coreutils:ls_colors_script.png?nolink |}} Con este otro se muestran todos los colores en negrita o con su color por defecto: for i in 00{2..8} {0{3,4,9},10}{0..7} do for j in 0 1 do echo -e "$j;$i \e[$j;${i}mEsto es un texto\e[00m" done done