Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

README.md

System Service Management, Runlevels and Boot Targets

Costa Rica

GitHub Open Source? Yes!

GitHub brown9804

Last updated: 2025-08-04


This is a summary based on References

Connect to the server:

ssh <user_name>@<IPadress>

Configuring a Default Boot Target:

The LPIC-1 exam expects the candidate to know how to change a default target for a Linux computer using systemd. This exercise will assist you in your practice of determining what the default target is, and changing it to a new one.

Check the Default Target:

The current default target is set to multi-user.target. Use the appropriate command to verify this:
systemctl get-default

Change the Default Target:

The administrator will need to change the default target so that the computer boots into a graphical desktop:
sudo systemctl set-default graphical.target

Check the Default Target again:

Now verify that the system is set for a graphical boot:
systemctl get-default

Scheduling a Systemd Service Job With Timer Units:

During the time that our development team has spent working on the new Web-based API for our organization, there have been several instances of mistaken keystrokes or processes that have necessitated the restoration of the site directory from backup.
We have been asked to run periodic backups of the website directory and, given that the development environment does not have access to the backup network, we have decided to write a custom service that will do so.
Previously we wrote systemd unit files to back up the site and have been provided a file called web-backup.sh in our /root directory. Using that file and the associated web-backup.service, we will create a systemd timer unit file that will control the schedule of our service.
After we have all three components ready, we'll stage the files in their appropriate locations and start the service for our team and turn it back over for their use.

Sign in root:

[user@$host ~]$ sudo su - When prompted, enter the provided lab credentials to finish logging in.

Considerations: Part of this job is already done. In a previous lab (lab0), we wrote the systemd unit file, web-backup.service in the /root directory, which we will use alongside the web-backup.sh file that the Dev team gave us. To use it, we need to make sure we are in /root and that the file is there.

Checking path:

[root@$host ~]# pwd

Checking content:

[root@$host ~]# ls Output:

web-backup.sh   web-backup.service

Create a Timer Unit File:

  1. With our items sourced, we are ready to create the timer unit file. To do so, use the vi command along with web-backup.timer: [root@$host ~]# vi web-backup.timer
  2. Fill out the information as follows:
[Unit]
Description=Fire off the backup

[Timer]
OnCalendar=*-*-* 23:00:00
Persistent=true
Unit=web-backup.service

[Install]
WantedBy=multi-user.target

Note that 23:00:00 can be set to anything. We're just picking 11:00 PM here as an example.
When the file is correct, remember to write and quit properly from vi using the Esc key, : (the colon), then w, then q.

Putting Files Where They Belong:

  1. With everything ready, we now need to make sure our files are in the correct locations. The shell script needs to be copied into /usr/local/sbin with the cp command:
    [root@$host ~]# cp web-backup.sh /usr/local/sbin/
  2. Then, using the cp command again, copy both the service and timer files into /etc/systemd/:
    [root@$host ~]# cp web-backup.{service,timer} /etc/systemd/system/

Tell systemd to Run The Files:

  1. With our files in place, we need to reload the systemd daemon so that it can calculate the service dependencies:
    [root@$host ~]# systemctl daemon-reload
  2. Now enable the services to run at boot:
[root@$host ~]# systemctl enable web-backup.service
    
[root@$host ~]# systemctl enable web-backup.timer
  1. Set the permissions for the file to be executable.
    [root@$host ~]# chmod +x /usr/local/sbin/web-backup.sh
  2. Once the symlinks are created, go ahead and start the services manually:
    [root@$host ~]# systemctl start web-backup.timer web-backup.service
  3. Then check on the statuses of both the timer and the service:
[root@$host ~]# systemctl status web-backup.timer
 
[root@$host ~]# systemctl status web-backup.service

They both show as running, meaning this server is ready to go back to the Dev team.

Working with System Service Log Files Using the Journal Control:

This is to understand how to use the built-in journalctl utility to view and troubleshoot system services.

Check the Web Server Configuration File:

  1. Change to the root account:
    sudo su -
  2. Check the status of the web service:
    systemctl status httpd.service 3.Attempt to start the web service:
    systemctl start httpd.service
  3. After the service fails to start, check the journal:
    journalctl -u httpd.service
  4. Check the directory where the httpd configuration file should be:
    ls /etc/httpd/conf
  5. Restore the original httpd configuration file:
    mv /etc/httpd/conf/httpd.conf.bkup /etc/httpd/conf/httpd.conf
  6. Restart the service:
    systemctl restart httpd.service

Verify That the Web Server Service Is Running:

  1. Check the status of the service:
    systemctl status httpd.service
  2. Navigate to the local web page:
    elinks http://localhost

References

https://learn.acloud.guru/course/cad92c58-0fd2-4657-98f7-79268b4ff2db/dashboard

Total views

Refresh Date: 2025-10-29