快轉到主要內容

Change username and home folder in ubuntu

·189 字· loading · loading ·
目錄

Permission
#

Note that the following commands may need to be run with root permission.


Logout the user
#

You need to logout the user before change username.

Change user and group name, for example, change username from older to newer:

1usermod -l newer older
2groupmod -n newer older

If system show the message usermod: user older is currently used by process xxxx when you trying to enter the commands above, it means that you have not fully logged out all of this user.

You can check what process is hogging the user by htop(or top), and kill the process.
Or just kill the all processes which is run on this user, for example, to kill the all processes running by user older:

1killall -u older

Btw, you can also use the w(or who) command to check which users are logged in.


Change home holder
#

For example, the new username is newer, enter the command:

1usermod -d /home/newer -m newer

If nothing else, the home folder of the user newer has been changed to /home/newer.


References
#

Alpaca
作者
Alpaca
No one can stop my feet.

相關文章