umask and Permissions
Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or
Already have an account? Sign In »

Video Transcription
00:00
>> Hey, Cybrarians. Welcome back to
00:00
the Linux Plus course here at Cybrary.
00:00
I'm your instructor Rob Gills.
00:00
In today's lesson we're going to be
00:00
discussing the umask and Permissions.
00:00
Upon completion of today's lesson,
00:00
you are going to be able to understand
00:00
the purpose of umask.
00:00
We're going to talk about how umask is configured,
00:00
and then we'll determine where are umask
00:00
should be set to set it permanently.
00:00
In addition to ownership that an object is created
00:00
with it gets certain default octal permissions.
00:00
In Linux, files get the default octal permission 666
00:00
and directories get the default octal permission 777.
00:00
That means read, write, read,
00:00
write, read, write for files for users,
00:00
groups and other,
00:00
and 777 is read,
00:00
write x for everybody.
00:00
But when we made a file in the demo in the last lesson,
00:00
that file that we touch had
00:00
the permission 644 by default.
00:00
Why is that?
00:00
Well, it's because of the user mask or
00:00
umask that is set for this system.
00:00
We can see this if we just type umask on
00:00
the command line, it'll display 0022.
00:00
What that means is that the umask removes or
00:00
subtracts bits from the default Linux permissions.
00:00
That means that it's going to give
00:00
a system default of 644,
00:00
which is read, write and then read,
00:00
read for user group and owner on the files,
00:00
and then directories only the user has read,
00:00
write and execute permissions.
00:00
Everybody else has read and execute permissions.
00:00
Those are effectively the
00:00
default permissions that you get when
00:00
you apply the default octal permissions with the umask.
00:00
How does that get configured?
00:00
Well, there's a couple of different things you can
00:00
do if you want to configure on the fly
00:00
because you're creating a bunch of files and you
00:00
want them to have specific settings,
00:00
you can just do it on the command line.
00:00
Say, for example, if you want a user and
00:00
group owner to have full directory access.
00:00
So u and g both have 775,
00:00
and you want to make sure that any users and
00:00
groups in that directory have read,
00:00
write access to the files.
00:00
So six and six and then four,
00:00
you would do this by changing the
00:00
>> umask from 022 to 002.
00:00
>> We can do this by just changing,
00:00
making the change and then making a directory and
00:00
touching the file and making sure it works properly.
00:00
We could type in umask 002.
00:00
And then when we do make directory
00:00
one and touch file one,
00:00
What that's going to do is we're going to
00:00
see now when we do
00:00
an li/l that the directory has read,
00:00
write execute, read, write, execute, and read,
00:00
execute permissions, which is 775.
00:00
Then if we look at a file that we created,
00:00
we'll see that it has read, write,
00:00
read, write, read permissions, which is 664.
00:00
However, these umask changes that we
00:00
make on the fly on the command line,
00:00
they're are only effective for
00:00
the duration of the session.
00:00
That's useful if you want to create
00:00
specific permissions when you're doing
00:00
a lot of files or directory creations.
00:00
But what if you want to permanently
00:00
change the umask, how do you do that?
00:00
Well, this is actually configured to one
00:00
of those global directory,
00:00
global settings that we talked about
00:00
previously, the /etc/ profile.
00:00
What we do is we set this differently in
00:00
/etc/ profile depending upon user types.
00:00
We'll cover user types later in the course here.
00:00
But specifically in /etc/ profile,
00:00
you'll see the line umask 022.
00:00
So if we wanted to change that to permanently be 002,
00:00
we would just change
00:00
this line here and it would permanently
00:00
change the way that the umask is set going forward.
00:00
But with that, we reached the end of this lesson.
00:00
And in this lesson we covered
00:00
the purpose of the umask in Linux,
00:00
we talked about how the umask
00:00
can be configured on the fly,
00:00
and then where the umask should be
00:00
set to permanently change it.
00:00
Thanks so much for being here and I look
00:00
forward to seeing you in the next lesson.
Up Next
Instructed By
Similar Content