LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   folder/file highlights vanish when changing user (https://www.linuxquestions.org/questions/linux-newbie-8/folder-file-highlights-vanish-when-changing-user-949385/)

Eerie 06-09-2012 11:36 AM

folder/file highlights vanish when changing user
 
1 Attachment(s)
Hey, I'm using Slackware 13.37 32-bit and there's this little aesthetic problem I've got here.

When I open a new bash it highlights folders and certain extensions when I print them. But as soon as I change user it's all in one colour for the rest of the session.

Any idea how I can make that stick?

(on a completely unrelated note, can someone tell me how to make sudo work? I have a root account but the password for su doesn't work for sudo.)

Thanks in advance.

DavidMcCann 06-09-2012 11:45 AM

Each user will have separate configuration for bash: one's been set for colour, the other isn't.

The password for sudo is your own one, not the root one. You also need to set up the service: see the man page for sudoers. You edit the sudoers file with the command visudo.

Eerie 06-09-2012 11:50 AM

That doesn't seem to be what's causing it to disappear though.
Because even when I change back to the user the colours are still gone.
Also, if I logged into root to begin with and then opened a bash the colours are there as well.

And thanks for the sudo help. I'll look into that.

colucix 06-09-2012 12:09 PM

Please, try to see what is the output of the following command for each of the three cases (normal user see colors, switching to root colors disappear, switching to previous user colors still disappeared) and post the output here.
Code:

alias ls
Moreover, take in mind that adding a minus sign as argument of the su command set the environment for the new user. Try what happens with and without it:
Code:

su -
Finally, what happen if you switch back to the previous user, in place of using su again? I mean:
Code:

nado$ ls
nado$ su
root# ls
root# exit
nado# ls

in sequence.

Eerie 06-09-2012 12:40 PM

usr:
from a fresh shell:
Code:

nado@ass:~$ alias ls
alias ls='/bin/ls $LS_OPTIONS'
nado@ass:~$ su
Password:
root@ass:/home/nado# alias ls
bash: alias: ls: not found
root@ass:/home/nado# su nado
nado@ass:~$ alias ls
bash: alias: ls: not found
nado@ass:~$

interesting, the su - preserves the highlighting and also prints these quotes (that you can see at the top of screenshot in my first post)
Similarly with exit, regardless of whether I use
Code:

su -
prior or
Code:

su
. Though it doesn't print new funny/smart quotes. But it prints
Code:

logout
and keeps the colours alive.




Quote:

Originally Posted by colucix (Post 4699518)
Please, try to see what is the output of the following command for each of the three cases (normal user see colors, switching to root colors disappear, switching to previous user colors still disappeared) and post the output here.
Code:

alias ls
Moreover, take in mind that adding a minus sign as argument of the su command set the environment for the new user. Try what happens with and without it:
Code:

su -
Finally, what happen if you switch back to the previous user, in place of using su again? I mean:
Code:

nado$ ls
nado$ su
root# ls
root# exit
nado# ls

in sequence.


colucix 06-09-2012 01:25 PM

Most likely, both the quote and the alias to the ls command come from the user's shell configuration files. As mentioned the minus sign as first argument of su preserve the user's own environment, that is switching this way it executes all the statement inside the configuration files placed in the user's home directory.
The quote comes from the fortune command. You may check where it's placed in your hidden files under your home directory, together with the alias definition, e.g
Code:

nado$ grep -E 'fortune|alias *ls' $HOME/.*
You may also check the value of the environment variable $LS_OPTIONS (where defined) to see if the --color option of ls appears.

The question now is: which configuration files are sourced and in which situation (login shell, interactive non-login shell, switching user w/ or w/o minus sign and so on)? You can try to answer by reading http://www.gnu.org/software/bash/man...#Invoking-Bash and the next chapter http://www.gnu.org/software/bash/man...-Startup-Files (assuming you're using bash as default shell) plus
Code:

man su
Since there are multiple options depending on the presence/absence of some files, you have to investigate your system and the users' set-up directly on your machine. Hope this helps.

Eerie 06-10-2012 10:21 AM

I've tried some of the things and it's giving me a lot of information. But I really need to sit down and spend some time here.

Thanks to su - and exit my problem is solved, but for the sake of understanding my system I'll leave the thread unsolved.

Thanks for helping out!


All times are GMT -5. The time now is 05:26 AM.