LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 05-29-2013, 05:16 PM   #1
jwsmith
LQ Newbie
 
Registered: Jan 2012
Location: Berkeley, CA
Distribution: rh fedora 18
Posts: 26

Rep: Reputation: Disabled
Customized command-line PROMPT


My preference would be for my command-line prompt to display the absolute directory path to any directory I am working in.

What I need is a $/etc/bashrc PS1 script-entry that reads ---

PS1="\h \w \$"

I can set that value at the command-prompt of any session and have what I want.
But the setting "goes away" when the session closes.
I would like to have it permanently.

To do this I understand it will be necessary to modify the /etc/bashrc script file

My reading led me to think that use of the 'export' command with root authority would make that change permanently in the bashrc script file:

CODE: #export PS1="\h \w \$"

However it did not.

I then "went" to /etc and invoked #gedit bashrc

RETURNED:
============
root@localhost etc]# gedit bashrc

(gedit:20555): EggSMClient-WARNING **: Failed to connect to the session manager: None of the authentication protocols specified are supported


** (gedit:20555): WARNING **: Could not connect to session bus
[root@localhost etc]#
=============

Yet when I invoked gedit bashrc as a mere USER --- the bashrc file displays in gedit and I am able to make the desired GEDIT changes, but am prevented from saving them.

At this point I coped out...
It was all just too scary...
I'm too much of a neophyte to be flying alone in these waters.

jwsmith
 
Old 05-29-2013, 05:19 PM   #2
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
How did you become root ?
"su" will cause that error , it is using your normal users $PATH
" su - " is what you need to use . It is using root's $PATH
 
1 members found this post helpful.
Old 05-29-2013, 06:40 PM   #3
jwsmith
LQ Newbie
 
Registered: Jan 2012
Location: Berkeley, CA
Distribution: rh fedora 18
Posts: 26

Original Poster
Rep: Reputation: Disabled
John...I became root by entering the command: $su root plus pwd ...obtaining #(root commandline)
I know no other way...am comfortable (cautious) with root authority.

You seem to be asking that I invoke gedit by first entering the command

$su -

Wow....I just did that...it asked for the pwd....and then offered me the bashrc text.

So I guess I'm on my way...

But would you comment on this:
Within the text of bashrc is explicit warning not to alter bashrc.
Suggests that instead, changes to bashrc be made by creating a "custom.sh" script file in /etc/profile.d
STATES that an additional advantage in doing this, is that the change will survive subsequent Fedora upgrades.
My fairly old documentation: (Tim Parker "Linux Unleashed" 3rd Ed.) and newer(Mark Sobell "Practical Guide to Linux Commands, Editors & Shell Programming" 2nd Ed. -2010) do not give any guidance about the format that a "custom.sh" script file should take)
Do you recommend that I just alter the PS1 description within bashrc, or should I concern myself with creation of a custom.sh script file.

jwsmith
 
Old 05-29-2013, 08:30 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
fallow the instructions in that warning

fedora changes VERY fast
With a new and sometimes VERY different version every 6 months
a fedora 18 book will be somewhat out of date by the time it is on the book shelf

a 3 year old book would be about 6 versions of fedora out of date

Now the basics ( mostly) do not change except for system-v VS. systemd and udev


as to ps1

do you wnat this system wide ?
or for just your user ?

i would recomend just your user
then a slightly different version for root
use say RED for root prompt , that way at a very quick glance you can tell

for your normal user
edit the .bashrc file in your home folder
just add this to the file
Code:
export PS1="\h\w\$"
however "\h\w\$" might not be what you want , that will remove the user name
------
PS1="\u@\h:\w>\$"
------

might be a better option

see this web page
http://bashrcgenerator.com/

then for the .bashrc in the /root folder add this
Code:
export PS1="\[\e[31m\]\u\[\e[0m\]@\h:\w>\$"
 
1 members found this post helpful.
Old 05-29-2013, 08:30 PM   #5
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,624

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
-- oops ---

Last edited by John VV; 05-29-2013 at 08:37 PM.
 
1 members found this post helpful.
Old 05-29-2013, 10:24 PM   #6
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
Instead of modifying /etc/bashrc file, modify individual files i.e. ~/.bashrc or ~/.profile for individual users.
Just do:
Code:
~$ echo PS1="\h\w\\$" >> ~/.bashrc
OR
~$ echo PS1="\h\w\\$" >> ~/.profile
Then restart the session to take changes into effects.
 
1 members found this post helpful.
Old 05-30-2013, 10:59 AM   #7
jwsmith
LQ Newbie
 
Registered: Jan 2012
Location: Berkeley, CA
Distribution: rh fedora 18
Posts: 26

Original Poster
Rep: Reputation: Disabled
John and shivaa....

Thank you both, very much.

Judd
 
  


Reply



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
910608 - command line prompt in color hamidi2 Linux - Newbie 11 09-01-2012 10:35 PM
Command line prompt has changed une Linux - Newbie 3 09-19-2006 10:51 PM
httpd -l and mysql -p at any command line prompt ZC1 Linux - General 1 05-23-2006 09:58 AM
Bringing Up Command Line\prompt hondagetter Linux - General 3 09-04-2005 06:13 AM
problem with command line prompt ??? robeb Linux - General 2 12-07-2002 08:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:54 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration