Posted by: isaraffee | August 9, 2009

Changing the UID of user1

Changing the UID of user1

Before changing the UID, check the UID of user1:

[root@venus tmp]# more /etc/passwd | grep user1

user1:x:508:512::/home/user1:/bin/bash__

Edit the /etc/passwd file and change user1’s UID from 508 to 608 using the command vipw or vi /etc/passwd

[root@venus home2]# vipw

In vi mode, change the UID of user1.

Now verify that the UID has been updated.

[root@venus home2]# grep user1 /etc/passwd

user1:x:608:512::/home/user1:/bin/bash

Note that the home directory has not been changed to /home/home2/eng. You should also update the home directory coulumn to /home/home2/eng/user1.

[root@venus /root]# grep user1 /etc/passwd

user1:x:608:512::/home/home2/eng/user1:/bin/bash

Since we have changed the UID, you will need to change the owner on /home/home2/eng to user1’s new UID 608.

Before that view the ownership of the user1 directory

[root@venus /root]# ll /home/home2/eng/user1

total 1

-rw-r–r– 1 root root 0 May 21 18:11 business.txt

YPBINDPROC_DOMAIN: Domain not bound

drwx—— 2 508 user1 1024 May 21 18:11 tmp/

The file business.txt belongs to root instead of user1

[root@venus /root]# ll -ld /home/home2/eng/user1

YPBINDPROC_DOMAIN: Domain not bound

drwx—— 5 508 user1 1024 May 21 18:11 /home/home2/eng/user1/

Now change ownership of user1:

[root@venus /root]# chown -R user1 /home/home2/eng/user1

Check that the ownership of the files have been changed.

[root@venus /root]# ll -l /home/home2/eng/user1

total 1

-rw-r–r– 1 user1 root 0 May 21 18:11 business.txt

drwx—— 2 user1 user1 1024 May 21 18:11 tmp/

[root@venus /root]# ll -l /home/home2/eng/user1/tmp

total 0

-rw-r–r– 1 user1 root 0 May 21 18:11 somefile.txt__

The files above show that the files ownership have been changed to user1 but the group belongs to root. To change the group ownership as well type:

[root@venus /root]# chown -R user1:user1 /home/home2/eng/user1

Check that the group ownership has been changeg:

[root@venus /root]# ls -l /home/home2/eng/user1

total 1

-rw-r–r– 1 user1 user1 0 May 21 18:11 business.txt

drwx—— 2 user1 user1 1024 May 21 18:11 tmp/

[root@venus /root]# ls -l /home/home2/eng/user1/tmp

total 0

-rw-r–r– 1 user1 user1 0 May 21 18:11 somefile.txtt

Log in to the user1 account and see that everything is working


Leave a comment

Categories