Did you know LQ has a Linux Hardware Compatibility List?
Go Back > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Slackware This Forum is for the discussion of Slackware Linux.


  Search this Thread
Old 07-13-2003, 11:45 PM   #1
Registered: Jul 2003
Posts: 38

Rep: Reputation: 15
Shell Prompts and root ls colouring

Hello. I have two questions. First of all, normally when I am
at a console I get the default shell prompt, which is like iantri@waffle:/etc$. However, when I open an xterm I only f
get sh-2.05b. How do I set things so that I get the same style shell prompt under an xterm?

Also, when I log in as root I get the pretty colouring on my
ls listings. But, when I su to root I don't. Why does this happen like this, and how can I change it so I get coloured
ls listings either way?

Thank you.
Ian Trider

Old 07-14-2003, 12:04 AM   #2
Senior Member
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Add -ls to whatever arguments start your xterm, whether in a window manager menu or .xinitrc or whatever. There may be a better way, but that makes it a log-in shell and causes it to source your bash configuration files.

Not sure about the second one except that it's probably a similar thing. You might have a DIR_COLORS entry in your user bash files and not in root's or something.
Old 07-14-2003, 12:05 AM   #3
LQ Guru
Registered: Mar 2003
Location: New Jersey
Distribution: Arch Linux
Posts: 1,445

Rep: Reputation: 46
First, searching the forums should give you the answer to both those questions.

The first one: You get that [user]@[host]: When youve just switched users or logged in. So logging in in an xterm will give you that.

Second question, the easiest way to get color is to make an alias to "ls --color"

make a file: ~/.bashrc and add:

alias "ls"="ls --color"

Save, and restart the terminal.
Old 07-14-2003, 10:34 AM   #4
Registered: Jul 2003
Posts: 38

Original Poster
Rep: Reputation: 15
Thank you for your answers although I think I found out what I need this morning while looking through some Linux from Scratch information.

I think what this is saying is that .bash_profile (or /etc/profile) is invoked when you login, and that .bashrc (or /etc/bashrc) is invoked when bash is started, but is not a login shell.

This would mean that if I am iantri and I su to root, it invokes bashrc which I'm assuming does not have ls colours set. This also means that if I am iantri and I open an xterm that bash is invoked, but not as a login shell and so bashrc is used.

If I put my PS1 variable and the alias from LS to LS --colour which are in /etc/profile (or my .bash_profile) I should get the same things either way, correct?

Thank you,
Ian Trider.
Old 07-14-2003, 10:59 AM   #5
LQ Guru
Registered: Feb 2003
Location: Sparta, NC USA
Distribution: Ubuntu 10.04
Posts: 5,141

Rep: Reputation: 58
I put it in my user's .bashrc file:
# Duron 950 uilleann .bashrc for user fancy
# User specific aliases and functions

# Change bash prompt. See the article
export PS1='\d \@ \[\e[32;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[32;1m\] $ \[\e[0m\]'
# For the root account use this
# export PS1='\d \@ \[\e[31;1m\]\u\[\e[34;1m\]@\[\e[36;1m\]\H \[\e[34;1m\]\w\[\e[31;1m\] # \[\e[0m\]'

# Set paths
alias path='echo -e ${PATH//:/\\n}'

# Allow local users to use my X session
# xhost +local:

# Dialup, start fetchmail daemon and startx
alias x='/sbin/ifup ppp0;fetchmail -d 300;startx'

# Alter the ls command
alias ls='ls -ac'
alias lls='ls -lac'
Old 07-17-2003, 01:16 AM   #6
LQ Newbie
Registered: Jul 2003
Location: Sydney, Australia
Distribution: Slackware
Posts: 7

Rep: Reputation: 0
Whenever I've wanted to su to root and have colours, I've just used su - instead of just plain su.

Works for me!
Old 07-17-2003, 04:10 AM   #7
Registered: Nov 2002
Distribution: A totally 133t distro :)
Posts: 358

Rep: Reputation: 31
I like machine specific prompts with the time included, this one has reverse video:

\033[1;31m\]> \[\033[0m\]"

much the same, no reverse video:

\[\033[1;31m\]$ \[\033[0m\]"
Old 07-27-2003, 04:39 PM   #8
LQ Newbie
Registered: Apr 2002
Location: West Central Texas
Distribution: Slackware 7.0
Posts: 2

Rep: Reputation: 0
PS1 Variable on Console and in xterm

I found an easier way to change the PS1 Environmental Variable.
I modify the /etc/profile file to what ever prompt I want for the console eg. PS1-'[\u@h:\W]$'
This gives me the following prompt:
It shows who is logged in and the present working directory.
As far as the xterm goes, I put the same line except for 1 difference ,in xinitrc.twm right before the line that says
export PS1='[\u@\h:\W]$'
Now I get the same prompt in the Xwindow as I get on the console.
Hope this helps.
Old 07-28-2003, 05:06 AM   #9
Registered: Jul 2003
Location: --> X <-- You are here.
Distribution: Slackware
Posts: 263

Rep: Reputation: 31
This is what I use for *every* user:

dircolors > ~/.bashrc

Short, sweet, and to the point...
Old 09-11-2003, 05:50 PM   #10
LQ Newbie
Registered: Sep 2003
Posts: 1

Rep: Reputation: 0
Help with Bash (shell script)

Does anyone know how to enable the time and the current working directory to be displayed once I login to use bash; someone said something about .bashrc; how do I access and edit this file to get it display what I need. -thanks
Old 09-11-2003, 09:48 PM   #11
Registered: Apr 2003
Distribution: Slackware
Posts: 345
Blog Entries: 5

Rep: Reputation: 30
My reasons for using the ls command really do not include being able to see a pretty display of colors.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
changing root shell surfbass Linux - General 1 10-28-2005 03:03 PM
How to login root shell satimis Linux From Scratch 7 07-11-2005 09:07 PM
Shell prompts and keymaps amnesty_puppy Linux - Newbie 8 08-17-2004 07:52 PM
Bad root shell Tyraziel Linux - General 2 04-08-2004 11:08 AM
su to root in my shell script? lel800 Programming 2 08-21-2003 12:03 AM

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration