changing ownership for diferent users from the command line
Hi: I have a webmail service in a server and today after a backup & restore all the ownerships got messed up so now everything is owned by user root and group root, how can I do, perhaps with a little shell script, to change for example every file that starts with user_name (than_random_letters_generated_by_the_webmail_software) to have owenership user_name.users ??? Thanks!! Raul
Hi: Ho ho hoo!
I have a webmail service in a server and today after a backup & restore all the ownerships got messed up so now everything is owned by user root and group root, how can I do, perhaps with a little shell script, to change for example every file that starts with user_name (than_random_letters_generated_by_the_webmail_software) to have owenership user_name.users ???
I have made myself a script that sets the correct ownerships. For this to work with Apache, make sure user wwwrun is in your 'users'-group. #!/bin/sh # # Setting the correct filerights for all users, preventing everybody to read/write in others' directories. # # Change to the /home directory cd /home # root is the owner of /home chown root.root /home # drwx--x--x for /home means a user cannot READ (r) this dirextory, but can go INTO (x), to change to their owns. chmod 0711 /home # For every userdirectory, set the filerights so that no user can go into anothers for i in `ls -1A` ; do # Set the owner chown -R $i.users $i # Set permissions chmod -R 0710 $i # Set permissions for Apache chmod -R 0750 $i/www/* done -cut here- For your Q with the random characters, perhaps you could use the stuff Alexandr Malusek gave to you. Kind regards, Rogier Maas
participants (2)
-
Raúl Gutiérrez Segalés
-
Rogier Maas