1

I'm trying to change the name that is listed as "user" under my desired username. This is the only account I have set up (= root account?).

I noticed that the name "user" instead of the account username appears in the terminal ("user"@). Note that my computer name has been set up as "ub".

How do I change the text under my username from "user" to match that of my username?

Screenshot:

I'm a newbie with ubuntu so if someone can list out clear step-by-step instructions I would be most grateful.

Thanks!

4
  • Whats the output of echo "$PS1"?
    – heemayl
    Oct 9, 2016 at 19:01
  • What do you get when you run whoami ; echo $HOME at the command prompt? Oct 9, 2016 at 19:25
  • @heemayl Output of echo "$PS1" in Terminal is \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]u@\h\[\033[00m\]:[\033[01;34m\]\w\[\033[00m\]\$ @L.D.James Output of whoami ; echo $HOME in Terminal is user /home/user with a line brake after the first user before /home ...
    – user604803
    Oct 9, 2016 at 20:45
  • Type in the name exactly the way you want it to appear. At present it's showing your actually username with is user. You can change your username to something different, or you can edit your $PS1 variable to output any other specification outside of your actual username. As per your question, I'll outline in a formatted answer how to do it both ways. Oct 9, 2016 at 20:58

1 Answer 1

1

enter code hereThe out put is showing you your username which is user.

You can either change your username or change the PS1 variable. Only do #1 or #2.

#1 Change your username to a name of your choice

The best way is to login via different account. The specific user account can't be active when making this modification. So you may have to create a temporary account with sudo active, if you don't already have one.

Then from the other account run this command:

$ sudo usermod -l newname user

The parameter user is the current name being changed. The newname is what it's being changed to.

Then you will have to move the directory to that new name. Do this with:

$ sudo usermod -d /home/user -m newname

#2 Change the PS1 variable in your ~/.bashrc file

If you just want to have your name displayed in a special way you can edit the PS1variable in your ~/.bashrc file. You can use the line below or any other variation. In this case the newname in the line is what you would change to what you want to appear in your terminal prompt.

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]newname@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Adding user from the commandline

You can add a user from the commandline with:

$ sudo adduser usernametoadd

You can add this user to sudoer access with:

$ sudo adduser usernametoadd sudo
3
  • How do I ensure my temporary account has sudo active? Will creating a temporary administrator account work?
    – user604803
    Oct 9, 2016 at 21:30
  • When you the account if you're using the GUI (by way of the Gear icon in the top right -> System Settings -> User Accounts), Choose Administrator as the Account Type. You could also add it to the sudoer's access from the commandline with: sudo adduser usertoadd sudo. Oct 9, 2016 at 21:35
  • @user604803 I added formatted steps for creating a user and ensuring he has sudo access to the answer. Oct 9, 2016 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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