Latest LQ Deal: Latest LQ Deals
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-26-2008, 05:46 PM   #1
Registered: Apr 2005
Location: Sao Paulo - Brazil
Distribution: Open Suse 12.1 64
Posts: 166

Rep: Reputation: 15
Command prompt changes

I press the power off button while Mandriva 2007 was shuting down. In the next time I power on, the command prompt of my user (Ricardo) appears as:


I'm sure that the old format was:

[Ricardo@localhost] (when I was logged in the home directory)

I suspect that the trouble is associated with the environment variable PROMPT_COMMAND, but I can't discover where it is set. I logged with my wife's user and everything is alright with her prompt. The same occurs with the root user.

How do I must do to correct this trouble?

Would the accidentally shut down damage anything else?

Greetings from Sao Paulo - Brazil

Old 04-26-2008, 06:15 PM   #2
LQ Guru
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Linux Mint 17, Debian 8
Posts: 7,865

Rep: Reputation: 311Reputation: 311Reputation: 311Reputation: 311
You configure the bash prompt by the PS1 variable. You can set the prompt to hello with PS1=hello. This is explained in the bash man page under the PROMPT_COMMAND section.

You can make the prompt more elaborate by using escape characters and variables in PS1, for example:


will change the prompt to the name of your home directory. Use the command:


to see other variables that you could possibly use. Other things that you can include in your prompt are described in the bash man page under PROMPTING. For example:


Once you get PS1 the way that you want it you can make it permanent by placing it in a bash profile file under /home/user/. Different distributions use different bash profile files. Look for .bashrc, .bash_profile, or .profile.

Steve Stites
Old 04-26-2008, 09:02 PM   #3
Registered: Jan 2005
Location: Summer Midwest USA, Central Illinois, Winter Central Florida
Distribution: SlackwareŽ
Posts: 13,504
Blog Entries: 32

Rep: Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675Reputation: 2675

You can create a .bashrc to setup for a user.


# Add bin to path

export PATH="$PATH:/sbin:/usr/sbin:$HOME/bin"

#export PATH="$PATH:$HOME/bin"

# Dynamic resizing
shopt -s checkwinsize

# Custom prompt
#PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

if [ `id -un` = root ]; then
   PS1='\[\033[1;31m\]\h:\w\$\[\033[0m\] '
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '

# Add color
eval `dircolors -b`

# User defined aliases
alias cls='clear'
alias clls='clear; ls'
alias ll='ls -l'
alias lsa='ls -A'
alias lsg='ls | grep'
alias lsp='ls -1 /var/log/packages/ > package-list'
alias na='nano'
alias web='links -g -download-dir ~/'

#To clean up and cover your tracks once you log off
#Depending on your version of BASH, you might have to use
# the other form of this command
   trap "rm -f ~$LOGNAME/.bash_history" 0

#The older KSH-style form
#   trap 0 rm -f ~$LOGNAME/.bash_history
Be sure to setup a .bash_profile;

# .bash_profile
# Source .bashrc
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
Remember that these files are in the users ~.


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
startx command in FC7 reverts me back to the command prompt sriram87 Linux - Newbie 5 01-04-2008 12:18 AM
Command line/ command prompt saiinch Linux - Newbie 5 03-17-2006 03:29 AM
Prompt command to...? Kelphyr Slackware 10 10-03-2004 05:42 PM
Key stroke/command to shut down x and go into the command prompt screen? Fear58 Linux - General 1 07-14-2004 08:14 PM
How to recall an old command at the command prompt? J_Szucs Linux - Newbie 9 03-07-2003 01:29 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:01 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration