In this chapter, we’ll explore productivity tools that can make your Linux experience more enjoyable and efficient. From ASCII art generators to time management tools, these utilities add a touch of creativity and help you stay productive. By the end of this chapter, you’ll have a toolkit of fun and useful programs to enhance your command-line workflow.
While Linux is often associated with serious system administration and development tasks, it’s also a platform for creativity and productivity. These tools can
- Add a touch of humor and personality to your terminal.
- Help you stay organized and focused.
- Make repetitive tasks more enjoyable.
figlet: ASCII Art Textfiglet creates large ASCII art text banners.
Installation:$ sudo apt install figlet # Debian/Ubuntu$ sudo dnf install figlet # Red Hat/Fedora
Custom Fonts: Use the -f option to specify a font. $ figlet -f slant "Linux"
lolcat: Rainbow-Colored Outputlolcat adds rainbow colors to text output.
Installation:$ sudo apt install lolcat # Debian/Ubuntu $ sudo dnf install lolcat # Red Hat/Fedora
Basic Usage: Pipe any command’s output to lolcat. $ figlet "Linux" | lolcat
pomodoro-cli: Time Managementpomodoro-cli is a command-line tool for the Pomodoro Technique, a time management method that uses timed work intervals.
Installation:$ sudo apt install pomodoro-cli # Debian/Ubuntu $ sudo dnf install pomodoro-cli # Red Hat/Fedora
Basic Usage: Start a 25-minute work session: $ pomodoro start
Take a 5-minute break:$ pomodoro break
taskwarrior: Task Managementtaskwarrior is a command-line task manager that helps you track and prioritize tasks.
Installation:$ sudo apt install taskwarrior # Debian/Ubuntu
$ dnf install taskwarrior # Red Hat/Fedora
Basic Usage: Add a task:$ task add "Write Chapter 25"
List tasks:$ task list
Mark a task as done:$ task 1 done
cal: CalendarThe cal command displays a simple calendar.
$ al$ cal 10 2025You can combine these tools to make your workflow more enjoyable. For example: - Add a motivational message to your daily task list:$ cowsay "Stay focused!" | lolcat task list
- Create a colorful banner for your project:$ figlet "Project X" | lolcat
Log files are essential for monitoring system and application activity. They help you troubleshoot issues, track performance, and ensure everything is running smoothly.
/var/log/: The directory where most system logs are stored.journalctl: A tool for querying and displaying logs from systemd.tail -f: Monitors log files in real-time.$ tail -n 10 /var/log/syslog$ tail -f /var/log/syslog$ journalctl -p errfortune $ sudo apt install fortune # Debian/Ubuntu $ sudo dnf install fortune # Red Hat/Fedora$ fortunelast$ lastuptime$ uptimewho$ whoneofetch$ sudo apt install neofetch # Debian/Ubuntu $ sudo dnf install neofetch # Red Hat/Fedora$ neofetch
Let’s put your new skills to the test:
1. Install cowsayand create a custom message with a dragon.
2. Use figlet and lolcat to create a colorful banner for your project.
3. Set up a Pomodoro session using pomodoro-cli.
4. Add a task to taskwarrior and mark it as done.
5. Automate a Task: Schedule a cron job to run a script every hour.
6. Monitor Logs: Use tail -f to monitor a log file in real-time.
7. Display System Information: Run neofetch to display your system’s details.
8. Check Login History: Use last to view recent logins.
croncron is a time-based job scheduler in Linux that allows you to automate repetitive tasks. Whether you need to run a script daily, back up files weekly, or send notifications hourly, cron is the tool for the job. In this section, we’ll explore how to use cron to schedule tasks, edit crontab files, and troubleshoot common issues.
cron is a daemon (background process) that runs scheduled tasks at specified intervals. These tasks are defined in a crontab (cron table) file, which contains a list of commands and their schedules.
crontab SyntaxEach line in a crontab file represents a job and follows this syntax:
* * * * * command-to-executeThe five fields represent: 1. Minute (0–59): The minute when the command will run. 2. Hour (0–23): The hour when the command will run. 3. Day of the Month (1–31): The day of the month when the command will run. 4. Month (1–12): The month when the command will run. 5. Day of the Week (0–7): The day of the week when the command will run (0 and 7 both represent Sunday).
*: Matches all values (e.g., * * * * * runs the command every minute).,: Specifies multiple values (e.g., 1,15 * * * *runs the command at the 1st and 15th minute of every hour).-: Specifies a range (e.g., 1-5 * * * * runs the command every minute from 1 to 5)./: Specifies intervals (e.g., */5 * * * * runs the command every 5 minutes).crontab FileTo create or edit your crontab file, use the following command:
$ crontab -eThis opens the crontab file in your default text editor. Each user has their own crontab file, so changes you make will only affect your scheduled tasks.
cron Job Examples0 0 * * * /path/to/script.sh0 * * * * /path/to/command*/5 * * * * /path/to/command0 8 * * 1 /path/to/command30 6 1 * * /path/to/commandcron Jobscron JobsTo view your current cron jobs, use:
$ crontab -lcron JobsTo delete all your cron jobs, use:
$ crontab -rcrontab (Requires Root Privileges)To edit another user’s crontab, use:
$ sudo crontab -u username -ecron Jobscron Logscron logs can help you debug issues with your jobs. On most systems, logs are stored in /var/log/syslog or /var/log/cron. Use grep to filter cron-related logs:
$ grep CRON /var/log/syslogBy default, cron sends job output to the user’s email. To save output to a log file, redirect it:
* * * * * /path/to/command >> /path/to/logfile.log 2>&1>> /path/to/logfile.log: Appends standard output to a log file.2>&1: Redirects error output to the same log file.cron jobs run with a limited environment, so always use full paths for commands and files:
* * * * * /usr/bin/python3 /home/user/script.pycron FeaturesYou can set environment variables at the top of your crontab file:
SHELL=/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
0 * * * * /path/to/commandcron supports special strings for common schedules: - @reboot: Run once at startup. - @daily or @midnight: Run once a day at midnight. - @hourly: Run once an hour. - @weekly: Run once a week. - @monthly: Run once a month. - @yearly or @annually: Run once a year.
Example:
@daily /path/to/backup.shcron is a powerful tool for automating tasks on Linux. By mastering crontab syntax and understanding how to manage and troubleshoot cron jobs, you can save time and ensure that important tasks run on schedule.
'at' command
The at command in Linux is used to schedule commands or scripts to run once at a specified time in the future. Unlike cron, which is used for recurring tasks, at is for one-time execution. The at command is a useful tool for scheduling one-time tasks, such as backups, updates, or running scripts at off-peak hours.
Here’s a breakdown of how it works:
Basic Syntax:
$ at [options] [time]After entering this command, you’ll be prompted to enter the command(s) you want to execute. Press Ctrl+D to signify the end of your input.
Specifying Time:
You can specify the time in various formats:
HH:MM (for today), YYYY-MM-DD HH:MM (for a specific date and time)now + 5 minutes, midnight, noon, teatime (4pm)tomorrow, next week, next monthExample:
To run my_script.sh five minutes from now:
$ at now + 5 minutes
warning: commands will be executed using /bin/sh
$ at> my_script.sh
$ at> <Ctrl+D>You’ll get a job number in response, which you can use to manage the scheduled task.
Options:
-l or -list: List pending at jobs.-d or -delete: Delete a specific job (using its job number).-m: Send an email notification after the job completes (even if there’s no output).-f <file>: Read commands from a file instead of standard input.Important Notes:
at daemon: The at command relies on the atd daemon to function. Make sure this daemon is running on your system.at is often restricted by /etc/at.allow and /etc/at.deny. If at.allowexists, only users listed in it can use at. If at.allow doesn’t exist and at.deny exists, all users except those listed in at.deny can use at. If neither file exists, typically only root can use at./bin/sh, even if your default shell is something else. Keep this in mind when writing scripts for at.
Let’s put your new skills to the test:
1. Schedule a Daily Backup: - Create a cron job to run a backup script every day at 2:00 AM.
2. Monitor Logs: - Schedule a job to check system logs every 10 minutes and save the output to a file.
3. Use a Special String: - Use @rebootto run a script every time your system starts up.
4. Troubleshoot a Job: - Create a cron job that fails intentionally, then use logs to debug the issue.
That’s it for Chapter 20! You’ve now learned how to use fun and productivity tools to make your Linux experience more enjoyable and efficient. In the next chapter, we’ll dive into file transfer tools—how to move files between systems using scp, rsync, and more. Until then, have fun experimenting with these tools!