In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about the comparison between useradd and adduser under Centos and Ubuntu. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
In fact, I read a lot of articles on the Internet at that time that the two commands had exactly the same effect, but when I tried it on Ubuntu10.04, I found that it was not the same. At that time, I complained about the miswork of articles on the Internet. Now, after my own experiments, I found that different versions of the Linux system have different interpretations of the two commands. I compared it under Centos with that under Ubuntu. First of all, let's take a look at Centos, let's go to the / usr/sbin directory and use the command
[cpp] [root@localhostsbin] # ll | grepuseradd
You can see the following results:
Looking at the * * and the third of the above results, we can see that adduser is linked to useradd, so in Centos, useradd and adduser play exactly the same role. After the user is created, a record of the new user is added to the / etc/passwd file, then the home directory of the new user is created in the / home directory, and the files in the / etc/skel directory are copied to this home directory. Note: new users created by this method cannot log in to the system until the password is set. You need to use the "passwd username" method under root authority to set the password for the specified user. Next time, you can log in to the system with this user name and password. Next, let's take a look at the Ubuntu system, or first go to the / usr/sbin directory and use the command:
[cpp] [root@localhostsbin] # ll | grepuseradd
You can see the following results:
You can see that under Ubuntu, useradd and adduser are separate commands, and there is no link relationship. I try to create a new user with the command useradd (without adding any parameters to useradd). The result is the same as the previous blog post (the article link is at the beginning of this article), and there is still no home directory for new users under / home. But this time I also looked at one file, which is / etc/passwd. I opened it and found that I did add information about my newly created user to / etc/passwd, but the login shell of this user was "/ bin/sh" unlike that of other users, and the login Shell of other users was / bin/bash. As shown in the following figure:
We can modify this file under the authority of root so that the login Shell of example is / bin/bash, and then we need to use the mkdir command to create a user directory for the user, that is, / home/example, and copy the files under the / etc/skel directory to the user directory, after setting the password, the new user can log in to the system like ordinary users.
Note: the above situation is that you do not use any specified parameters of useradd, so you need to do extra work manually. If you add a parameter "- m" when using useradd and set the password, then the user can log in to the system normally (see my previous blog post, the link is at the beginning of this article). In addition, it seems that the default login Shell created by useradd is / bin/sh, which can be changed to / bin/bash under the permission of root, or specified with the parameter "- s" when using useradd.
Now let's take a look at the adduser under Ubuntu10.04, or in / usr/sbin, use the following command to check the result:
[cpp] [root@localhostsbin] # ll | grepadduser
Looking at the above results, it is found that adduser and addgroup are the same command. Under Ubuntu, the default login Shell created by the adduser command is / bin/bash, which is different from useradd.
Combining the above two versions, it is found that the set of commands useradd and adduser are also different according to the system version.
This is what the comparison between useradd and adduser under Centos and Ubuntu is like. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.