• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 523
  • Last Modified:

Question in Linux home directory

I need to perform this tasks on 10 Servers


remove the account of user A ( h95922) .

DO NOT REMOVE THE HOME DIRECTORY
Move the home directory for h95922 to the home directory of User_B , and make User_B  of the files.  Also, do a find from the / directory of the systems
and search for any files owned by h95922 and change the ownership to User_B .  


the commands i am thinking to use are :



# userdel h95922
# mv /home/h95922 /home/User_B
# cd /home/user_B/h95922
# chown -R user_B /home/h95922


is this correct so far ?




Also, do a find from the / directory of the systems
and search for any files owned by h95922 and change the ownership to User_B .  

( any help on this would be appreciated)
0
c_hockland
Asked:
c_hockland
1 Solution
 
farzanjCommented:
Yes.

find / -user h95922 -exec chown User_B {} \;
0
 
Darr247Commented:
This sounds like a homework. Is it?
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
@c_hockland - Answer of farzanj is correct but: you could have tested all the commands you listed on a testuser / testdirectory yourself so why the question?
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Seth SimmonsSr. Systems AdministratorCommented:
the fourth line is incorrect because the second line you have User_b for destination folder so that command wouldn't work.  it would be chown -R user_b /home/user_b/h95922

farzanj's find command wouldn't work since you are specifying the user though your first command you are removing the user account; you would instead specify -uid <uid> since the user doesn't exist and the files would only show uid/gid (or group) in a directory listing (example - if h95922 uid is 600, use find / -uid 600 and your other parameters/expressions)
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
>> the fourth line is incorrect
No, it is correct, the h95922 folder is moved to a subfolder of user_B and the chown is recursive so subfolder h95922 has owner user_B after the chown command.
0
 
Seth SimmonsSr. Systems AdministratorCommented:
i understand it's recursive

read what you just wrote...the h95922 folder is moved to a subfolder of user_B, I understand that.  now look at specified path in that command - /home/h95922

with h95922 being moved under user_b then h95922 wouldn't be directly under /home, now would it?  the path would be /home/user_b/h95922 so the correct 4th command would be chown -R /home/user_b which would, of course, trickle down through the h95922 folder within; or just chown -R /home/user_b/h95922 for just that folder that was moved
0
 
Gerwin Jansen, EE MVETopic Advisor Commented:
Yup, the path is wrong ;)

Still: OP could have tested all this before asking the question...
0
 
c_hocklandAuthor Commented:
these are production servers .
Unfortunately i cannot create test users and test these commands.
0
 
serialbandCommented:
You could use virtualbox or xen to make test servers.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now