To change the full name and other information stored for a certain user, the chfn command will come in handy. This allows a system administrator to change the data with a simple command.
In this example, I am changing the full name of a Linux user.
root@darkstar:~# chfn -f "Jason Smith" jason |
Now I use the finger command to view the information as I am already logged in as this user.
root@darkstar:~# finger -lmps Login: jason Name: Jason Smith Directory: /home/jason Shell: /bin/bash On since Tue Nov 15 07:59 (AEDT) on tty7 from :0 On since Tue Nov 15 08:33 (AEDT) on pts/0 from :0 1 minute 33 seconds idle On since Tue Nov 15 08:44 (AEDT) on pts/2 from :0 4 seconds idle (messages off) No mail. |
That is how easy this is. Below is some information regarding the other things that may be edited by this command.
The options which apply to the chfn command are: -f, --full-name FULL_NAME Change the user's full name. -h, --home-phone HOME_PHONE Change the user's home phone number. -o, --other OTHER Change the user's other GECOS information. This field is used to store accounting information used by other applications, and can be changed only by a superuser. -r, --room ROOM_NUMBER Change the user's room number. -R, --root CHROOT_DIR Apply changes in the CHROOT_DIR directory and use the configuration files from the CHROOT_DIR directory. -u, --help Display help message and exit. -w, --work-phone WORK_PHONE Change the user's office phone number. If none of the options are selected, chfn operates in an interactive fashion, prompting the user with the current values for all of the fields. Enter the new value to change the field, or leave the line blank to use the current value. The current value is displayed between a pair of [ ] marks. Without options, chfn prompts for the current user account. |
The usermod command is another way to accomplish this, use this command to change the full name.
root@darkstar:~# usermod -c "John Snow" jason |
This is also very effective.
root@darkstar:~# finger -lmps Login: jason Name: John Snow Directory: /home/jason Shell: /bin/bash On since Tue Nov 15 07:59 (AEDT) on tty7 from :0 On since Tue Nov 15 08:33 (AEDT) on pts/0 from :0 32 minutes 25 seconds idle On since Tue Nov 15 08:44 (AEDT) on pts/2 from :0 1 second idle (messages off) No mail. |
This way, user information may be easily edited. This makes it easy to change user information with a simple command.
Another way is to edit the /etc/passwd file in VIM to change the user`s details.