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 introduces the relevant knowledge of "how the Linux system modifies the uid and gid of existing users". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Under the Linux system, it is sometimes necessary to mount the common NAS on different hosts, and the files or folders in the NAS are required to have the same master group, which requires some users (usually business users) and user groups on each host to have the same uid and gid. If the systems of different hosts do not create users according to the same rules, you may need to modify the uid and gid of existing users (groups). The following is an example to describe the modification method:
Before modification:
There are two users, tomcat and nginx, whose information is as follows
Uid=501 (tomcat) gid=501 (tomcat) groups=501 (tomcat)
Uid=500 (nginx) gid=500 (nginx) groups=500 (nginx)
The requirement is modified to:
Uid=501 (nginx) gid=501 (nginx) groups=501 (nginx)
Uid=500 (tomcat) gid=500 (tomcat) groups=500 (tomcat)
Note when modifying:
1. Stop all applications under tomcat and nginx users first.
2. When changing, you cannot log in to SSH with tomcat or nginx users.
3. After the change, you have to restore the directory to the master group.
Modify the steps:
1. For root users, change one of them first. Nginx is selected here.
First replace nginx with unused uid and gid
Id nginx;groupmod-g 507 nginx;usermod-u 507-g nginx nginx;id nginx
2. Set the files and folders originally belonging to the main group as nginx to nginx again.
This step should be paid special attention to, in this case, tomcat and nginx happen to exchange uid and gid, so before tomcat users switch to nginx's uid and gid (here is 500,500), set the files and folders that used to belong to the master group as nginx again (which requires familiarity with the relevant paths) to avoid confusion.
Chown-R nginx:nginx / home/nginx
Others are modified according to the actual situation.
You can find it here with the help of the find command, such as finding files and folders with a gid of 500in the root directory
Find /-gid 500
3. Modify uid and gid of tomcat
The 500 needed by tomcat has been freed before, but now the uid and gid of tomcat can be changed to 500.
Id tomcat;groupmod-g 500 tomcat;usermod-u 500-g tomcat tomcat;id tomcat
4. Set the files and folders originally belonging to the main group as tomcat to tomcat again.
Chown-R tomcat:tomcat / home/tomcat
Others are modified according to the actual situation.
5. Modify nginx's uid and gid again
The 501s needed by nginx have been freed before, but now the uid and gid of nginx can be changed to 501s.
Id nginx;groupmod-g 501 nginx;usermod-u 501-g nginx nginx;id nginx
6. Set the files and folders originally belonging to the main group as nginx to nginx again.
Chown-R nginx:nginx / home/nginx
Others are modified according to the actual situation.
7. Application recovery and check
Restore the applications previously stopped by tomcat and nginx users, see if they can start normally, and check if there are any missing operations.
This is the end of the content of "how to modify the uid and gid of existing users in Linux system". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.