Linux Changing File Ownership
In Linux, you can change the ownership of a file using the chown
command.
The syntax of the chown
command is as follows:
csssudo chown [new_owner_username] [file_name]
For example, if you want to change the ownership of a file named example.txt
to a user named johndoe
, you would run the following command:
bashsudo chown johndoe example.txt
If you want to change the ownership of a directory and all its contents recursively, use the -R
option:
bashsudo chown -R johndoe mydirectory
This will change the ownership of the directory mydirectory
and all its contents to the user johndoe
.
Note that you need to have root privileges or be the owner of the file/directory in order to change its ownership.
Comments
Post a Comment