From a18fd31b8e4e474efcdc53d3b538ecccc47312bc Mon Sep 17 00:00:00 2001 From: darksun Date: Sat, 30 Dec 2017 18:15:14 +0800 Subject: [PATCH] translate done: 20171128 How to rename user in Linux (also rename group - home directory).md --- ...ux (also rename group - home directory).md | 64 ---------------- ...ux (also rename group - home directory).md | 76 +++++++++++++++++++ 2 files changed, 76 insertions(+), 64 deletions(-) delete mode 100644 sources/tech/20171128 How to rename user in Linux (also rename group - home directory).md create mode 100644 translated/tech/20171128 How to rename user in Linux (also rename group - home directory).md diff --git a/sources/tech/20171128 How to rename user in Linux (also rename group - home directory).md b/sources/tech/20171128 How to rename user in Linux (also rename group - home directory).md deleted file mode 100644 index 30a65a62ad..0000000000 --- a/sources/tech/20171128 How to rename user in Linux (also rename group - home directory).md +++ /dev/null @@ -1,64 +0,0 @@ -translating by lujun9972 -How to rename user in Linux (also rename group & home directory) -====== -We might have come across a situation where we might want to rename user in Linux system, for whatever reasons. We can easily rename user in Linux & also we can rename the home directory or its UID as well. - -In this short tutorial, we will be discussing these things only. Let's start by renaming user in Linux first, -**(Recommended Read:[How to use FIND command to locate anything in Linux][1])** -### Rename user in Linux - -For renaming user in Linux systems, we will use ** 'usermod'** command. Syntax for the command is, - - **$ usermod -l new_username old_username** - -For example, if we have a user named ** 'dan'** & want to rename it to **' susan'**, execute the following command from terminal; - - **$ sudo usermod -l susan dan** - -This will only change the username & everything else, like group, home directory, UID will remain same. - - **Note:-** You should need to logged out from the account you are trying to rename. You can also kill all the processes running for that user, to do so execute the following command, - - **$ sudo pkill -u dan** - - **$ sudo pkill -9 -u dan** - -### Renaming Home directory - -For renaming home directory to correspond to the renamed user, we use ** '-d'** option with **' usermod'** command., - - **$ sudo usermod -d /home/susan -m susan** - -### Changing UID for the user - -To change the UID of the user , execute the following command, - - **$ sudo usermod -u 2000 susan** - -where **' 2000'** is the new UID for user. - -### Renaming the group - -To rename the group from ** 'dan'** to **' susan**', we will use **' groupmod'** command. Use the following command to rename the group, - - **$ groupmod -n susan dan** - -Once we have made the required changes, we can than check the changes made using the ** 'id'** command, - - **$ id susan** - -With this we end this tutorial on how to rename user in Linux. Please let us know if you have any question or any issue or if you do have any suggestion, please do let us know that as well. - - --------------------------------------------------------------------------------- - -via: http://linuxtechlab.com/rename-user-in-linux-rename-home-directory/ - -作者:[Shusain][a] -译者:[lujun9972](https://github.com/lujun9972) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://linuxtechlab.com/author/shsuain/ -[1]:http://linuxtechlab.com/use-of-find-command/ diff --git a/translated/tech/20171128 How to rename user in Linux (also rename group - home directory).md b/translated/tech/20171128 How to rename user in Linux (also rename group - home directory).md new file mode 100644 index 0000000000..e489cf6380 --- /dev/null +++ b/translated/tech/20171128 How to rename user in Linux (also rename group - home directory).md @@ -0,0 +1,76 @@ +Linux 下如何修改用户名(同时修改用户组名和 home 目录) +====== +有时候,由于某些原因,我们可能会需要重命名用户名。我们可以很容易地修改用户名以及对应的 home 目录和 UID。 + +本教程将会讨论这些东西。让我们先从修改用户名开始, +**(推荐阅读:[Linux 下如何用 FIND 命令查找想要东西的路径 ][1])** +### 修改用户名 + +我们使用 `usermod` 来修改用户名。其语法为, + +``` +$ usermod -l new_username old_username +``` + +举个例子,假设我们有一个名叫 `dan` 的用户想要重命名为 `susan`,那么在终端下执行下面命令; + +``` +$ sudo usermod -l susan dan +``` + +这只会更改用户名,而其他的东西,比如用户组,home 目录,UID 等都保持不变。 + + **注意:-** 你需要从要改名的帐号中登出并杀掉该用户的所有进程,要杀掉该用户的所有进程可以执行下面命令, + +``` +$ sudo pkill -u dan +$ sudo pkill -9 -u dan +``` + +### 修改 Home 目录 + +要同时更改 home 目录,我们需要在执行 `usermod` 命令的同时加上 `-d` 选项, + +``` +$ sudo usermod -d /home/susan -m susan +``` + +### 更改用户 UDI + +执行下面命令修改用户 UID, + +``` +$ sudo usermod -u 2000 susan +``` + +这里 `2000` 就是用户的新 UID。 + +### 修改用户组名 + +要把用户组名从 `dan` 修改为 `susan`,我们需要使用 `groupmod` 命令。使用下面命令来修改用户组名, + +``` +$ groupmod -n susan dan +``` + +做完修改后,可以使用 `id` 命令来检查, + +``` +$ id susan +``` + +这篇教导如何修改用户名的指南就此结束了。有任何疑问或建议,欢迎给我们留言。 + + +-------------------------------------------------------------------------------- + +via: http://linuxtechlab.com/rename-user-in-linux-rename-home-directory/ + +作者:[Shusain][a] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://linuxtechlab.com/author/shsuain/ +[1]:http://linuxtechlab.com/use-of-find-command/