What are Cron Jobs and systemd Services?
Good to know
Checking for Suspicious Cron Jobs
- Check your personal cron jobs: Open a Terminal (usually by pressing Ctrl+Alt+T) and type
crontab -l. This shows scheduled tasks for your user account. Look for anything you don't recognise. An empty output is often a good sign for a home user. - Check root cron jobs: These are system-wide jobs that run with special permissions. In the Terminal, type
sudo crontab -l -u root. You may be asked for your password. Again, look for anything suspicious. - Examine system-wide cron directories: System-wide cron jobs are often stored in specific folders. Use the command
ls -l /etc/cron.*to list the contents of these directories. Pay attention to any unusual file names or scripts you don't recall installing.
Investigating systemd Services and Timers
- List all running systemd services: In the Terminal, type
systemctl list-units --type=service --all. This will show a long list. Focus on services that haveenabledstatus and look for services with strange names or descriptions. - Check for systemd timers: These are like scheduled tasks. Type
systemctl list-timers --all. Again, look for anything you don't recognise that isactiveand potentially enabled. - Examine user-specific systemd units: Malware might hide in user-specific systemd directories. Type
ls -l ~/.config/systemd/user/to see if there are any suspicious user-defined services or timers.
Important
What to do if you find something suspicious
- Research it: Copy the name of the suspicious job or service and search for it online. Often, legitimate system components have clear documentation.
- Disable cron jobs: To remove a suspicious user cron job, type
crontab -e, delete the line, save, and exit. For system-wide cron jobs, you would typically delete the specific file from the relevant/etc/cron.*directory (e.g.,sudo rm /etc/cron.daily/malware-script). - Disable systemd units: To temporarily stop a unit, use
sudo systemctl stop suspicious.service. To prevent it from starting on boot, usesudo systemctl disable suspicious.service. To remove it entirely, you would typically delete the service file (e.g.,sudo rm /etc/systemd/system/malware.service).
Tip
chkrootkit or rkhunter.Was this guide helpful?
Know someone who needs this? Send them the guide.
Written by
Jordan DicksonFounder, CyberSecurityGuides
Founder of CyberSecurityGuides, writing practical, jargon-free guides that help everyday people recover from and protect against online attacks.
Reviewed by CSG Security Engineers