Linux/Unix – Finding things and replacing it on directories or files.

Find an user and replace the ownership for his file/directories.

 

This is a very usefull command

find . -user 24204 -exec chown ivcel {} \;

find . –user <current_user_name> -exec chown <new_user_name> {}\;

 

  This will traverse the file system finding the user “<current_user_name> ” and changing it to <new_user_name> it might be owner instead of user.  When you use find you don’t have to worry about links.

Another examples are:

This sentence find directories named BMPGwork and change it ownership to bmpdb.

find /p/bmp/proc/projects/db_root/bmp -follow -maxdepth 3 -mindepth 3 -name BMPGwork -type d -exec chown -R bmpdb {} \;

 

This sentence find directories named BMPGwork and change it permission schema to 750.

find /p/bmp/proc/projects/db_root/bmp -follow -maxdepth 3 -mindepth 3 -name BMPGwork -type d -exec chmod -R 750 {} \;

Advertisements

About msotela

This blog is for anyone who wants to access the power of a Linux system as a systems administrator or user. You may be a Linux enthusiast, a Linux professional, or possibly a computer professional who is increasingly finding the Windows systems in your data center supplanted by Linux boxes.

Posted on March 15, 2009, in Unix/Linux. Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: