Do You Want to Learn Marketing or Coding? Do You Want to Learn Marketing or Coding?

SSH Find User ID and replace it

Share on facebook
Share on twitter
Share on linkedin

Sometimes you have a web site with a bunch of different users and groups. This can happen whenever are moving sites from one server to another. What happens when you don’t want to just use chown -R username:group file because it changes the user of all of these files? Here is a simple find and replace command that will look for a specific username and change it with another.

[cc lang=’php’ ]find . -uid <uid> -exec chown <new uid> {} \; [/cc]

Make sure you remove the <> around the user id.   So if you have a directory that has files with the user id 1001 and would like to change it to 2002. You would run the code like this:

[cc lang=’php’ ]find . -uid 1001 -exec chown 2002 {} \; [/cc]

This will run through the current file and change all users from 1001 to 2002.

I Really Need

Reviewing nerdy stuff is expensive.

Consider clicking on this ad & buying that item you REALLY wanted from Amazon.

It helps a ton!

Leave Your Thoughts