Changing Ownership of Files and Directories with chown


Changing Ownership of Files and Directories with chown

Suppose you've been working on a file called rowyourboat, and your boss decides to let a coworker, Merrilee, take over the project. In this case, to fully pawn off the project to your coworker, you need to change ownership of the file from you to her. Depending on how your system administrator set up the system, you can usually change ownership of files using chown (Code Listing 5.6).

Code Listing 5.6. Changing ownership of files transfers complete control.

[ejr@hobbes merrilee]$ ls -l total 26 -rw-rw-r-       1 ejr          users     24850 Jul 24 15:17 rowyourboat [ejr@hobbes merrilee]$ chown merrilee rowyourboat [ejr@hobbes merrilee]$ ls -l total 26 -rw-rw-r-       1 merrilee     users     24850 Jul 24 15:17 rowyourboat [ejr@hobbes merrilee]$ 

To change ownership with chown:

1.

ls -l

For starters, type ls -l at the shell prompt to verify the file's name and ownership, as in Code Listing 5.6. Remember that the ownership information is located after the permissions and linking information.

2.

chown merrilee rowyourboat

Type chown followed by the userid of the person you want to transfer ownership to and the filename. In this case, the chown command changes the ownership for rowyourboat to merrilee. rowyourboat and its associated problems will now be hers, and life will be but a dream.




Unix(c) Visual Quickstart Guide
UNIX, Third Edition
ISBN: 0321442458
EAN: 2147483647
Year: 2006
Pages: 251

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net