在linux中更改用户ID
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18248056/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change user id in linux
提问by mryvlin
Here is a short description of what I want to do:
这是我想要做的事情的简短描述:
User tom has id 1000. I'm calling usermod -u 2000 tom
.
用户 tom 的 ID 为 1000。我正在调用usermod -u 2000 tom
.
What happens exactly besides that the id of tom changes to 2000? Do files and folders which were owned by this user still remain by this user or do I have to explicitly set the owner again?
除了 tom 的 id 更改为 2000 之外,还会发生什么?该用户拥有的文件和文件夹是否仍由该用户保留,还是我必须再次明确设置所有者?
Thanks for your help!
谢谢你的帮助!
采纳答案by StianE
usermod
will change permissions for the user's files inside his home directory. files outside his home directory will have to be changed manually.
usermod
将更改用户在其主目录中的文件的权限。他的主目录之外的文件必须手动更改。
man usermod lists the following caveats:
man usermod 列出了以下注意事项:
You must make certain that the named user is not executing any processes when this command is being executed if the user's numerical user ID, the user's name, or the user's home directory is being changed. usermod checks this on Linux, but only check if the user is logged in according to utmp on other architectures.
You must change the owner of any crontab files or at jobs manually.
You must make any changes involving NIS on the NIS server.
如果用户的数字用户 ID、用户名或用户的主目录正在更改,则必须确保指定用户在执行此命令时没有执行任何进程。usermod 在 Linux 上检查这一点,但只检查用户是否根据其他架构的 utmp 登录。
您必须手动更改任何 crontab 文件或 at 作业的所有者。
您必须在 NIS 服务器上进行任何涉及 NIS 的更改。