LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 07-21-2013, 09:57 AM   #1
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Rep: Reputation: 2
main non-root user shell prompt lost


Sooo embarrassed...

While fooling around (let's call it "exploring the cli") with two
files:
  1. .bashrc_profile and
  2. .bashrc,
I have managed to completely "disappear"
my main user's shell prompt!

At the console prompt (or an xterm for that matter) I can log in as root; but when I try with my non-root user, on entering log and p/word, the prompt goes to null, then, after 3 or 4 seconds, the main prompt is restored.

I know that I have to reset it by using something like:
<PS1=\u\h\w$>
but I do not know where to begin to do this.

And all the help notes I googled assume that one is starting with the bare minimum:
<bash-4.2$ >
or something like that, the very thing which has vanished.
All I have is a sober, forbidding-looking:
<bash-4.2#>

Anyone? I feel all orphaned, marooned, widowed, bereft even of the right metaphor ....
 
Old 07-21-2013, 10:02 AM   #2
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2.1.2 on Lenovo Thinkpad W520
Posts: 9,366

Rep: Reputation: Disabled
(wrong answer)

Last edited by Didier Spaier; 07-21-2013 at 10:03 AM.
 
Old 07-21-2013, 10:43 AM   #3
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 147

Rep: Reputation: Disabled
Hi,

Login in root, then move the .bash* of your user:

Code:
mv /home/<user>/.bashrc,{.old}
mv /home/<user>/.bash_profile{,.old}
If it still does not work, check in /etc/passwd the shell you have defined for this user:

Code:
grep ^user: /etc/passwd
The last field of the line is the defined shell.
 
1 members found this post helpful.
Old 07-21-2013, 10:44 AM   #4
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062
Go look in /etc/profile, there's a section:
Code:
# Set a default shell prompt:
#PS1='`hostname`:`pwd`# '
if [ "$SHELL" = "/bin/pdksh" ]; then
 PS1='! $ '
elif [ "$SHELL" = "/bin/ksh" ]; then
 PS1='! ${PWD/#$HOME/~}$ '
elif [ "$SHELL" = "/bin/zsh" ]; then
 PS1='%n@%m:%~%# '
elif [ "$SHELL" = "/bin/ash" ]; then
 PS1='$ '
else
 PS1='\u@\h:\w\$ '
fi
PS2='> '
export PATH DISPLAY LESS TERM PS1 PS2
Copy the one you like to your ~/.profile, ~/.bashrc or ~/.bashrc_profile. file (hint: I think the default BASH prompt is PS1='\u@\h:\w\$).

You can also edit the preferences for your terminal emulator program and turn on the "make it a login shell" option.

Or, if you did something in one of the .bash* files with PS1, remove that and you'll get the system default.

Hope this helps some.

Last edited by tronayne; 07-21-2013 at 10:46 AM.
 
1 members found this post helpful.
Old 07-21-2013, 10:57 AM   #5
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Non non ba, tronayne, thanks kindly for detailed responses.
in the meantime, I actually worked out one possible way how to fix it:
I simply logged in as root and removed that user's .bashrc and .bashrc_profile, which gave me the default back.

Now, I'll go to work on your suggestion tronayne, of selecting one i like
(the one I had worked up before was simply the one you reference: <PS1='\u@\h:\w\$>

(feels kinda good having worked something out for myself for the first time )
 
Old 07-21-2013, 11:20 AM   #6
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by NonNonBa View Post
Hi,

Login in root, then move the .bash* of your user:

Code:
mv /home/<user>/.bashrc,{.old}
mv /home/<user>/.bash_profile{,.old}
If it still does not work, check in /etc/passwd the shell you have defined for this user:

Code:
grep ^user: /etc/passwd
The last field of the line is the defined shell.
The answer to that query was /home/user:/bin/bash, which is interesting, but doesn't tell me how to get my old customized prompt back.

Thanks again
 
Old 07-21-2013, 11:51 AM   #7
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062
Well, the one I use (with KornShell, I don't use BASH) is
Code:
PS1='${HOST}-${USER}-${PWD}: '
)
(it looks like this: fubar-trona-/home/trona: )

The only variable that isn't "just there" is ${HOST} which I define with
Code:
export HOST="`uname -n`"
For what it's worth...
 
1 members found this post helpful.
Old 07-21-2013, 02:04 PM   #8
onebuck
Moderator
 
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,557
Blog Entries: 34

Rep: Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732Reputation: 2732
Member Response

Hi,

I like to provide my users with this;
Code:
sample .bash_profile;   
~$ cat .bash_profile 
#-----------------cut-----------------   
# .bash_profile
#08-30-06 12:21

# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

#-----------------cut end--------------
Code:
 cat .bashrc
#-----------------cut-------------------

#.bashrc
#08-30-06 12:20 

# Add bin to path
export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize
#
#save bash history so as to share

shopt -s histappend
PROMPT_COMMAND='history -a'

# Custom prompt                                                                                                                                                                 
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 
                                                      
#08-29-06 11:40                                                                           
if [ `id -un` = root ]; then                                                                                                                                                    
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '                                               
 else                 
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '                                                                                                                                      
fi                                                                                                                                                                              
#                                                                                                                                                                               
# Add color                                                                                                                                                                     
eval `dircolors -b`                                                                                                                               
#Terminus is a very nice Unicode font for the Linux console
#02-02-12
#from dugan's site http://duganchen.ca/writings/slackware/fonts/

#04-30-12 11:41 removed
#
#if [ $TERM = "linux" ]; then
#    setfont ter-v16n
#fi

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/ www.google.com'

#08-29-06 11:50

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0
        
#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history


#-----------------cut end--------------
I let them modify to suit their needs.
Hope this helps!
 
1 members found this post helpful.
Old 07-22-2013, 12:47 AM   #9
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by tronayne View Post
Well, the one I use (with KornShell, I don't use BASH) is
Code:
PS1='${HOST}-${USER}-${PWD}: '
)
(it looks like this: fubar-trona-/home/trona: )

The only variable that isn't "just there" is ${HOST} which I define with
Code:
export HOST="`uname -n`"
For what it's worth...
Nice.
1. But what about simply "\h" to render "hostname"; which is what works for me?
2. I notice you use single ` ... `; are these equivalent in scripting to " ... " (a key with which I am more comfortable: ie: i can actually hit it accurately, nearly every time )?
3. slack is sinking into my fibres, into my dreams and taking up waaaayyy too much of my waking moments for me to continue to claim the tag of normality.

cheers
 
Old 07-22-2013, 12:57 AM   #10
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Code:
mv /home/<user>/.bashrc,{.old}
mv /home/<user>/.bash_profile{,.old}
Hi, I was just wondering if you would mind clarifying a couple of things which occur to me about your response?
1. is {.old} equivalent to {~}? I notice that every time I create a file I get a back up automatically, ending in tilda (~) )
2. would you explain the grammar of:
Code:
grep ^user: /etc/passwd
for me, as I have never been able to wade through the man pages on grep sufficiently to grasp (or "grep") more than a bare outline of what it does, but your use of it above looks so helpful.

And thanks again,
 
Old 07-22-2013, 01:01 AM   #11
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by onebuck View Post
Hi,

I like to provide my users with this;
Code:
sample .bash_profile;
Thanks kindly Onebuck!

Would you go one further and tell me how i can save the aliases I have made in my ~/.bashrc so that they are available for root?

Once again, appreciate such a detailed, informative and pin-point-pertinent response!
Cheers,
 
Old 07-22-2013, 03:43 AM   #12
NonNonBa
Member
 
Registered: Aug 2010
Distribution: Slackware
Posts: 147

Rep: Reputation: Disabled
The a{x,y,z} expression is just a shortcut for writting ax ay az. So here it's a way to write mv /home/<user>/.bash_profile /home/<user>/.bash_profile.old (ooops, I realize there's a typo in the first line I gave, sorry). See man bash, "Brace expansion" section, for further details.

Per default, grep takes a regular expression. "^" means "beginning of the line", so here I just ask for printing the line(s) starting with the "user:" string. Regular expressions are a way to describe a line to match, by requesting things such a line, starting with A to H, followed by one or more digit(s), maybe followed by a string introduced with a column, and always ending with no or one or more spaces, equal, no or one or more spaces, then "Eric", "Kenny", "Kyle" or "Stan". Which gives something like ^[A-H][0-9]+(:[^ ]*)? *= *(Eric|Kenny|Kyle|Stan)$. You have a short introduction in man grep, but it's a rather complex topic... maybe man perlretut is a better introduction (Perl's IMHO the best and the funniest language to play with them).

Hope this feeds your curiosity.

Last edited by NonNonBa; 07-22-2013 at 03:47 AM.
 
1 members found this post helpful.
Old 07-22-2013, 03:55 AM   #13
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
NonNonBa:
Thanks heaps for the detailed response.
Reading up big now.
(Your suggestion about perl has peeked my curiosity)
 
Old 07-22-2013, 04:10 AM   #14
Didier Spaier
LQ Addict
 
Registered: Nov 2008
Location: Paris, France
Distribution: Slint64-14.2.1.2 on Lenovo Thinkpad W520
Posts: 9,366

Rep: Reputation: Disabled
Before reading "man bash" I would recommend anyone reading the definition of the Shell Command Language in the POSIX standard, for following reasons:
  1. I am under the impression that its knowledge is "tacitly assumed" by writers of "man bash"
  2. It's (slightly) easier to read IMO
  3. It provides some examples
Only caveat, it's maybe not quite as good as remedy against insomnia


Just my
 
1 members found this post helpful.
Old 07-22-2013, 05:46 AM   #15
textillis
Member
 
Registered: May 2013
Location: Northern Rivers, NSW, Australia
Distribution: Slackware64-current, Mint Nadya
Posts: 299

Original Poster
Rep: Reputation: 2
>Didier!
Thanks mon vieux.
I'll take up the challenge and see if I can keep awake through the introduction.

If so, I'll make it my "well-thumbed" guide.

Seriously apt suggestion, given my oft-publicly-declared aversion to man-pages,
and my oft-displayed need for the information in them to be transferred to my brain.
 
  


Reply

Tags
non-root, shell prompt


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
Need Track if any user close the windows of shell prompt sahworld Linux - Server 1 03-22-2011 01:06 PM
Can root and my main user account share the same home directory? rivercat Linux - Newbie 11 02-21-2011 07:22 PM
Root Shell, Path & Prompt tschima Solaris / OpenSolaris 3 05-03-2008 09:51 PM
howto: verify a user/pass at the shell prompt. exodist Linux - Security 8 08-16-2006 05:16 AM
How to set tcsh prompt: # for root and % for user? robson Linux - Newbie 1 10-12-2003 03:13 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration