Hey guys, thanks for joining me again. Today, in this video we are going to be
going over more command line stuff, and it's file permissions and file ownership.
So, the first thing we need to do in order to discuss this is to have a file
that we currently don't have any permissions to, and the easiest way to do that is to
type "sudo nano file". What this is gonna do is as an administrator, or as the root
user, is going to use nano to produce a file named file. Im gonna put ".txt" there so we can keep
track of it. I'm going to type "Read" and CTRL + O to save, hit enter & CTRL + X.
Now if I type "ls -l" we see here that file.text is owned by the user
root, and that users group root. Now
what we've got here are provisions. The way these columns work is this this for
the owner. The owner can read and write, groups can only read, and public can only read.
So, if I wanna make myself able to read and write, I've gotta change his third
column to match that column. I've actually got to first share it with the group "nick"
So, what I'm gonna do is use a second command here called "sudo chown" and this
means change ownership, and then how we write this is we type the "user:group: So,
user corresponds to what we're setting this column to, group corresponds to what we're
setting this column to. So, I'm going to leave it as root for the user
that owns it, and share it with the group "nick" and then the file that we want to
perform this action on. Now if I type "ls -l" we should see here that file.txt
now is under ownership of the nick group. So, we need to change this third column
to write. So, how we do that is use chmod
use that as sudo to change the permissions of the file. Now 6 means it is readable
and writable, 4 means it is readable, and 7 means it's a directory. We don't use that
with single files and we'll go over that more in a moment. So, we're going to set the
permissions in numeric values that it currently has, it will look like that. So,
we can see that 4 corresponds to read access,
6 corresponds to read/write access. So what we want to do change the third
column here is we're going to type "sudo chmod 646" and then the file that we want to
perform this action on. Now if I type "ls -l" we can see that change has been made, so I can now
use nano file.text to write, and I can't. That's because the columns, I changed the
wrong column, we needed to change the second column. So, I'm gonna type "sudo chmod 664" on file.txt
When this is done, the first two columns are now read/write, read/write, and the
third column is just read.
So, now I can write to that file.