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 06-15-2013, 12:41 AM   #1
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Rep: Reputation: Disabled
Display-bash-4.2#, not changing to my username


Dear Slackers
First, my bash was displayed as bash-4.2$, bash-4.2# for user and root.
I edited the file 'profile', by un commenting the one for above
Code:
bash-4.2# cat /etc/profile
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems with the backspace key using 'eval tset' instead of 'TERM=',
# but you might want to try it anyway instead of the section below it.  I
# think with the right /etc/termcap it would work.
# eval `tset -sQ "$TERM"`

# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# 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

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y 2> /dev/null
fi

# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

bash-4.2#
I created a .bashrc file as below
Code:
san2ban@KRISHNA:~$cat .bashrc
PS1="\u@\h:\w$"
PS2="\u@\h:\w#"
san2ban@KRISHNA:~$
Now, for user, I am happy with the display. For root, still bash-4.2 is displayed.
Pl. indicate, what is to be edited
 
Old 06-15-2013, 01:05 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
Copy the ~/.bashrc file to /root and it should work.
 
Old 06-15-2013, 04:07 AM   #3
kabamaru
Member
 
Registered: Dec 2011
Location: Greece
Distribution: Slackware
Posts: 276

Rep: Reputation: 134Reputation: 134
I don't know if your PS2 setting is on purpose, but FYI PS2 is the secondary prompt i.e. what your prompt will look like when you break your command in two or more lines. It is not your root's primary prompt.

As for PS1, replace "\u@\h:\w$" with "\u@\h:\w\$" (or better "\u@\h:\w\$ ") for both regular user and root, and do as TobiSGD suggested. "\$" means "$" for regular user, and "#" for root.

Last edited by kabamaru; 06-15-2013 at 04:09 AM.
 
Old 06-15-2013, 04:12 AM   #4
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
TobiSGD
Did as you suggested
Does not work
Code:
bash-4.2# cat .bashrc
PS1="\u@\h:\w$"
PS2="\u@\h:\w#"
bash-4.2#

Last edited by san2ban; 06-15-2013 at 04:14 AM.
 
Old 06-15-2013, 04:18 AM   #5
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,090

Rep: Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173
~/.bashrc is not read for login shells: if you want it to be used also for those you gotta create a ~/.bash_profile (both for your user and root) with this content
Code:
# ~/.bash_profile: executed by bash(1) for login shells.

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi
 
Old 06-15-2013, 04:18 AM   #6
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,263
Blog Entries: 24

Rep: Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194Reputation: 4194
Actually, I think your ~/.bashrc is not being read.

When you login bash only reads ~/.bash_profile

If you want to read ~.bashrc you need to create a ~/.bash_profile with something like this...

Code:
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
[EDIT]
ponce beat me by 17ms... at least!
[/EDIT]

Last edited by astrogeek; 06-15-2013 at 04:21 AM.
 
Old 06-15-2013, 04:21 AM   #7
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
Kabamaru

Did as you suggested. Removed PS2. Still, for root, no change
Code:
bash-4.2# cat .bashrc
PS1="\u@\h:\w\$"

bash-4.2#

Last edited by san2ban; 06-15-2013 at 04:32 AM.
 
Old 06-15-2013, 04:26 AM   #8
kabamaru
Member
 
Registered: Dec 2011
Location: Greece
Distribution: Slackware
Posts: 276

Rep: Reputation: 134Reputation: 134
@ponce,astrogeek: if he didn't modify his /etc/profile, his login shells should be fine though.
 
Old 06-15-2013, 04:27 AM   #9
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
Ponce, Astrogeek
Still same display
Code:
bash-4.2# cat .bash_profile
# ~/.bash_profile: executed by bash(1) for login shells.

# include .bashrc if it exists
if [ -f ~/.bashrc ]; then
  source ~/.bashrc
fi
bash-4.2#
 
Old 06-15-2013, 04:31 AM   #10
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
Kabamaru
On reading your post, again I inserted the # for PS1=, still no change in display
Code:
bash-4.2# cat /etc/profile
# /etc/profile: This file contains system-wide defaults used by
# all Bourne (and related) shells.

# Set the values for some environment variables:
export MINICOM="-c on"
export MANPATH=/usr/local/man:/usr/man
export HOSTNAME="`cat /etc/HOSTNAME`"
export LESSOPEN="|lesspipe.sh %s"
export LESS="-M"

# If the user doesn't have a .inputrc, use the one in /etc.
if [ ! -r "$HOME/.inputrc" ]; then
  export INPUTRC=/etc/inputrc
fi

# Set the default system $PATH:
PATH="/usr/local/bin:/usr/bin:/bin:/usr/games"

# For root users, ensure that /usr/local/sbin, /usr/sbin, and /sbin are in
# the $PATH.  Some means of connection don't add these by default (sshd comes
# to mind).
if [ "`id -u`" = "0" ]; then
  echo $PATH | grep /usr/local/sbin 1> /dev/null 2> /dev/null
  if [ ! $? = 0 ]; then
    PATH=/usr/local/sbin:/usr/sbin:/sbin:$PATH
  fi
fi

# I had problems with the backspace key using 'eval tset' instead of 'TERM=',
# but you might want to try it anyway instead of the section below it.  I
# think with the right /etc/termcap it would work.
# eval `tset -sQ "$TERM"`

# Set TERM to linux for unknown type or unset variable:
if [ "$TERM" = "" -o "$TERM" = "unknown" ]; then
 TERM=linux
fi

# Set ksh93 visual editing mode:
if [ "$SHELL" = "/bin/ksh" ]; then
  VISUAL=emacs
#  VISUAL=gmacs
#  VISUAL=vi
fi

# Set a default shell prompt:
#O
#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

# Default umask.  A umask of 022 prevents new files from being created group
# and world writable.
umask 022

# Notify user of incoming mail.  This can be overridden in the user's
# local startup file (~/.bash.login or whatever, depending on the shell)
if [ -x /usr/bin/biff ]; then
 biff y 2> /dev/null
fi

# Append any additional sh scripts found in /etc/profile.d/:
for profile_script in /etc/profile.d/*.sh ; do
  if [ -x $profile_script ]; then
    . $profile_script
  fi
done
unset profile_script

# For non-root users, add the current directory to the search path:
if [ ! "`id -u`" = "0" ]; then
 PATH="$PATH:."
fi

bash-4.2#

Last edited by san2ban; 06-15-2013 at 04:33 AM.
 
Old 06-15-2013, 04:33 AM   #11
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,090

Rep: Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173
have you logout and logged in again?
how do you become root? use "su -"

try also to add an export to the PS1 line in .bashrc, so you will have it also in child shells, like
Code:
export PS1="\u@\h:\w\$"
and, like kabamaru says, use the standard /etc/profile: you can add your customizations to ~/.bash_profile
 
Old 06-15-2013, 04:39 AM   #12
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
Ponce
Using standard /etc/profile. added 'export' as you suggested. Still same display.
Yes, I use 'su' for becoming root
Code:
bash-4.2# cat .bashrc
export PS1="\u@\h:\w\$"

bash-4.2#
 
Old 06-15-2013, 04:43 AM   #13
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,090

Rep: Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173Reputation: 4173
Quote:
Originally Posted by ponce View Post
have you logout and logged in again?
bash init file are read when it's executed, so you have to logout and re-login (or launch a new shell with the command "bash")

Quote:
how do you become root? use "su -"
note that I've written "su -" (with an additional space and a -), not just "su".

Last edited by ponce; 06-15-2013 at 04:44 AM.
 
Old 06-15-2013, 04:48 AM   #14
san2ban
Member
 
Registered: May 2013
Location: Bengaluru / India
Distribution: Slackware14.2-64bit on one HDD, Slackware64-current on anotherHDD, VoidLinux on Libreboot laptop
Posts: 169

Original Poster
Rep: Reputation: Disabled
Ponce

Logging out and in did not help. I rebooted the system, and now it works. Thanks to all for your time and suggestions. SLACKWARE14-64bit ROCKS!!!
Code:
san2ban@KRISHNA:~$su
Password: 
root@KRISHNA:/home/san2ban$
Further suggestions, if any, are accepted gratefully, gracefully
 
Old 02-21-2019, 01:59 AM   #15
champalal
LQ Newbie
 
Registered: Feb 2019
Posts: 2

Rep: Reputation: Disabled
Check the .bashrc file in the "/" (root) if there is below contains.

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


then create the duplicate of the .bashrc file and rename with the .bash_profile or you can copy the above contains and create the .bash_profile new file and paste the same. and change the permission of file (.bash_profile) as 777 and it will resolve your issue.
 
  


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
I made a mistake changing my /home/username/pubIic_html/ ownership to username:user Sionek2u Linux - Newbie 5 06-20-2012 10:30 AM
Username Changing johnsonkv91 Linux - Newbie 1 04-19-2012 12:29 AM
[Help in Bash Scripting] Display real name from username logged in + user processes leoboy1986 Programming 1 01-14-2011 01:11 PM
Changing username Kramon Mandriva 1 11-24-2003 08:04 PM
changing username evil_lafta Slackware 3 01-15-2003 09:22 AM

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

All times are GMT -5. The time now is 05:07 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