0

On my Centos7 Server I have different shells for my users.

For example the terminal as root looks like:

[root@hostname www]#.

The terminal as a different user looks like bash-4.2$.

If I type echo $0 to get the currently-used shell, I get /bin/bash on my different user and -bash on my root.

Do I have to configure the shell for my different user, in order to make it look like the shell for my root?

Is there a way to use the shell used in Debian (bash) to see the full path of my location? (root@server:/var/www# instead of root@server www).

Thanks for your help.

  • That's not the shell (which is always Bash), that's the command prompt format. – Massimo Jul 5 '20 at 17:11
4

It sounds like your user is missing the skeleton files, the default .bashrc, .bash_profile etc. which are normally copied into a user's home directory from /etc/skel when a user is created. You can copy these files yourself if they are missing or corrupted.

  • Well that seems to work. I just copied the .bashrc, .bash_profile, .bash_logout from my root user, because I dont find a /etc/skel folder on my Centos-Server. The .bash_history was already in the home folder. Thank you very much. – MrWaffelXD Jul 9 '20 at 15:35
  • @MrWaffelXD The /etc/skel directory itself is provided by the filesystem package, which every CentOS system has installed. The .bash* files within it are provided by the bash package. It sounds like someone has manually deleted these files. Try restoring them with yum reinstall filesystem bash. – Michael Hampton Jul 9 '20 at 15:39
  • Somehow I messed something up in the past. I reinstalled it and have the /etc/skel folder now. That should be the issue for the missing files in the home directory I guess. Thanks again ^.^ – MrWaffelXD Jul 9 '20 at 15:48
1

A user's prompt is determined by the value of the shell variables PS1, PS2, PS3, PS4.

PS1 – The value of this parameter is expanded and used as the primary prompt string. 
      The default value for Bash is \s-\v\$ .
PS2 – The value of this parameter is expanded as with PS1 and used as the secondary 
      prompt string. The default value for Bash is >
PS3 – The value of this parameter is used as the prompt for the select command
PS4 – The value of this parameter is expanded as with PS1 and the value is printed 
      before each command bash displays during an execution trace.

Typically a user only customizes PS1.

Bash allows these variables to be customized by inserting one or more escaped special characters:

\a : ASCII bell character
\d : The date in “Weekday Month Date” format (e.g., “Tue May 26”)
\D{format} : the format is passed to strftime(3) and the result is inserted into
the prompt string; an empty format results in a locale-specific time representation. 
The braces are required
\e : Tne ASCII escape character
\h : The hostname up to the first ‘.’
\H : The full hostname
\j : The number of jobs currently managed by the shell
\l : The basename of the shell's terminal device name
\n : A newline
\s : The name of the shell
\t : The current time in 24-hour HH:MM:SS format
\T : The current time in 12-hour HH:MM:SS format
\@ : The current time in 12-hour am/pm format
\A : The current time in 24-hour HH:MM format
\u : The username of the current user
\v : The current version of bash (e.g., 2.00)
\V : The current release of bash, version and patch level (e.g., 4.12.0)
\w : The current working directory, with $HOME abbreviated with a tilde
\W : The basename of the current working directory, with $HOME abbreviated 
     with a tilde
\! : The history number of this command
\# : The command number of this command
\$ : If the effective UID is 0, a #, otherwise a $
\nnn : The character corresponding to the octal number nnn
\\ : A backslash
\[ : Begin sequence of non-printing characters, which could be used to embed 
     a terminal control sequence into the prompt
\] : End sequence of non-printing characters

Example:

fpm@fpmurphy ~]$ PS1="[\d \t \u@\h:\w ] $ "
[Sun Jul 05 23:44:17 fpm@fpmurphy:~ ] $ 

To persist the custom prompt across a reboot or a logout, add the prompt to the users $HOME/.bashrc, or to make it the default prompt for all users, add it to /etc/bashrc or create an entry under /etc/bashrc.d depending on your distribution.

  • Perfect. Thanks – MrWaffelXD Jul 9 '20 at 15:38
  • @MrWaffelXD. Please upvote the answer. thanks. – fpmurphy Jul 9 '20 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.