Why Does Linux Prompt Look Like ...

Rubicone

Senior member
Jan 11, 2001
520
0
0
Last night I was practicing adding users using the passwd and shadow file. Used the passwd command to create a password for the new user. Made a home directory for the new user. Copied the default login initialization files to the users home directory.Assigned the appropriate permissions for the home directory and contents.Set the owner and group for these directories. However, when I attempted to login as that user I got the following strange looking prompt.
bash-2.05$.
Can anyone tell me why that is and how it can be changed?

 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Nothing strange looking about that, it's a regular bash prompt.

What exactly were you expecting?

Oh and a tip, instead of creating userdirs and such yourself, you just use useradd -m -d /home/username -s /whatever/shell.
The -m option will create the dir and copy the files from /etc/skel into it.
 

Rubicone

Senior member
Jan 11, 2001
520
0
0
I know about the useradd command but I am trying to learn this other method as I will be tested on it for a course on Linux I am taking. In terms of what I expected it is as follows:

[rubicone@sob3 skel]$

The username, preceding the computer name of the server, and the directory name one is currently in.

I looked at the .bash_profile file and the contents thereof are as follows:

[rubicone@sob3 skel]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

The contents of the .bashrc file are as follows:

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi


fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

Is there something missing in either one?
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Type set, and see what the PS1 var is set to.

If you want a "username@hostname wd", type PS1='\u@\h:\w$ '.
\u = username
\h = hostname
\w = working directory
 

Rubicone

Senior member
Jan 11, 2001
520
0
0
Is everything enclosed in single quotations? Cannot quite make out the full command because of the font and size thereof.
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Yup, but it should work with double quotations as well, I just tend to stick to singles.

Oh and by the way, to make it stick, put it in the users .bashrc file.
Or to make it system-wide, put it in the /etc/profile.
Or if you just wanna make it the default for newly created accounts, edit the /etc/skel/.bashrc file.
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
Not as long as you dont break something else.

Such as putting it smack in the middle of an if/fi statement or something.
 

Rubicone

Senior member
Jan 11, 2001
520
0
0
I notice that the .bashrc file has 2 fi occurences can I place it between them or at the end of the two?
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
A fi is the closing statement for an if.

if
blah blah is tru
do blah blah
fi

PS1='Whateveryouwant'

if
more blah
fi