LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-12-2007, 08:00 PM   #1
micko_escalade
LQ Newbie
 
Registered: Feb 2006
Distribution: Fedora Core 6
Posts: 6

Rep: Reputation: 0
Why do I have type this source /etc/bashrc to get [root@fedora6-01 ~]# ?


Hi,

When I login as root I get this on command prompt -bash-3.1#
if I enter this source /etc/bashrc I get "regular" prompt
[root@fedora6-01 ~]#
Why is this happening?
 
Old 07-12-2007, 08:19 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
It depends on just how you've set things up to get the "regular" prompt.

Do this at the command line:

Code:
man bash
and all will be revealed.

Hope this helps.
 
Old 07-12-2007, 08:33 PM   #3
alexander_bosakov
Member
 
Registered: Mar 2006
Location: Plovdiv, Bulgaria
Distribution: OpenSuse 11.3
Posts: 55

Rep: Reputation: 15
Executing the content of "/etc/bashrc" sets the prompt variables. It's a shell script, just read it for more details. Te variables of interest in your case are named PS1, PS2, ... and PROMPT_COMMAND. See the bash manpage for the meaning of these.
Also, look in your "~/.bashrc", it's executed after "/etc/bashrc", so settins in ~/.bashrc are the last valid. In short:
1) after login, bash executes "/etc/bashrc" and sets PS1,PS2 ... to something
2) then in "~/.bashrc" they are set to something else or maybe unsets them
3) You "source /etc/bashrc" which brings you to point 1)
 
Old 07-12-2007, 11:00 PM   #4
micko_escalade
LQ Newbie
 
Registered: Feb 2006
Distribution: Fedora Core 6
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks for the replies!

I just can't set it permanently, when I logout and log back in I get -bash-3.1#
typing either PS1="[\u@\h \W]#" or source /etc/bashrc gets me back to standard prompt.
 
Old 07-13-2007, 01:10 AM   #5
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
Normally you only get '#' as the PS1 if you login as root, otherwise you'll get whatever's decided by the /etc/profile and /home/user/.bash_profile, /home/usr/.bashrc, assuming bash shell is set in /etc/passwd.
The reason '#' is used for root is to visually remind you that you are root and can easily trash the system/ make it insecure, as linux does not (normally) ask 'Are you sure?' etc.
Just does what you tell it.
Pls don't login as root unless you need to eg install sw that requires root to install.
Most things you need to access will work from your non-root acct.
 
Old 07-13-2007, 06:03 AM   #6
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 30
There is no reason you can't specify the prompt (and other things) to be set automatically when you run as root.

man bash is your friend.

When you've read that, figure out how your non-root account gets the prompt set.

Then do the same for your root account.
 
  


Reply


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
is there any way to become root off the fedora6 live cd? extendedping Linux - Software 9 01-21-2007 09:27 PM
installing redhat 8.0 when text login in I cannot type password?? I type root scrist Linux - General 4 04-22-2006 02:20 AM
need root .bashrc .bash_profile darkRoom Slackware 5 04-30-2005 03:24 AM
root (hd 0,0)Filesystem type unknown, partition type 0x7chainloader +1 ece30675 Linux - Distributions 5 07-20-2004 09:04 AM
.bashrc or .profile for root in SuSE jimsee Linux - General 3 11-15-2003 02:36 PM


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

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