LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 04-26-2008, 05:46 PM   #1
nightrider
Member
 
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:

bash-3.1$

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

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

Rep: Reputation: 271Reputation: 271Reputation: 271
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:

PS1=$HOME

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

printenv

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:

PS1="\u@$HOME"

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
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,542
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

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

Code:
#.bashrc

# 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\] '
 else
   PS1='\[\033[1;32m\]\h:\w\$\[\033[0m\] '
fi

#
# 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 ~/ www.google.com'

#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;

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


Reply


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


All times are GMT -5. The time now is 02:53 PM.

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