Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-11-2005, 03:32 PM
|
#1
|
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,466
Rep: 
|
Questions about su, su -, shells and terminal colours
Firstly, I appreciate my title doesn't make a lot of sense (and yes, I've spelt colours correctly  )! Now, I have seen in various threads around LQ, people telling others to change to root with "su -". From the man page for su (albeit not the one on my system, I had to look it up online :/) I've found that the - is for a login shell. My first question is, why would one use this instead of simply "su"?
Seeing as it's a login shell, I get a quote from fortune when I log in with "su -". Is there any way to make it so that when I open a terminal window, instead of seeing just my "nick@nick:~$" prompt, I see a quote from fortune as well? I'm sure I've seen this in screenshots, but I can't remember where  . I use Xfce and the command used to open a terminal is "xfterm4".
When I issue "ls" in a terminal, directories appear in blue and executable files in green. I did this by editing (or creating) a .bashrc and copying a line I found in a sample .bashrc on the web:
alias ls='ls -hF --color'.
If I now issue "ls" after logging in with "su -", in addition to the colouring above, I have .wmv, .jpg files coloured in magenta and archives like .tar.gz and .zip in red. How do I get that extra colourin g in a "normal" shell?
Hopefully this makes some sort of sense and any help is appreciated!
|
|
|
|
08-11-2005, 04:07 PM
|
#2
|
|
Senior Member
Registered: Jan 2003
Posts: 2,786
|
When issuing su -, you create a login shell (as you mentioned). When you start a login shell your startup files are read. That means (if your shell is bash) /etc/profile, ~/.bash_profile, and ~/.bashrc are read in. That's important because, typically, root has different paths, different aliases, and different settings in general than normal users. It's the path change that usually gives people problems. If you just issue su without the dash, then you're not likely to have any of the sbin directories in your path. There would be a "command not found" error for utilities such as fdisk, shutdown, etc.
As for your fortune problem, you'll need to read the documentation for xfterm. It likely has a number of command line options that you can use to run fortune when you start, or a configuration file that would accomplish the same thing. I've never used it before, so I'm afraid I can't help much beyond that.
For the file colors on ls, again, that's a configuration thing. There are (at least) two files that control that behavior: /etc/dir_colors and ~/.dir_colors. Well, that's off the top of my head, they may be slightly different and/or in slightly different location. Anyway, the point is, the configuration file in your home directory will override the one located in /etc. If there is no personal configuration, the file in /etc is used. If there are no configuration at all, then ls may use a default color scheme, or maybe no colors at all.
|
|
|
|
08-11-2005, 04:09 PM
|
#3
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,916
|
Re: Questions about su, su -, shells and terminal colours
Quote:
Originally posted by Nylex
Firstly, I appreciate my title doesn't make a lot of sense (and yes, I've spelt colours correctly ;))! Now, I have seen in various threads around LQ, people telling others to change to root with "su -". From the man page for su (albeit not the one on my system, I had to look it up online :/) I've found that the - is for a login shell. My first question is, why would one use this instead of simply "su"?
|
So you get roots environment and not the current users.
Important for things that live in */sbin directories, for instance,
which a normal user commonly won't have in his path but
root may want to be able to use.
Quote:
Originally posted by Nylex
Seeing as it's a login shell, I get a quote from fortune when I log in with "su -". Is there any way to make it so that when I open a terminal window, instead of seeing just my "nick@nick:~$" prompt, I see a quote from fortune as well? I'm sure I've seen this in screenshots, but I can't remember where :(. I use Xfce and the command used to open a terminal is "xfterm4".
|
The fastest would be to source /etc/profile from
~/.bashrc
Quote:
Originally posted by Nylex
When I issue "ls" in a terminal, directories appear in blue and executable files in green. I did this by editing (or creating) a .bashrc and copying a line I found in a sample .bashrc on the web:
alias ls='ls -hF --color'.
If I now issue "ls" after logging in with "su -", in addition to the colouring above, I have .wmv, .jpg files coloured in magenta and archives like .tar.gz and .zip in red. How do I get that extra colourin g in a "normal" shell?
|
I don't understand that question. If you have colouring going,
all colours will be there. Just go into a directory that has those
files ...
All your alias does is to a) [-h] make file-sizes with extensions,
b) [-F] append a special character for certain and c) [--color]
turn colours on. There's no statement in there that influences
what gets which colour.
Cheers,
Tink
|
|
|
|
08-13-2005, 01:29 AM
|
#4
|
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,466
Original Poster
Rep: 
|
Thanks for the replies, I think I sort of understand  . Would you also use "su -" if root used a different shell, or is that not possible?
It seems that the documentation for Xfce is pretty sucky, to be honest  . Tink, what do you mean by "source /etc/profile from ~/.bashrc"? Also is it normal on Slackware (if anyone knows) for the .bashrc file to not be there when you install? I had to create mine.
Here is a screenshot of what I mean about the colouring. Both terminals show my home folder, the one on the left is the "normal" one and the other is from doing "su -". I get the same output if I do "su - nick" and then issue "ls".
|
|
|
|
08-13-2005, 02:59 AM
|
#5
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,916
|
Quote:
Originally posted by Nylex
Thanks for the replies, I think I sort of understand :).
Would you also use "su -" if root used a different shell,
or is that not possible?
|
Sure, no problem.
Quote:
Originally posted by Nylex
It seems that the documentation for Xfce is pretty sucky,
to be honest :(. Tink, what do you mean by "source /etc/profile
from ~/.bashrc"?
|
in ~/.bashrc
. /etc/profile
Quote:
Originally posted by Nylex
Also is it normal on Slackware (if anyone knows)
for the .bashrc file to not be there when you install? I had to create mine.
|
That's normal. Slack *IS* minimalistic.
Quote:
Originally posted by Nylex
Here is a screenshot of what I mean
about the colouring. Both terminals show my home folder,
the one on the left is the "normal" one and the other is from
doing "su -". I get the same output if I do "su - nick" and
then issue "ls".
|
That's odd...
/etc/profile fires up dircolors, which in turn gets
the definitions for colourisation from /etc/DIR_COLORS.
Unless you have an ~/.dir_colors that differs from /etc/DIR_COLORS
I can't explain how those different schemes come about.
Cheers,
Tink
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 09:54 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|