So behind sudo there is the sudoers configuration file, and I want to talk about
this configuration file a little bit because it can be useful to know about it.
You can use the vi sudo command to open the etc sudoers configuration file.
Notice that visudo will use your editor variable to start your default editor. So depending
on that variable, you may have nano or vim or maybe even another editor.
If you don't want to edit the etc. Sudoers file directly, you
can alternatively add drop in files to the etcsuduos d directory.
Now, what do we find in the etc. Sudoers file? Well, you find a line like wheel all is
all all on Red Hat that is on Ubuntu. It's slightly different, but the idea is the same.
It allows all users who are a member of the group wheel to run all commands from all systems.
And that's the default line.
Now, this line does prompt for a password anytime sudo is used. If you don't like that, and if
you like to make your system very insecure, you can use real all is all no passwd all.
Honestly, I don't think you should ever do that, because that means
that your admin user doesn't need any additional authentication before using sudo.
That's dangerous.
A better solution would be to add the following line to cache the valid sudo credentials for four hours.
As I just mentioned, after entering the password by default, you get an authentication token that's valid for five minutes.
If you don't like that, you can add this line to your sudo's configuration file. So default timestamp type is global.
That part means that no matter how sudo is coming in over remote connections or local connections, and
then the essential parameter is is timestamp. Timeout is whichever value in minutes works for you. I like
240, because that's half a day after lunch. It's okay if you need to enter your password again.
Let's add this before we continue with the next video.
Okay, so I'm using sudo vi sudo.
After all, we do need administrative privileges.
Did you notice, by the way, that on CentOS 10, the title bar of the
terminal window is getting a different color? If you are using elevated privileges, that's an
easy way to figure out if you're in a normal user shell or not.
Using uppercase g brings me to the end of the document where we can
see include dir. That's for the drop in files in this include directory.
Here we can see percent will all is all all that is the
default setting and I am going to use defaults followed by timestamp.
Type is global and TimesTimeToMeout is 240.
Let's make the timestamp. And did you notice how VIM syntax highlighting is
automatically highlighting it correctly now that I have the right value in there?
So I'm going to save these changes and from now on I only have to enter my password every four hours.