Maintaining Linux Systems

Hands-On Lab

 

Photo of Rob Marti

Rob Marti

Linux Training Architect I in Content

Length

00:30:00

Difficulty

Intermediate

In this lab, we are going to practice scheduling updates, modifying NTP settings, and changing what kernel the server will reboot into. Understanding how to do these tasks will prepare you for various administrative duties in the future.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Maintaining Linux Systems

Introduction

In this lab, we are going to practice scheduling updates, modifying NTP settings, and changing what kernel the server will reboot into. Understanding how to do these tasks will prepare you for various administrative duties in the future.

The Scenario

We have to set up a server, and adhere to our company's policy when we do. First, it needs to be completely updated before we move it to production. Second, we need to modify the NTP pools according to our standards. Finally, the kernel we set as default needs to be kernel at index 1.

Get logged in

Use the credentials and server IP in the hands-on lab overview page to log into our lab server. Since we'll need to be root for the all of the commands, we'll run a quick sudo -i as soon as we're in. Once that's done, we can get moving.

Schedule a Job Using the at Utility

To schedule commands using the at command, we can run this:

[root@host]# at 12:00am

We'll then land in an at> prompt, where we can type the command we want to be run at midnight:

at> yum update -y

To get out of the at prompt, and back to our command line, press Ctrl+D. We'll see a message like this: at> <EOT> and then land back at our shell.

To verify whether the job is set to run or not, we can run atq and see any scheduled at jobs.

If, when we first run at, we get an error similar to this:

Can't open /var/run/atd.pid to signal atd. No atd running?

That means that the atd service isn't running. We can resolve that by running:

[root@host]# systemctl start atd

Once that's done, we could carry on and actually schedule the job.

Modify the NTP Pools to Keep Clocks Synchronized

NTP configuration is set in /etc/chrony.conf. We can edit that file (using whichever editor we like) and change the server section to look like this:

server 0.pool.ntp.org iburst
server 1.pool.ntp.org
server 2.pool.ntp.org
server 3.pool.ntp.org

To make sure our configuration gets implemented, we need to restart the service. And once it's restarted, we'll verify:

[root@host]# systemctl restart chronyd
[root@host]# chronyc sources -v

> Note: In the lab environment, none of the time sources will actually sync, so we're going to see ^? characters here in the last few lines of output. In the real world, we'd get ^*.

Modify the GRUB Boot Order So That the Kernel at Index 1 Boots

Let's see what GRUB is booting to currently:

[root@host]# grubby --default-index

This should return a 0. If you want to know what that kernel actually is (and any others installed on the system) list them out with:

[root@host]# grubby --info=ALL

There's a line in for each kernel that reads index=X where X is a number. Now let's set the new default kernel to 1 with this:

[root@host]# grubby --set-default-index=1

Now if we look at the default again (with grubby --default-index) we should see a 1.

Conclusion

We had three jobs, and we got them done. We scheduled an update to run automatically, pointed our machine at the required time servers, and we set the default boot kernel. Congratulations!