-bash-4.2$ for command line?

9,024

(edited to add:) The root account is probably using bash also, but it is configured to show your username, hostname, and path in the shell prompt. Shells are very configurable.

The root account presumably had a .bashrc or .profile or similar file which set the shell prompt to the value you expect. (What you're seeing is bash's default prompt.) If you want your new account's shell to have similar behavior, you can look at root's startup files and copy the relevant settings into your new account's startup files. You probably want to copy the setting of the PS1 variable which controls the main interactive shell prompt.

For details, check the PROMPTING section of the bash man page, or the bash reference manual.

Share:
9,024

Related videos on Youtube

Centos User
Author by

Centos User

Updated on September 18, 2022

Comments

  • Centos User
    Centos User over 1 year

    I don't know why when I SSH with putty onto my VPS, my command line starts with: -bash-4.2$ It hasn't ever been like that, it was myname@localhost

    Only thing I have done different in the last 24 hours, was disable root, and create myself a login, rebooted the VPS. I did in fact SSH back onto the VPS after reboot, so I don't know why when I woke up, it's running under bash.

    Nothing is changing in bash, so its obvious something isn't right.

    -bash-4.2$  cd/
    -bash: cd/: No such file or directory
    -bash-4.2$ cd //
    -bash-4.2$ cd /
    -bash-4.2$ cd /var/www/
    
  • Centos User
    Centos User over 8 years
    Weird, I will look into this ore when I get back home. Need to go somewhere.
  • Tyson
    Tyson over 8 years
    It's not "weird" at all. Pretty straight forward actually.
  • Centos User
    Centos User over 8 years
    Not what I meant exactly..
  • Centos User
    Centos User over 8 years
    So I opened up two instances of putty and logged in as root, and as my regular user. I copied the exact information for both .bashrc and .bash_profile. Including adding PS1='\u@\H:\w\$ ', and then rebooted the server, but nothing changes. I got that PS1 command from: wiki.centos.org/TipsAndTricks/CustomizeBash
  • Centos User
    Centos User over 8 years
    Any advice on what I should try next?