Default User Id at Login different from User Name in Terminal Shell
Solution 1
The easy and safe way
Open Terminal with Ctrl+Alt+T
, and type:
sudo chfn username
where username
is what shows in front of the @
in the prompt.
Your existing "display name" (shown at the login screen, on the top right of the desktop, etc.) will appear enclosed in brackets []
after Full Name:
. Type in whatever you want the new "display name" to be and press enter.
You can leave the remaining fields (Room number, Phone, etc.) blank (just keep pressing enter).
Once done, exit the terminal and logout. You should have a shiny new "display name"!
The direct but risky way
The original version of this answer proposed directly editing /etc/passwd
to change the "display name". This is risky if you don't know the format of the passwd file, since a typo could leave you unable to login any more. You have been warned.
The general format is:
username:x:1000:1000:displayname,,,,:/home/username:/bin/bash
Change "displayname" to whatever you want the name displayed on the login screen to be, e.g. "John Doe" or just the same as "username". This name CANNOT contain colons, commas or equal-to signs.
Save and quit your editor, and PLEASE then use pwck
to check that the format of /etc/passwd
is still valid, using:
sudo pwck | egrep -v "directory.*does not exist"
The response you are looking for is:
pwck: no changes
Otherwise, just logout, and you should see your chosen display name.
Solution 2
The easiest and safest way is to do it from the User Accounts application. You can run it by hitting the Windows/Meta key and entering user accounts
, or by clicking on your username (with the other app indicators on the top right) and select User Accounts...
from the drop down menu.
Then change it:
Before:
bcbc@14:00:19:~$ sudo cat /etc/passwd | grep bcbc
bcbc:x:1000:1000:712345:/home/bcbc:/bin/bash
After:
bcbc@14:00:53:~$ sudo cat /etc/passwd | grep bcbc
bcbc:x:1000:1000:bcbc:/home/bcbc:/bin/bash
Related videos on Youtube
Bill
Bill has just completed his Masters by Research in Computer Science and Software Engineering at the University of Wollongong. His research topic was in Lattice Based Cryptography. Bill is currently working as a sub-contractor for small companies and organisations developing desktop and/or web-based applications.
Updated on September 18, 2022Comments
-
Bill over 1 year
During the Ubuntu 12.04 LTS installation, I was prompted to enter a user name and password, so that a corresponding account could be created and set up for login. I replaced the one that was provided by default (i.e. '70319', which is the Windows 7 admin id) with a user name/id of my choosing.
Now, when I turn on the computer, and choose to enter the Ubuntu operating system, the login id that is displayed is 70319 - that is, the one provided by Windows 7. However, when I open up a Unix/Terminal shell, the user id that is displayed at the prompt is the one I entered during installation. Otherwise, the installation of Ubuntu was a success! Is there some way of changing the user id that is displayed at the Login screen, so that it is consistent with the one I entered during installation?
If it's any help, I installed Ubuntu using
wubi
on an ASUS Eee PC 1011PX running Windows 7, and ASUS Express Gate Cloud. Further details regarding the setup/installation can be found at the following link: -
ohno about 12 yearsYou should NOT edit /etc/passwd directly. At least check its structure afterwards with pwck! A better way to change the displayname is chfn. You even don't need to use sudo.
-
ish about 12 yearsI upvoted your comment @ohno, and am aware of
chfn
, but the problem is that Ubuntu by default does NOT allow editing the full name with chfn. (CHFN_RESTRICT = rwh
in/etc/login.defs
). Messing with login.defs to allow chfn to change the full name is even riskier, IMO. But usingpwck
to verify is a good idea, I will edit the answer to include that. -
ohno about 12 yearsYou still should not edit /etc/passwd directly:-) "sudo chfn ..." seems to override the settings in /etc/login.defs.
-
ish about 12 yearsYou're making me do my homework :).
sudo chfn username
is what finally works;sudo chfn
didn't/doesn't. -
ish about 12 yearsAnswer edited to recommend using
sudo chfn username
as the default way, with screenshot included. -
bcbc about 12 yearsThe normal way... click on your user name (top right) of desktop after logging in, click on
User accounts...
at the bottom of the menu that appears. then click on your name on the right of the window that appears. Now type in the new name. Then close the window. That's all. Logging off will show the new description.