Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The default prompt will be

root@monu dev]#

Can we change the "root@monu" part and give it a desired name?

share|improve this question
add comment

2 Answers

up vote 5 down vote accepted

This is changed by changing the environment variable PS1.

You can see the current value of PS1 by:

root@monu dev# echo $PS1

You can see the value to be equal to \u@\h \w\$, where:

  • \u : username
  • \h : hostname
  • \w : current working directory
  • \$ : a # symbol for the root user, a $ symbol for other users

If you want the change to be permanent, you have to add the script changing the value of PS1 in ~/.bashrc, since that it gets executed every time a user logs in.

share|improve this answer
    
Don't forget to put it into your ~/.bashrc file also. e.g. `PS1="myname \\$ "'. –  Keith Apr 5 '12 at 6:55
3  
~/.bashrc is not executed every time a user logs in. “When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists.” – man bash /INVOCATION –  manatwork Apr 5 '12 at 7:39
    
By changing them, you can change.? –  Tshepang Apr 6 '12 at 23:44
    
For details, see the PROMPTING section with man bash. –  Francesco Turco Sep 23 '12 at 10:30
add comment

This depends on your shell. As an important side note, you should never use the root account as a personal account. Create a normal user and set up access to sudo. Please check your distribution manual as to how to do this.

In zsh, you need to set the PROMPT variable like so:

PROMPT='%{ESC[38;5;24m%};%{ESC[0m%} '

zshell offers a lot of other options and this is really a minimal prompt.

In bash, you can set it this way:

local ROOK="\[\033[38;5;24m\]"
local DEFAULT="\[\033[0;39m\]"
PS1="${ROOK}\$${DEFAULT} "

Note that in both cases, I have a 256 colour enabled terminal. The man page will help a lot (man bash or man zsh).

share|improve this answer
2  
Here, you stated the root account case correctly, IMO - it is not to be used as a personal account (except on some very low-footprint embedded systems). –  rozcietrzewiacz Apr 5 '12 at 8:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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