Costa Rica
Last updated: 2025-08-04
This is a summary based on References
ssh <user_name>@<IPadress>
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.
The current default target is set to multi-user.target. Use the appropriate command to verify this:
systemctl get-default
The administrator will need to change the default target so that the computer boots into a graphical desktop:
sudo systemctl set-default graphical.target
Now verify that the system is set for a graphical boot:
systemctl get-default
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.
[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.
[root@$host ~]# pwd
[root@$host ~]# ls
Output:
web-backup.sh web-backup.service
- 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 - 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.
- 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/ - 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/
- 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 - Now enable the services to run at boot:
[root@$host ~]# systemctl enable web-backup.service
[root@$host ~]# systemctl enable web-backup.timer
- Set the permissions for the file to be executable.
[root@$host ~]# chmod +x /usr/local/sbin/web-backup.sh - Once the symlinks are created, go ahead and start the services manually:
[root@$host ~]# systemctl start web-backup.timer web-backup.service - 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.
This is to understand how to use the built-in journalctl utility to view and troubleshoot system services.
- Change to the root account:
sudo su - - Check the status of the web service:
systemctl status httpd.service3.Attempt to start the web service:
systemctl start httpd.service - After the service fails to start, check the journal:
journalctl -u httpd.service - Check the directory where the httpd configuration file should be:
ls /etc/httpd/conf - Restore the original httpd configuration file:
mv /etc/httpd/conf/httpd.conf.bkup /etc/httpd/conf/httpd.conf - Restart the service:
systemctl restart httpd.service
- Check the status of the service:
systemctl status httpd.service - Navigate to the local web page:
elinks http://localhost
https://learn.acloud.guru/course/cad92c58-0fd2-4657-98f7-79268b4ff2db/dashboard