Вы находитесь на странице: 1из 3

libe riange e k.

ne t

http://www.liberiangeek.net/2012/01/ubuntu-tip-change-o wnership-o f-files-fo lders/

[Ubuntu Tip] Change Ownership of Files / Folders


T his quick tip shows you how to change the ownership of f iles and f olders in Ubuntu. T his will work in all versions of Ubuntu, including Ubuntu 11.10 (Oneiric Ocelot). When you use the sudo command to install packages or create f olders, the root account automatically assumes ownership. And if a regular user wants to edit or modif y the f ile of which the root is the owner, he or she will be denied. In this case, youll have to give ownership of the f ile to the user who will be modif ying it, and this is why this tutorial is here. Without wasting anymore of your time, lets continue below to learn how.

Objectives: Change ownership of f iles and f olders in Ubuntu Enjoy!

To get started, press Ctrl Alt T on your keyboard to open Terminal.

T he f irst thing you might want to do is list the content of the current directory. If youre a new user, run the ls command. ls

T he ls command lists the content of the current directory.

To change the ownership of a single f ile, run the command below. sudo chown <username>:<groupname> lename

Replace <username> with the username of the account you wish to take ownership of the f ile. And <groupname> is the group that will assume ownership of the f ile.

By def ault, when a new account is created in Linux, a group is also created named af ter the username of the account. For example, if a user account is created with username <pumpkin>, a group will automatically be created named <pumpkin> and the user is automatically made a member of that group.

So, if you run the commands below, youre giving ownership to the user <pumpkin> and the <pumpkin> group. sudo chown pumpkin:pumpkin le.t xt

But wait, you dont always need to specif y a group everytime you wish to change the ownership of a f ile. You could just change the username f or a particular f ile and the group can stay intact. sudo chown <username> <lename.t xt >

Now that you know how to change the ownership of a single f ile, the below commands show you how to change the ownership of a f older and all sub-f olders within. sudo chown -R <username>:<groupname> FolderName

T hats it! And I hope you liked it.

Вам также может понравиться