Green 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.

      Источник

      Thread: ls -> green colored .txt files

      sha1sum is offlineA Carafe of Ubuntu

      ls -> green colored .txt files

      When I type the command ls in the command line, the file names of certain text files are displayed in green. What does this mean?

      CharlesA is offlineWhat are you planning?

      Re: ls -> green colored .txt files

      It means they have execute permissions.

      You can verify that by running:

      Permissions can be altered by using chmod:

      Tomorrow’s an illusion and yesterday’s a dream, today is a solution.

      Iowan is offlineExpired admin

      Re: ls -> green colored .txt files

      Those look like executable files (scripts?).

      Oops — outtyped by CharlesA again.

      heir4c is offlineQuad Shot of Ubuntu

      Join Date Jan 2009 Location Belgium (Ghent) Beans 481 —> Beans 481 Distro Ubuntu 13.10 Saucy Salamander

      Re: ls -> green colored .txt files

      Dutch speaking; understand English, writing is a bit difficult. Member of: http://forum.ubuntu-nl.org
      be Open be Free be Ubuntu Reg. User #485479
      Ubuntu 13.10 Saucy Salamander — Ubuntu 14.04 Trusty Tahr

      sha1sum is offlineA Carafe of Ubuntu

      Re: ls -> green colored .txt files

      Thanks for the information guys.

      I found that indeed the .txt files were executable. I tried to change that using the following command:

      However it did not work, the permissions stayed -rwx——. When I moved the file to another directory however, the same command did work. What could be going on?

      • Site Areas
      • Settings
      • Private Messages
      • Subscriptions
      • Who’s Online
      • Search Forums
      • Forums Home
      • Forums
      • The Ubuntu Forum Community
        1. Ubuntu Official Flavours Support
          1. New to Ubuntu
          2. General Help
          3. Installation & Upgrades
          4. Hardware
          5. Desktop Environments
          6. Networking & Wireless
          7. Multimedia Software
        2. Ubuntu Specialised Support
          1. Ubuntu Development Version
          2. Security
          3. Virtualisation
          4. Ubuntu Servers, Cloud and Juju
            1. Server Platforms
            2. Ubuntu Cloud and Juju
          5. Gaming & Leisure
            1. Emulators
          6. Wine
          7. Development & Programming
            1. Packaging and Compiling Programs
            2. Development CD/DVD Image Testing
            3. Ubuntu Application Development
            4. Ubuntu Dev Link Forum
            5. Programming Talk
            6. Repositories & Backports
              1. Ubuntu Backports
                1. Bug Reports / Support
          8. System76 Support
          9. Apple Hardware Users
        3. Ubuntu Community Discussions
          1. Ubuntu, Linux and OS Chat
            1. Recurring Discussions
            2. Full Circle Magazine
          2. The Cafe
            1. Cafe Games
          3. Market
          4. Mobile Technology Discussions (CLOSED)
          5. Announcements & News
          6. Weekly Newsletter
          7. Membership Applications
          8. The Fridge Discussions
          9. Forum Council Agenda
          10. Forum Feedback & Help
            1. Request a LoCo forum
          11. Resolution Centre
        4. Other Discussion and Support
          1. Other OS Support and Projects
            1. Other Operating Systems
              1. Ubuntu/Debian BASED
              2. Debian
              3. MINT
              4. Arch and derivatives
              5. Fedora/RedHat and derivatives
              6. Mandriva/Mageia
              7. Slackware and derivatives
              8. openSUSE and SUSE Linux Enterprise
              9. Mac OSX
              10. PCLinuxOS
              11. Gentoo and derivatives
              12. Windows
              13. BSD
              14. Any Other OS
          2. Assistive Technology & Accessibility
          3. Art & Design
          4. Education & Science
          5. Documentation and Community Wiki Discussions
          6. Tutorials
            1. Outdated Tutorials & Tips
          7. Ubuntu Women
          8. Ubuntu LoCo Team Forums
            1. Americas LoCo Teams
              1. Argentina Team
                1. Software
                2. Hardware
                3. Comunidad
              2. Arizona Team — US
              3. Arkansas Team — US
              4. Brazil Team
              5. California Team — US
              6. Canada Team
              7. Centroamerica Team
              8. Chile Team
                1. Comunidad
                2. Hardware
                3. Software
                4. Instalaci�n y Actualizaci�n
              9. Colombia Team — Colombia
              10. Georgia Team — US
              11. Illinois Team
              12. Indiana — US
              13. Kentucky Team — US
              14. Maine Team — US
              15. Minnesota Team — US
              16. Mississippi Team — US
              17. Nebraska Team — US
              18. New Mexico Team — US
              19. New York — US
              20. North Carolina Team — US
              21. Ohio Team — US
              22. Oklahoma Team — US
              23. Oregon Team — US
              24. Pennsylvania Team — US
              25. Peru Team
              26. Texas Team — US
              27. Uruguay Team
              28. Utah Team — US
              29. Virginia Team — US
              30. West Virginia Team — US
            2. Asia and Oceania LoCo Teams
              1. Australia Team
              2. Bangladesh Team
              3. Hong Kong Team
              4. Myanmar Team
              5. Philippine Team
              6. Singapore Team
            3. Europe, Middle East, and African (EMEA) LoCo Teams
              1. Albania Team
              2. Catalan Team
              3. Portugal Team
              4. Egypt Team
              5. Georgia Team
              6. Ireland Team — Ireland
              7. Kenyan Team — Kenya
              8. Kurdish Team — Kurdistan
              9. Lebanon Team
              10. Morocco Team
              11. Saudi Arabia Team
              12. Sudan Team
              13. Tunisia Team
            4. Other Forums & Teams
            5. LoCo Archive
              1. Afghanistan Team
              2. Alabama Team — US
              3. Alaska Team — US
              4. Algerian Team
              5. Andhra Pradesh Team — India
              6. Austria Team
              7. Bangalore Team
              8. Bolivia Team
              9. Cameroon Team
              10. Colorado Team — US
              11. Connecticut Team
              12. Costa Rica Team
              13. Delhi Team
              14. Ecuador Team
              15. El Salvador Team
              16. Florida Team — US
              17. Galician LoCo Team
              18. Greek team
              19. Hawaii Team — US
              20. Honduras Team
              21. Idaho Team — US
              22. Iowa Team — US
              23. Jordan Team
              24. Kansas Team — US
              25. Libya Team
              26. Louisiana Team — US
              27. Maryland Team — US
              28. Massachusetts Team
              29. Michigan Team — US
              30. Missouri Team — US
              31. Montana Team — US
              32. Namibia Team
              33. Nevada Team — US
              34. New Hampshire Team — US
              35. New Jersey Team — US
              36. Northeastern Team — US
              37. Panama Team
              38. Paraguay Team
              39. Qatar Team
              40. Quebec Team
              41. Rhode Island Team — US
              42. Senegal Team
              43. South Carolina Team — US
              44. South Dakota Team — US
              45. Switzerland Team
              46. Tamil Team — India
              47. Tennessee Team — US
              48. Trinidad & Tobago Team
              49. Uganda Team
              50. United Kingdom Team
              51. US LoCo Teams
              52. Venezuela Team
              53. Wales Team
              54. Washington DC Team — US
              55. Washington State Team — US
              56. Wisconsin Team
              57. Yemen Team
              58. Za Team — South Africa
              59. Zimbabwe Team

      Bookmarks

      Bookmarks

      Posting Permissions

      • You may not post new threads
      • You may not post replies
      • You may not post attachments
      • You may not edit your posts

      Источник

      Читайте также:  Linux mint темы окон
Оцените статью
Adblock
detector