So hello, and a big welcome to this first demonstration.
A demonstration where we'll take a look at using the ls
command so we can list our permissions, and these,
of course, are going to include our special permissions.
We're going to go through and see that we can see our
permissions and then take a look at how we can locate these
permissions using the find command.
So come on then.
Let's find that command line.
And here we are.
Look at this, a glorious command line and an AlmaLinux 8 command line.
What we want to be able to show you is that permissions work
irrespective of the Linux distribution that you are using.
So we're going to get a bit hands on here on AlmaLinux,
but you could equally be using your Ubuntu system or your openSUSE system,
if you prefer.
So we're going to go through and create ourselves some directories to play with.
When we go through and look at the mkdir command,
mkdir ‑p, we know it's creating our parent directory.
We can create then the parent directory,
perms, and have subdirectories beginning with dir inside of them.
We want to show four different directories,
so let's have 1 through to 4, the double dot indicating our range.
When we go through and look at the damage that we've done with the tree command,
you can see then very nicely we've got perms,
dir1, dir2, dir3, and dir4.
Give yourself a round of applause.
We're now going to go through and start setting our permissions.
‑V will show us the permissions before and the permissions after.
We always need a before and after photo, don't we?
So we get that with chmod ‑v.
If we go through and set 1777, this is very much like the /tmp directory,
a central shared directory where we want users to be able to write,
but only delete files that they own.
The sticky bit is being set here,
and that's the position 1 that we see with the value of 1.
We can set this on, well, our dir1 would seem like a good idea.
So we can see then that we set 775, and that changed to 177.
But when we look at our permissions, instead of being read,
write, and execute all the way through,
the sticky bit becomes the letter t in the execute block of others.
So it would be the same as me going, o+t if I was using symbolic notation.
Now the lowercase t does indicate that execute is set,
so we can still read the value of our execute permission even
though we don't have a block to display it.
Well enough of dir1.
Let's move now to our group ID bit.
When we use the SETG ID bit, we're going to set this on dir2.
All new files being created in that directory are going to be
group owned by the group owner of the directory.
Again,
it could be something really useful to set on a shared directory
where it's shared towards a particular group.
And we can see that we get the lowercase s showing in the group execute block.
Now you might think, why isn't it s all the way through?
That's really a legacy setting.
T for our sticky bit comes from an older setting that's no longer
used for terminate and stay resident programs.
We don't utilize them anymore, but we keep that t position and element.
As we then go through, we can set for our third directory.
Well, we can set 3, 2 plus 1 with a group ID bit.
And the sticky bit are set.
And of course, we're going to do this on dir3.
Again,
this will be really useful on shared directories where we don't
want users to be able to delete their files,
but we want all new files to be owned by the group owner of the directory,
so something that we're going to see a lot being
configured on shared directories.
Now in our fourth example,
we're going to look at the instance of an uppercase letter.
Lowercase indicates that execute is set.
Where execute is not set, we're going to have an uppercase character.
So if we go through and set no permissions for others,
but configure the sticky bit,
we're going to see that it's being configured with an uppercase T.
Do you see what I mean, the uppercase T?
And it would be the same for any of the other special permissions.
They would show in an uppercase S if we were looking at a
scenario where the execute permission was not set in the
case of the group or the user.
So we can still view the execute permission by looking at
whether it's a lowercase or uppercase character.
If it's uppercase, then the execute permission is not set.
Now it's all well and good setting our permissions,
but we should also be able to locate files and
directories with the special permissions set,
and that's where our find command comes in.
So let's make sure we're a little bit familiar with this.
I'm working in my home directory, and if I want to search the current directory,
I don't need to specify the directory to search.
I can look for the file type of being a directory and then the
permissions being set to a certain range.
Where I use a forward slash, I'm oring the permissions together that I add in.
So I'm looking for the permission where the group ID
bit is set or the sticky bit is set, so g=s or o=t.
Let's give the big Enter key a wallop here,
and we can see then, of course, it's on all of my directories,
1, 2, 3, and 4.
They all have some kind of special permission that is being configured.
Well, okay.
Maybe this didn't show us too much.
Maybe we want to check that it is really working.
Well, okay.
We can do that.
We can go through and search for some other permissions.
If we go back and look at my find command again,
we can reconfigure this to search for something else.
And we can go through, and if we put, now instead of using the forward slash,
if we use a dash, we are anding the permissions together.
So we're now saying that group has the special permission.
Others have the sticky permissions,
and we can see then that is only configured on dir3.
So dir3 had the group ID bit and the sticky bit set.
Now, of course, we're not finished yet.
If we go back and then we look for o=t, we can see that's on 1,
3, and 4, so only 2 that doesn't have the sticky bit.
But if we look for o=tw,
we're looking then for the sticky bit or the write
permission being set for others.
We can see again, we're back to listing all of them.
Well, because others have the write permissions in all of them except dir4,
but the sticky bit.
So we're oring them together.
Again, if we and them together,
we will then show only those where the write
permission and the sticky bit are set,
and we can then go through and see that that's on dir1 and dir3.
Now, as usual,
I'm ever hopeful that you're also trying this on your own lab systems.
It's that that is really going to help you to learn.
But make sure then you can search for the permissions that you've set,
and you're able to get the same results coming back. I look forward to seeing you in the next video.