CIT054 Index > Assignment - Startup Scripts

Assignment - Startup Scripts

There are three different kinds of startup scripts in the Linux world:

System V init scripts
This is the “original” startup script format from UNIX, and carried over to Linux until a few years ago.
Upstart scripts
Ubuntu created this new version for the startup system.
systemd scripts
This is the format used in Fedora, RedHat, and CentOS.
In general, a startup script has to describe:

Since the system you are using is Fedora, you will be writing a systemd service script.

Read the man page for systemd. This will give you an overview of what systemd is capable of, and where it finds its files (see the “Directories” section). On our machine, you will see a large number of systemd service files in directory /usr/local/lib/systemd/system.

Then, read the man page for systemd.unit. This tells you the directives that are common to all systemd files. The man page for systemd.service gives you more information about the directives used for specifying services, and the man page for gives you information about specifying a target, which is a way to group units.

A few good service files to look at are vsftpd.service, which starts an ftp server daemon, mysqld.service, which starts MySQL, and sshd.service, which starts the SSH daemon.

For examples of target files, see, used when shutting down the system,, which takes the system to single-user mode, and

You use the systemctl command to start, stop, enable, or disable a service. Here is its man page. When you enable or disable a service, a symbolic link to the service file is either created or deleted in the appropriate .wants folder within /etc/systemd/system; if you look on the server you will see that httpd.service and mysqld.service are listed in the directory.

The assignment

First, write a bash script that echoes a line to a file that has your name in it. For example, a person named John Smith, would write a script like this:

echo "$(date) systemd script for John Smith" >> /tmp/smith_j

Save the script in a file whose name has the form, and put it in a directory somewhere; remember where it is.

Now write a lastname_firstInitial.service unit file that will invoke this script. It will be of Type=simple (the default). Make sure you have an appropriate Description= in your file. Your service must start after the,, and httpd.service units. It will be wanted by and

Testing Your Changes Locally

Do not upload this script to the CIT054 server and install the service! Instead, test it on your local Fedora system.

Type systemctl commands to do the following:

If you go to the /tmp/lastname_firstInitial you should see the record of the invocations of your shell script. (You may want to do this at each step.)

Finishing the Assignment

Upload your script to the server into your home directory. When you finish, email me to let me know you’ve finished.