linux重命名用户名_如何在Linux中更改或重命名用户名和用户ID?
linux重命名用户名The problem is we want to change the already created user name or user id. As we know there is a lot of configuration those rely on the user id like permissions. We will use usermod command
linux重命名用户名
The problem is we want to change the already created user name or user id. As we know there is a lot of configuration those rely on the user id like permissions. We will use usermod
command to make this change. Keep in mind this changes will effects system wide.
问题是我们要更改已经创建的用户名或用户ID。 我们知道有很多配置都依赖于用户ID(例如权限)。 我们将使用usermod
命令进行更改。 请记住,此更改将影响整个系统。
列出用户信息 (List User Info)
Before starting to big changes we will list users detailed info with cat
command like below.
在开始进行较大的更改之前,我们将使用下面的cat
命令列出用户的详细信息。
$ cat /etc/passwd | grep ismail
test is our user name for this operation
test是此操作的用户名
1000 is the current id of our test user.
1000是我们测试用户的当前ID。
变更使用者名称 (Change User Name)
We will change username with the following command by providing new username. We will provide the -l
option with the new username and old username. In this example we will change username ismail
into ali
.
我们将通过提供新的用户名,使用以下命令更改用户名。 我们将为-l
选项提供新的用户名和旧的用户名。 在此示例中,我们将用户名ismail
更改为ali
。
$ sudo usermod -l ali ismail
usermod is command we issue to chage
usermod是我们发出的命令
-l ali is the new username
-l ali是新的用户名
ismail is the original username
ismail是原始用户名
变更使用者编号(Change User ID)
Another opportunity is changing the user ID. Previously we have listed user information of the ismail
. We know that the user id of the ismail
is 1000
. We will use -u
option and the new user id with the user name. In this example we will change the user id of ismail
into 1010
另一个机会是更改用户ID。 以前我们已经列出了ismail
用户信息。 我们知道ismail
的用户ID是1000
。 我们将使用-u
选项和带有用户名的新用户ID。 在此示例中,我们将ismail
的用户ID更改为1010
$usermod -u 1010 ismail
usermod is command used too
usermod也使用命令
-u 1010 is new user id provided for the user
-u 1010是为用户提供的新用户ID
ismail is the user whose id will be changed.
ismail是将更改其ID的用户。
再检查一次 (Check It Again)
After these steps we need to the if there is a problem or everything is OK. We will list user information again with the cat
command like below.
完成这些步骤后,我们需要确定是否存在问题或一切正常。 我们将使用cat
命令再次列出用户信息,如下所示。
$cat /etc/passwd | grep test
test2 is new username but home directory stays the same
test2是新的用户名,但主目录保持不变
1010 is the users new id
1010是用户的新ID
如何在Linux中更改或重命名用户名和用户ID? 信息 (How To Change or Rename Username and User ID In Linux? Information)
翻译自: https://www.poftut.com/change-rename-username-user-id-linux/
linux重命名用户名
更多推荐
所有评论(0)