Red files in linux

What do the different colors mean in ls?

What do the different colours in Ubuntu’s ls command mean? For example, when I type the ls command in one of my folders, I get one of the files in light green, the other (which is a folder) in blue with green highlighting. What do those colours mean, and there is any manual about all the colours?

5 Answers 5

  • Blue: Directory
  • Green: Executable or recognized data file
  • Cyan (Sky Blue): Symbolic link file
  • Yellow with black background: Device
  • Magenta (Pink): Graphic image file
  • Red: Archive file
  • Red with black background: Broken link

    To turn the color off, you have to comment out the following lines in .bashrc .

# enable color support of ls and also add handy aliases #if [ -x /usr/bin/dircolors ]; then # test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" # alias ls='ls --color=auto' # #alias dir='dir --color=auto' # #alias vdir='vdir --color=auto' # # alias grep='grep --color=auto' # alias fgrep='fgrep --color=auto' # alias egrep='egrep --color=auto' #fi 
eval $(echo "no:global default;fi:normal file;di:directory;ln:symbolic link;pi:named pipe;so:socket;do:door;bd:block device;cd:character device;or:orphan symlink;mi:missing file;su:set uid;sg:set gid;tw:sticky other writable;ow:other writable;st:sticky;ex:executable;"|sed -e 's/:/="/g; s/\;/"\n/g') < IFS=: for i in $LS_COLORS do echo -e "\e[$m$( x=$; [ "$" ] && echo "$" || echo "$x" )\e[m" done > 

You can find out what colours ls uses by looking at the $LS_COLORS variable:

  • Turquoise: audio files 1
  • Bright Red: Archives and compressed files 2
  • Purple: images and videos 3

In addition, files are colourised by attributes:

alt text

  1. aac, au, flac, mid, midi, mka, mp3, mpc, ogg, ra, wav, axa, oga, spx, xspf.
  2. tar, tgz, arj, taz, lzh, lzma, tlz, txz, zip, z, Z, dz, gz, lz, xz, bz2, bz, tbz, tbz2, tz, deb, rpm, jar, rar, ace, zoo, cpio, 7z, rz.
  3. jpg, jpeg, gif, bmp, pbm, pgm, ppm, tga, xbm, xpm, tif, tiff, png, svg, svgz, mng, pcx, mov, mpg, mpeg, m2v, mkv, ogm, mp4, m4v, mp4v, vob, qt, nuv, wmv, asf, rm, rmvb, flc, avi, fli, flv, gl, dl, xcf, xwd, yuv, cgm, emf, axv, anx, ogv, ogx.

All this information is contained in the output of dircolors —print-database , but its formatting is rather unreadable.

Here’s a technical explanation of what’s happening:

The colour code consists of three parts:

  • The first part before the semicolon represents the text style.
    • 00=none, 01=bold, 04=underscore, 05=blink, 07=reverse, 08=concealed.
    • 30=black, 31=red, 32=green, 33=yellow, 34=blue, 35=magenta, 36=cyan, 37=white.

    Each part can be omitted, assuming starting on the left. i.e. «01» means bold, «01;31» means bold and red. And you would get your terminal to print in colour by escaping the instruction with \33[ and ending it with an m . 33, or 1B in hexadecimal, is the ASCII sign «ESCAPE» (a special character in the ASCII character set). Example:

    Prints «Hello World» in bright red.

    The command ls with the argument —color=auto (on Ubuntu, ls is an alias for ls —color=auto ) goes through all the file names and tries first to match different types, like Executable, Pipe and so on. It then tries to match regular expressions like *.wav and prints the resulting filename, enclosed in these colour-changing instructions for bash.

    Thanks! I was looking at a Git topology visualization question and wondered why some of the characters were being printed.

    Full list, with the default setup

    • Uncolored (white):
      • file
      • non-filename text (e.g. permissions in the output of ls -l )
      • multi-hardlink file
      • image file, video, graphic, etc.
      • door
      • socket
      • block device
      • character device
      • orphan symlink
      • missing file

      Note that bold red looks orange, black looks dark grey, cyan looks blue/green, and bold magenta looks purple/pink/lavender.

      Script to show colors

      #!/bin/bash # For each entry in LS_COLORS, print the type, and description if available, # in the relevant color. # If two adjacent colors are the same, keep them on one line. declare -A descriptions=( [bd]="block device" [ca]="file with capability" [cd]="character device" [di]="directory" [do]="door" [ex]="executable file" [fi]="regular file" [ln]="symbolic link" [mh]="multi-hardlink" [mi]="missing file" [no]="normal non-filename text" [or]="orphan symlink" [ow]="other-writable directory" [pi]="named pipe, AKA FIFO" [rs]="reset to no color" [sg]="set-group-ID" [so]="socket" [st]="sticky directory" [su]="set-user-ID" [tw]="sticky and other-writable directory" ) IFS=: for ls_color in $LS_COLORS; do color="$" type="$" # Add description for named types. desc="$" # Separate each color with a newline. if [[ $color_prev ]] && [[ $color != "$color_prev" ]]; then echo fi printf "\e[%sm%s%s\e[m " "$color" "$type" "$" # For next loop color_prev="$color" done echo 

      Output with default setup:

      gnome-terminal screenshot - default

      gnome-terminal screenshot - custom

      I got the descriptions from dircolors -p and man dir_colors , and filled in the gaps with my own research.

      The colors and descriptions are the same from at least 14.04 to 17.10.

      @FredrickGauss Not explicitly, but «RESET» is the only one that can be abbreviated as «rs», and the color (0) matches.

      If you type dircolors ( echo $LS_COLORS also works) from command line you will get a list of codes and colors for lots of filetypes in 1 line. dircolors —print-database shows them 1 line at a time. Here is a short list (I tried to put in the most important ones). At the bottom there is an explanation about what the different codes at the end of each lines represents:

      NORMAL 00 # global default, although everything should be something. FILE 00 # normal file DIR 01;34 # directory LINK 01;36 # symbolic link. (If you set this to 'target' instead of a # numerical value, the color is as for the file pointed to.) FIFO 40;33 # pipe SOCK 01;35 # socket DOOR 01;35 # door BLK 40;33;01 # block device driver CHR 40;33;01 # character device driver ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file SETUID 37;41 # file that is setuid (u+s) SETGID 30;43 # file that is setgid (g+s) STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w) OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable # archives or compressed (bright red) .tar 01;31 .tgz 01;31 # image formats .jpg 01;35 .jpeg 01;35 .gif 01;35 .bmp 01;35 # audio formats .aac 00;36 .flac 00;36 .ogg 00;36
      • Attribute codes: 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
      • Text color codes: 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
      • Background color codes: 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white

      If you want to play around with this here is an example on how to set a color for a file:

      export LS_COLORS=$LS_COLORS:"*.ogg=01;35":"*.mp3=01;35" 

      This will set *.ogg and .mp3 to bold magenta . And if you put it in your .bashrc file it will become permanent.

      Источник

      why ls -a command showing file name in red color? [duplicate]

      enter image description here

      As shown in the above picture, When I do the command ls -a is one specific file name in red color. Why is it so?

      @kos your linked article says red is for archive file but then why is all other files displayed in green and just this one in red.. All files are jar files only.

      That is explained in the link as well. Sky blue = symbolic link. Try running ls -la , you’ll see that permissions for the sky blue files will start with an l and that their filename will be something like ant-antlr.jar -> /some/other/path .

      1 Answer 1

      The colours from ls are as follows:

      • Blue: Directory
      • Green: Executable or recognized data file
      • Sky Blue: Link
      • Yellow (black background): Device file
      • Pink: Graphics image file
      • Red: File Archive

      cf: What do the different colors mean in ls? So most of the files are links, apart from the non-link file archive which is red.

      OK, sorry, I wanted to clarify why there seemed an inconsistency between the similar looking archives. Cross referenced link added.

      Sorry about that, but I think you can understand how it looked from an external point of view. I removed my downvote, but really, you should vote to close duplicate questions instead of answering them: meta.askubuntu.com/questions/14279/….

      Your name is familiar. Are you the Colin Ian King I referenced in askubuntu.com/a/711465/158442? If so, can you give an authoritative answer there?

      Red may also happen to mean a broken link (a link to a nonexistent file path). I am not sure about Ubuntu as I have migrated to Manjaro with KDE5 seeking more Unity-like experience as Unity has been discontinued but at my system (Manjaro, recent KDE5 Konsole, FISH shell) it shows a broken link in red.

      Источник

      Files in red, what do they mean

      What does it mean when a file is in red. I change into one of my directories and run ls and it shows these files I’ve never seen in red. duplicity-full.20120405T013825Z.vol10.difftar.gz and goes all the way to vol 20. What does this mean?

      3 Answers 3

      Red means the file is compressed. The .gz extension means it was gzipped.

      It means more than that, especially if the OP didn’t use the Duplicity tool to create these backups (that’s what these archives are. See my answer for more info.

      What it probably means is that ls is aliased to ls —color=auto or ls —color=always . To check whether this is the case, you can run command ls , or /bin/ls, to get around the aliasing (and, if I’m right, it should print without special colors).

      That being said, one of the ways you can figure out what the color means is through the documentation for ls , and by running dircolors . Or you can simply run file on the file to see what kind of thing your computer thinks the file is (IIRC, ls uses file to determine how it should colorize).

      Incidentally, coloring can change based on terminal, platform, and shell, but red usually means either that the file is an archive, or that it is an executable.

      A *.gz file is an archive, and I assume that you’re accessing via terminal (there’s no info to suggest that you’re accessing via GUI).

      Files highlighed in red in the terminal are archives, and are normally used by some applications to back-up their content.

      Looking at the file names, they seem to be backups of your hard disk. If you never intended to use Duplicity, then I strongly advise you to run a full virus/malware/spyware scan on your system, and to take your system offline while doing so. If possible, have a look at your network logs to see if these files are being sent out; if so, this means that hackers are stealing your data.

      It should be noted that the actual file type can differ from the extension (after all, the extension is mostly there to be human-readable)- the actual file type is stored as a signature within the file (these are also known as «magic bytes» and «magic numbers»). You can find out about these signatures here.

      Also, your example file seems to have been created on 4th May 2012 (or 5th April 2012, if you’re European), so they’re extremely old (by the standards of backups). Ask anyone else who had access to the system on this date if they know anything about this.

      Источник

      Читайте также:  Configure and make linux
Оцените статью
Adblock
detector