ugly color for directories in gnome- terminal?
Some of my folders are highlighted in green
What does the green highlighting means? How can I remove the highlight and make them look similar to others?
terminal : gnome-terminal.
system : Ubuntu 16.04
36 Answers
The answer to your question is hidden in the answers to both What do the different colors mean in the terminal? and How do I change the color for directories with ls in the console?
The cause of the green highlighting is because your directories are writable by other (o+w) and not sticky.
So that explains why they have green highlighting, but you also ask how to remove it. You say "make it look like the others", by which I assume you mean normal directories. Open up your ~/.bashrc and append the following to the bottom:
export LS_COLORS="$LS_COLORS:ow=1;34:tw=1;34:"save the file and then run
source ~/.bashrcNow they will look the same as any other directory. Take note though that the system thinks this is information you should be able to see, by doing this you will no longer be able to see it easily. Consider choosing a different background color from the list here. I think purple isn't too bad (ow=1;34;45:)
Explanation:
ow stands for 'other, writable', tw is 'sticky, writable' (the other condition that has a green background). I found these values by examining the contents of $LS_COLORS on my system, looking for values with a background color of 42 (green). The color code has 3 columns (unused columns are left out):
bold;font-color;bg-color 3 This is because you have given write permission to other, meaning other than file owner and not in the group. Check permissions with ls -l or ll. Remove write permission from other by chmod 0755 directory_name, so it will look similar to other directories.
I did: 'chmod o-w -v -R *' to the directory I had trouble reading. It removes others write recursively. I may yet encounter other errors with this 'chmod' process. I'll report back if I come across errors.
1We can implement it with Python's os.listdir() method. Below is a Python example file: /mnt/home/uname/Documents/reverseVideo.py.
import os
from stat import *
class Rvideo: def __init__(self, path): self.pathname = path def other_no_write(self): td = self.pathname for f in os.listdir(td): path = os.path.join(td,f) mode = os.stat(path).st_mode if S_ISDIR(mode): os.chmod(path, mode & ~S_IWOTH & 0o777)Alternatively, one could code the last line like below:
os.chmod(path,oct(os.stat(path)[ST_MODE])[-3:])Then we can invoke it within a python3 interactive shell:
>>> sys.path.append("/mnt/home/uname/Documents/")
>>> from reverseVideo import Rvideo
>>> d = Rvideo("/some/directory")
>>> d.other_no_write() Just try the following commands instead:
ls -l --color=noor
dir -l 0 In my researches found that YouTube Video walk-trough starting at minute 9:50
To make it simple:
.In the root ~ folder create a .dircolors file with nano .dircolors
.Paste in that schema from articstudio Github
.In the root folder add this line in .bashrc: eval "$(dircolors ~/.dircolors)"
.Activate by typing this one at prompt again: source .bashrc
It worked for me at least. Feel free to watch all the Julian Nash video. Great content and channel.
0