Commands for Managing Ownership and Permissions
This section presents the details of the chown and chmod commands, which are the essential tools for assigning file system rights in the Linux environment. You can view the ownership and permissions for a file using the ls command with the -l option.
The chown command
The chown command changes the owner of a file. Normally, the user who creates a file is the owner of the file. However, the owner can transfer the file to someone else via this command. The basic syntax of this command is
chown user file
For example, to change the owner of a file named rescue.plans to user professor, use this command:
$ chown professor rescue.plans
To change ownership of all the files in the directory named /home/island to professor, use this command:
$ chown professor /home/island
Tip Issuing the following command would be a really bad idea:
$ chown gilligan rescue.plans
In this tutorial:
- Linux Commands
- Command Shell Basics
- Editing commands
- Wildcards
- Redirection and piping
- Environment variables
- Shell scripts
- Directory and File Handling Commands
- The cd command
- The mkdir command
- The rmdir command
- The ls command
- The cp command
- The rm command
- The mv command
- The touch command
- The cat command
- Commands for Working with Packages and Services
- The rpm command
- Commands for Administering Users
- The usermod command
- The chage command
- The passwd command
- The newusers command
- The groupadd command
- The groupdel command
- Commands for Managing Ownership and Permissions
- The chgrp command
- The chmod command
- Networking Commands
- The ipconfig command
- The netstat command
- The ping command
- The route command
- The traceroute command