How To Linux How to Use The Chown Command On Linux Easily change the owner of Linux files Share Pin Email Print Linux Guides & Tutorials Basics Installing & Upgrading Tips & Tricks Commands Key Concepts by Jack Wallen Jack Wallen is a former Lifewire writer, an award-winning writer for TechRepublic and Linux.com, and the voice of The Android Expert. Updated October 20, 2019 With Linux, every file is owned by a specific user. Although files support group permissions, the purpose of ownership is to ensure that only those who actually have access to the file have the ability to read, write, or execute it. Without ownership, those files are, generally speaking, off limits. When you open a terminal window on your Linux desktop and issue the command ls -l, you will see the third column from the left displaying who the owner of the files and folders are. These assignments aren't fixed, however. You're free to change the owner of the file or folder with the help of the chown command. A Word Of Warning To change the ownership of files or directories, use sudo. By using sudo, you are able to run sensitive tasks that require elevated privileges, which means you can act on files or directories you wouldn’t normally be able to. Changing Ownership of a Single File Let’s say you have two users on your Linux machine: bethanyjacob The user bethany owns a file named test that jacob needs to access. If bethany issues the command ls -l, she notes that she is the owner of the file. For bethany to change the ownership of the file test such that it is then owned by jacob, she issue the command: sudo chown jacob ~/test After running this command, bethany then checks the ownership with the command ls -l to see that jacob is now the owner of the file. However, just because jacob is the owner of the file, doesn’t mean he has both read and write access. Why? Because, as it stands, the file is in a directory (/home/bethany) owned by bethany, and jacob doesn’t have write access to the directory. In order for jacob to have both read and write access, the file would have to be moved into a directory giving jacob both read and write access. Bethany can move that folder into jacob’s home directory with the command: sudo mv ~/test /home/jacob Or, even better, bethany can create a new directory and give jacob read and write access to that folder by way of ownership. This would be done (by user bethany) with the following steps: Create a new directory with the command mkdir ~/jacob Change the ownership of the directory with the command: sudo chown jacob ~/jacob Move the test file into the new directory with the command mv test ~/jacob Although the new directory is owned by jacob, because the directory /home/bethany/jacob still belongs to the group bethany (as noted by the fourth column from the left), the user bethany is still able to access the file (with both read and write privileges). Changing Ownership of an Entire Directory Say bethany has an entire directory (filled with files) that jacob needs access to. She can either change the ownership of those files, one at a time, or she can simply change it all in one fell swoop. To give jacob ownership of that directory, bethany would run the command sudo chown -R jacob ~/jacob The -R option stands for recursive, which means it will change the ownership of the directory and then dive into the directory and change the ownership of all the files contained within. Continue Reading