Israel Science and Technology Directory

Linux Permissions

Updated on January 20, 2026.

  1. Who is the owner?
  2. Changing ownership
  3. Instances that require change of owner
    1. Files/folders that are not owned by the user
    2. Changing directory owner for localhost management

Who is the owner? 🡱

In Linux operating systems (OS), when users log in to their accounts, they enter their so-called "home directory" by default. The home directory is a sub-directory within the /home folder under the main root directory. The name of this home folder matches the username. For example, if the username is "noah", the home directory will be /home/noah.

The "home directory" serves as the default location for personal files, documents, and settings for the specific user who is marked as the "owner". The owner has full control over the contents of the directory and sub-directories.

On a PC with several users, each user account is assigned a separate "home directory" under the Linux systems' /home directory. Examples: /home/oliver, /home/ted. The owner of each home directory is the respective user.

To see the "owner" of a file/folder, open the the system file manager (e.g. Nemo), right-click on the file name and select "Properties". Under the Permissions tab, the first item you'll see is "Owner: Username". Below that, there is a list of three rows of permissions for Owner, Group, and Others. The management of these are described on the Permissions page.

A user can navigate to the home directory by entering the command cd ~. The tilde (~) is a shortcut for the home directory.

Outside the home directory (/home/user), there are many directories of the OS, such as boot, etc, sys, and var. To see these, switch to the root directory by entering cd / in a terminal window. Then run ls -l command to list the directory. In the directory list, the owner of all these folders and files is root. The name "root" reflects the fact that OS directories are viewed as branches of the stem that starts at the root. The contents of these folders cannot be edited by the user. To edit these, the user can use Superuser privileges by prefixing a command with sudo. To avoid damaging the OS, such actions should be performed by knowledgeable and experienced users.

Changing ownership 🡱

The Bash command to change file and folder ownership is chown (change owner). The syntax of the command is:

chown [options] USER[:GROUP] [file/folder]

As seen in the syntax, the chown command can be used to change both file owner and group. Changing ownership to another user requires Superuser permission by prefixing command with sudo as follows:

sudo chown [new_user] example.txt

To change the owner of several files, list the file names separated by a space:
sudo chown [new_user] file1 file2 file3

To change the owner of all files and sub-folders in a directory, chown is run with the -R option that recursively changes the ownership of all files. Example:

sudo chown -R NewUser:NewGroup FolderName

Instances that require change of owner

Files/folders that are not owned by the user

When the owner of a file is different from that of the user it may be necessary to transfer the ownership of the file to the user, using chown command as described above.

Prior to using this command, it is recommended that you switch to the folder where the file or folder is located. This way you can set the instruction to modify the permissions of files/folders without specifying the full path address.

Changing directory owner for localhost management 🡱

A directory on a local computer that hosts a website is called a "localhost". Localhost is generally used to develop and test a local mirror of a website that does not require an external network. By default, a localhost is associated with the IP address 127.0.0.1.

In Linux, the recommended location for the localhost is the /var/www/html directory. As noted above, this directory belongs to root. Since a localhost may be accessed frequently by different users, there is a security risk managing this directory as root. In addition, if the root ownership is maintained, file editing will require sudo privileges, making the process cumbersome.

A secure and convenient method to manage the /var/www/html directory is to change the owner of the directory from root to your user name and set the group to the web server group, www-data as follows:

sudo chown -R $USER:www-data /var/www/html

$USER is a system variable that is equal to the name of the currently logged user.
www-data is a system group used specifically by web servers such Apache and Nginx. The use of www-data avoids the risky use of root privileges.

Next: Permissions needed for file and folder operations

ADVERTISEMENT