O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

1.7. chown and chgrp

When you create a file it is owned by the creator. Once you own a file, you can then change the ownership and give it to another user, so long as this is a valid user who has an entry in /etc/passwd. This can be in the form of the actual login name of the user or the user ID, which is a number. When you change ownership of a file, the suid bit is cleared for security reasons. Only the system administrator or the actual owner of the file may give the file away to another user. If you change the owner of the file you cannot claim it back. If you want it back, go and talk to your system admin.

Here’s the general format:

chown –R –h owner file 

The -R means you can do a recursive change on your files throughout your sub-directories ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required