UIDをMac OS Xと同じにする

Q. How do I change user name (rename user name) or UID under Linux operating system?

A. Use the usermod command to change user name under Linux. it modifies the system account files to reflect the changes that are specified on the command line.

Syntax is as follows
usermod -l login-name old-name


Where,

=> The name of the user will be changed from old-name to login_name. Nothing else is changed. In particular, the user's home directory name should probably be changed to
reflect the new login name.

usermod -u UID username


Where,
=> The numerical value of the user's ID (UID) . This value must be unique, unless the -o option is used. The value must be non-negative. Values between 0 and 99 are typically reserved for system accounts. Any files which the user owns and which are located in the directory tree rooted at the user's home directory will have the file user ID changed automatically. Files outside of the user's home directory must be altered
manually.
Task: Change username from tom to jerry

Type usermod command as follows:
# id tom
# usermod -l jerry tom
# id jerry
# id tom


Task: Change user tom UID from 5001 to 10000

Type usermod command as follows
# id tom
# usermod -u 10000 tom
# id tom



Read man page of usermod for more information.




As I recall, usermod only updates UIDs for files in the user’s home directory and the mail spool. You also have to consider files in /tmp or /var that can be persistent between user sessions, or even reboots depending on your OS. I just do this to ensure that all files have been changed,

find / -user 5001 -exec chown -h 10000 {} \;

or maybe this,

find / -user 5001 | xargs chown -h 10000

Use the ‘-h’ switch to chown so that it updates the ownership of symbolic links rather than what the symlink points to.



sudo -i
gedit /etc/login.defs

Change the value UID_MIN to 501
Change the value GID_MIN to 501
Save the file and exit.


sudo -i
gedit /etc/group

Substituting powermonkey for your username look for a line like this:
powermonkey:x:1000:
and change it to (switching out your username for powermonkey) this:
powermonkey:x:501:
Save and exit.



sudo -i
gedit /etc/passwd

powermonkey:x:1000:1000:Powermonkey,,,,:/home/powermonkey:/bin/bash
and now change it to this:
powermonkey:x:501:501:Powermonkey,,,,:/home/powermonkey:/bin/bash
save and exit



You’ll now need to change all the file permissions in your home folder. This is easy enough to do. Go to Administration > Groups and Users or type users-admin in the terminal. Unlock the GUI with your password, add a new user called temp. Click on advanced setting to give the user permission to administrate the computer. Save all of your settings and when you’re done, log out and log back in as the new user temp.
Open a terminal and type as follows, again using powermonkey as a substitute for your normal username.
sudo -i
cd /home
chown 501:501 powermonkey







end

タグ:

+ タグ編集
  • タグ:

このサイトはreCAPTCHAによって保護されており、Googleの プライバシーポリシー利用規約 が適用されます。

最終更新:2010年04月30日 13:36
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。