Lab 9: System time and Package managers

Exercise 1: System time

Task 1: Time zone

Task 2: NTP

We are going to set up an NTP server and then configure a client to use this NTP server. You need two VMs to test this. You can work in pairs to set up the client-sever infrastructure.

Installing and configuring an NTP server

Configuring the client

We show two approaches for configuring the client. You can use either the systemd service systemd-timesyncd that comes with systemd-based systems by default, or use chronyd.

1. Using systemd-timesyncd
2. Using chrony

Test the setup

Exercise 2: Package managers

A package manager automates the process of installing, configuring, upgrading, and removing packages.
There are several package managers depending on the OS. This lab focuses on Ubuntu package managers.
Note that Ubuntu is based on the Debian distro and it uses the same APT packaging system as Debian and shares a huge number of packages and libraries from Debian repositories.

Task 3: dpkg

dpkg is a tool that allows the installation and analysis of .deb packages. It can also be used to package software.

Task 4: APT

The Advanced Packaging Tools (APT) is a package manager on Ubuntu systems. apt acts as a user friendly tool that interacts with dpkg. Unlike dpkg, apt allows download and installation of packages from online repositories.

You can install or remove multiple packages in one command by separating them by spaces. e.g apt install package1 package2 package3.
To remove multiple packages is similar e.g apt remove package1 package2 package3.

Task 5: sources.list

Adding repositories

Task 6: Creating a custom Ubuntu package

You can have a compiled application in place of the script we have used.

Questions to answer

Instruction: Show all steps taken including screenshots of commands executed, files created, and configuration added.

  1. What alternative do you have for configuring your NTP server pool if you don’t want to be dependent on NTP servers on the internet. The time must be accurate and appear to be in sync with other devices globally. Describe how you will perform this setup.

    The accuracy of the time should be strongly considered.

  2. You have two Linux servers whose time won’t stay in sync for various reasons. They tend to drift so much that they have a 30 second difference after 7 days of operation. What can you do to ensure that they stay in sync with each other without relying on external devices or servers?

    Hint: Inaccurate time is not a problem in this case. The goal is to ensure that both servers are in sync.

  3. What are the differences between apt and apt-get?
  4. Why should System Administrators prefer apt upgrade over apt full-upgrade?
  5. Show how you will install Atom text editor from the apt repository. Provide explanation for every step you take.
    • After adding the repository, show the output when you run $ apt search atom

    You are not allowed to manually download the debian package and install it.

  6. Create an Ubuntu package that meets the following requirements:
    • The package creates the directory /var/helloworld/ on the target system.
    • The package contains the python script /var/helloworld/helloworld.py. The python script is simple:
      #!/usr/bin/env python3
      print("Hello, World!")
      
    • The package should deploy a bash script helloworld that executes /var/helloworld/hello.py on the target system.

Take the following steps after building the package

After a user installs your package, he should be able to run $ helloworld from the terminal without additinonal steps.
The expected flow of execution is helloworld (bash script) -> helloworld.py -> Output (Hello, World!)

Bonus

The bonus tasks encourage you to failiarize yourself with CentOS and RPM packages. Linux distributions such as Red Hat and CentOS are very common and they utilize RPM packages.

  1. Find and add new source repository to be used for yum.
    • Install a package from it (for example MongoDB).
    • Check with the RPM package manager to verify that the package was installed, and provide details such as dependencies needed.
    • Find logs related to all actions from the previous steps.
  2. Sometimes you might have access to an open-source application source code but might not have the RPM file to install it on your system. In that situation, you can either compile the source code and install the application from source code or build an RPM file from source code by yourself and use the RPM file to install the application. There might also be a situation where you want to build a custom RPM package for the application that you developed.
    Create an RPM package to deploy any application of your choice.