LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   newbie :( (https://www.linuxquestions.org/questions/linux-newbie-8/newbie-280746/)

Lance56 01-22-2005 02:46 AM

newbie :(
 
Hey on the command line it says
[lance@localhost lance]$

and i was wondering how i can change that
i know the first word is the "user", i just figured that out, i changed it awhile ago
now it's
[retro@localhost lance]$

i was wondering what the last word means and how i can edit/change it

Dark_Helmet 01-22-2005 02:57 AM

You want to modify the PS1 enfironment variable. Do this at a prompt:
Code:

echo $PS1
You'll see something like:
[\u@\h \w]\$

Again, yours may be different. All those backslash-character combinations represent something significant to the shell, and they get replaced when the prompt is actually printed. You can read about what's available with the man page for bash (man bash) The man page is rather long, and you only need to see one particular section. So start a search by hitting a forward slash ( / ), type "PROMPTING" (should be all upper case), hit Enter/Return, and then press 'n' until you see the man page highlight the heading of the PROMPTING section. You'll see a list of all the codes you can use and what they expand to. If you use something that is not one of those codes, it's probably taken literally and printed verbatim in the prompt(like the open and close square braces in the example above).

To change your prompt, change the value it is assigned in one of two files.

Edit ~/.bash_profile to make the change only for one particular user.
Edit /etc/profile to make the change global for every user (each user can override this setting if they make a change in their personal ~/.bash_profile)

If you don't see any lines where PS1 is modified in the file you opened, then add these lines:
Code:

PS1='your custom string here'
export PS1

Otherwise, just substitute your customized value for whatever was there to begin with.

Save the file, and the next time you log in, your prompt should be what you set it to.

You can test it before adding to the file by executing:
Code:

export PS1='your custom string here'

perryub 01-22-2005 11:05 AM

Re: newbie :(
 
Quote:

Originally posted by Lance56
Hey on the command line it says
[lance@localhost lance]$

and i was wondering how i can change that
i know the first word is the "user", i just figured that out, i changed it awhile ago
now it's
[retro@localhost lance]$

i was wondering what the last word means and how i can edit/change it

Lance,

basically, it's "username@machine-name directory". For example, when I first open a shell, I get:

[perry@localhost perry]$

This is because my username is perry, my machine name is localhost and I am in the /home/perry/ directory. If I type cd /etc/ to get to the /etc/ directory, it displays:

[perry@localhost etc]$

Hope that helps,

Perry


All times are GMT -5. The time now is 08:10 AM.