File Ownership - Linux

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this lesson we're going to discuss file and directory ownership within the Linux file system now to effectively control who is allowed to do what with the files and directories in the file system you first have to consider who owns each file and directory so let's begin this lesson by discussing how ownership works understand that anytime a user creates a new file or a new directory in the Linux file system that users account is assigned to be that file or directories owner by default now by default the owner of a directory in the Linux file system will automatically receive read write and execute permissions to that directory which basically allows them to do whatever they want to do in that directory as that directories owner likewise the owner of a file in the Linux file system will receive read and write permissions to that file by default for example suppose I log in to my Linux system and then I open up my libera office word processing application and I create a file named schedule DT in my home directory now because I created this file the owner of this file is me as it shows right here which is actually the are Tracy user because the are Tracy user account created this file the are Tracy user is automatically assigned ownership of scheduled ODT in this screen what we did was right click on this file in the graphical user interface of my Fedora system and then I selected properties and then I selected the permissions tab right here and here I can see who the files owner is now be aware that there are actually two different owners for this file the first one is the name of the user who owns the file again that's me are Tracy but in addition there's also a group that owns the file as well and by default it will be the primary group of whatever user created the file in the first place in this case my default group on this system is the art Tracy group because that's the primary group that the art Tracy user - therefore the owner of the file is the art tracer user and the owning group of the file is the art Tracy group you can also view file and directory ownership from the command line using the LS dash L command in this example I ran the command in my users home directory notice that the third column in the output displays the name of the file or directory zoner in this case they are all owned by our Tracy the fourth column over here displays the name of the group that owns a file now all of them are owned by the art Tracy group except for one the run me file is owned by a different group it's owned by a group named users now understand that file and directory ownership isn't fixed even the ownership is automatically assigned whenever a file of directory is created you can modify it if you want to you can specify a different user or a different group or both as the owner of a particular file or directory in the file system but to do so you need to keep this in mind in order to change the user who owns a file you have to be logged in as root only root is allowed to do this but to change the group that owns a file you have to be logged in as either root or as the user who currently owns the file now there are a couple of different utilities that you can use to do this the first one is the Chong utility which stands for a change owner it can be used to change the user or the group that owns a particular file or directory and the syntax is shown here you enter chi own followed by the name of the user or the group that you want to change ownership to followed by the file or directory in the file system whose ownership you want to change for example suppose I have a file named resources txt it's located in the slash TMP directory and currently that file is owned by the root user well I want to change the ownership of that file from root to the are Tracy user to do this I would enter to own and then the name of the user that I want to change ownership to in this case are Tracy and then the name of the file if we do an LS command down here LS dash L we see that our Tracy is now the user that owns the resources dot txt file but notice that the name of the group that owns the file was not changed the group named root which is the primary group associated with the root user still owns this file and this was assigned when the file was originally created by the root user well suppose I want to change the group that owns the file to my primary group from the root users primary group now my primary group is the art traci group therefore i would enter to own and then i would enter dot r tracy and then the name of the file that i want to modify now this dot right here is very very important because essentially what it does is tell that your own command the the entity that follows is not a username but is a group name when we run the command we see that the name of the owning group has now changed from root to our Tracy now be aware that I could have actually accomplished both tasks with one single command you can change the owning user and group at the same time by simply specifying the name of the user first then the period and then the name of the group that you want to change ownership to and then the name of the file does it all at once and also be aware that you can use the - capital R option with the QI own command in the examples that we've shown right here where we're modifying just one single file at a time and that's fine if you just have one single file to modify but if you have a whole bunch of files that you need to modify and you have maybe even sub directories containing files whose ownership you need to modify - are saves a ton of time basically this tells to own to change ownership recursively in which case it'll burrow down through all of the sub directories of whether whatever path you specify and apply the ownership change that you specify to all of those files all at once in addition to the chown command there's another command that you can use to manage ownership is the check group command and as its name implies it's only used to change the name of the group that owns a file a directory it cannot be used to modify the user that owns a file a directory the syntax is pretty straightforward you enter to group the name of the group that you want to change ownership to followed by the name of the file that you want to modify that's it for this lesson in this lesson we discussed file and directory ownership we first discussed how ownership works we also discuss how to change the owning user and the owning group using Chone and then we ended this lesson by talking about how to use to group to change just the owning group
Info
Channel: The Linux Man
Views: 2,664
Rating: 4.949367 out of 5
Keywords: Linux
Id: I8fhN3ZIft0
Channel Id: undefined
Length: 7min 12sec (432 seconds)
Published: Thu Nov 24 2016
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.