Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I remove the background color for the sticky bit. LSCOLORS looks like this export LSCOLORS="Gxfxcxdxbxegedabagacad"

Using oh-my-zsh

Edit: As suggested I tested LSCOLORS="" ls but the colors are still there.

enter image description here

share|improve this question
    
What happens with the command LSCOLORS="" ls -ltr? –  mpez0 Apr 19 '11 at 11:21
    
You need LS_COLORS=, not LSCOLORS=. See man dircolors. –  Mikel Apr 20 '11 at 22:41

1 Answer 1

up vote 2 down vote accepted

Your example doesn't show the sticky bit, it shows setgid. (sticky is chmod +t, you have chmod g+s.)

Are you sure you need that? It seems wrong to me.

Setgid on a directory means that files created in that directory will have the group from the directory, not the user's primary group, so that's quite useful.

But setgid on a normal, non-executable file doesn't do anything useful.

I would suggest removing setgid from all files (but leave it on directories) like this:

find . -type f -exec chmod g-s {} \;

Or you could force a set of known permissions on files and directories using:

find . \( -type d -exec chmod g=rwsx {} \; \) -o \( -type f -exec chmod g=rw {} \; \)

And next time, rather than using chmod -R g+s or find -exec chmod g+s {} \;, do this:

find . -type d -exec chmod g+s {} \;

so that it only affects the directories.


Background

ls colors setgid files because if the file is also executable, it would run with extra permissions.

I think the idea is that the yellow and black highlighting is meant to make you look carefully at them, to make sure they are the ones you expect, and not some new file that was installed by a malicious user or a rootkit or something.

Run

find /usr -perm -2000

to see some examples of programs that use those permissions.

On my system it lists

/usr/bin/wall
/usr/bin/chage
/usr/bin/expiry
...

For example, the r-s on /usr/bin/wall

$ ls -l /usr/bin/wall
-rwxr-sr-x 1 root tty 9888 2008-04-29 11:57 /usr/bin/wall

means that the wall program can write output to any user's tty, even if it's not running as root.


If after all that, you still really want to change the colors, try something like this:

LS_COLORS=${LS_COLORS/sg=30;43:/sg=00:}

Where you put it depends on your setup, but at the end of ~/.zshrc should do it.

For some reason, removing the sg (setgid) entry makes it use the default colors, rather than no special colors.

share|improve this answer
    
Yes, I meant the setgid bit and not the sticky bit. I use the g+s with umask to allow multiple users to edit files that are owned by www-data. I still don't like the color and I really don't think ls is the right tool to hunt down rootkits. –  grm Apr 21 '11 at 22:04
    
You don't need g+s on the files, you need g+w on the files and g+ws on the directories. –  Mikel Apr 22 '11 at 0:38
    
Yes, you are right. Will correct that. Thanks! –  grm Apr 22 '11 at 7:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.