Changing Ownership

Learn how to change the ownership of files and directories.

Setting permissions

Changing ownership is the easier method, and it’s often the only method we need. The permissions are set correctly in most cases, but they’re applied to the wrong user and group. That’s the case here, as well.

The chown command

The chown command lets us change the owner and group of a directory.

$ sudo chown temp:temp /var/files

We get a new directory listing to check the ownership:

$ ls -alh /var/files/

Run the complete code on the terminal below for practice.

cd var
mkdir -p files/docs/manuals
cd ..
clear
su temp
cd var
clear
sudo chown temp:temp /var/files
ls -alh /var/files/

Get hands-on with 1400+ tech skills courses.