LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Dragora GNU/Linux-Libre (https://www.linuxquestions.org/questions/dragora-gnu-linux-libre-110/)
-   -   bash-4.2$: change the command prompt to display username who has logged in (https://www.linuxquestions.org/questions/dragora-gnu-linux-libre-110/bash-4-2%24-change-the-command-prompt-to-display-username-who-has-logged-in-4175601354/)

san2ban 03-08-2017 09:51 PM

bash-4.2$: change the command prompt to display username who has logged in
 
The /etc/skel directory was empty. Created .bash_profile, .bashrc, .bash_logout files. /etc/profile exists.
However much I try, unable to change the display of command prompt, to display the username
I would be glad if some body would clarify, how to make the terminal(bash) command prompt display the username of the user that has logged in, every time, automatically

Think I am missing something elementary, but I feel I am going round and round in circles, with .bashrc, .bash_profile, /etc/profile files

This will be a lesson for me

san2ban 03-09-2017 12:28 AM

In the below link
http://unix.stackexchange.com/questi...t-show-anymore

It was mentioned as below
Quote:

4
down vote


I had the same issue, here’s how I solved it:

One of two things happened. Either the directory /root was deleted; or a missing / corrupt .bashrc file in /root (.bashrc sources /etc/bashrc, which sets the prompt), you can run the following command to restore the original files (which are copied automatically when the root or any user account is created). Run this command as the user who is having problems OR define the destination path to /home/directory/user/

cp -v /etc/skel/.bash* ~/ #if logged in as user
cp -v /etc/skel/.bash* /home/user/ #run as root

Should replace the .bash_logout, .bash_profile and .bashrc - exit terminal and log back in. The -bash-4.1# should now be gone!
This solved my issue. bash prompt below
Quote:

san2ban@KRISHNA:~$
Quote:

root@KRISHNA:/home/san2ban#
But, in future, if I have to make changes to my .bashrc, should I do it at /home/san2ban/.bashrc or /etc/skel/.bashrc ?

ondoho 03-09-2017 01:29 AM

Quote:

Originally Posted by san2ban (Post 5680963)
But, in future, if I have to make changes to my .bashrc, should I do it at /home/san2ban/.bashrc or /etc/skel/.bashrc ?

in your $HOME.

and please mark the thread solved (Thread Tools at the top).

lazydog 03-09-2017 01:48 PM

You are aware that you only need to replace a single line of code in your bashrc file;

Code:

PS1="\u@\h: "
This will display the uses name.


All times are GMT -5. The time now is 07:02 AM.