Skip to content
PURPLEDUEL

What runs at night?

Linux Fundamentals · medium level · 5 objectives · 600 XP in total

Every night, always at the same time, the server becomes very slow for about ten minutes: something is scheduled. Learn to read the crontab, choose among jobs that all look alike and look at the report of the right one.

Lab 12 of 13 in the Linux Fundamentals path. If you get stuck you have 3 hints, from the vaguest to the most precise: they cost 0, 40 and 120 XP.

What you learn

Objectives complete themselves while you work in the terminal; each one is worth experience points:

  • Read the system crontab (60 XP)
  • Check the jobs in the cron.d files too (80 XP)
  • Set the comments aside with grep -v (120 XP)
  • Read the script of the suspicious job (140 XP)

Topics: linux, cron, pianificazione.

Commands you will use

The terminal is simulated and understands about forty Linux commands. In this lab you will mostly need these:

  • cat: prints the contents of a file: the most direct way to read configurations, notes and logs.
  • grep: finds the lines that contain a word, even across whole folders with -r. It is the main tool for analysing text and logs.
  • ls: lists the files in a folder; with -l it shows permissions and owners, with -a hidden files too. It is the first command on any machine.

The simulated environment

You work in a simulated Linux shell, in the home folder of the user runner: invented files and folders, no network target.

Besides the home folder there is a complete simulated system, with configuration files, logs, users and permissions to examine.

The defensive lesson

Once the lab is solved, the write-up explains what went wrong and how to protect yourself:

The crontab says what starts when: five time fields (minute, hour, day of month, month, day of week), the user and the command; the asterisk means "every". Reading the time carefully avoids the classic mistakes (15 3 is not 3 15) and grep -v '^#' removes the comments so you see only the active jobs. Defense: scheduled jobs are a classic place to hide persistence or to make root run scripts that others can edit: list the system crontabs and those of all users regularly (/etc/crontab, /etc/cron.d, crontab -l), keep the scripts owned by root and not writable by others, give each job the least privileged user possible, record the outcome of every run and read a script before launching it.

Before and after this lab

To unlock it you must have solved:

After this lab you can move on to:

The Linux Fundamentals path

Linux Fundamentals is the starting point. Almost every server, network device and security tool runs on Linux, and anyone who defends a system (or tests it with permission) spends much of their time in a terminal. Here you learn to move around the filesystem, find hidden files, read huge logs piece by piece, search for words with grep, chain commands with pipes and understand permissions, environment variables and history: the basics you will use in every other path.

All labs in the Linux Fundamentals path

Learn more with the guides

All guides