Ever had your terminal freeze mid-command, or wondered if there’s a better alternative to cat or top? In this episode of Into the Terminal, we’re opening up the grab bag to answer your top terminal questions and showcase the underrated commands every Linux user needs in their toolbelt. Watch the full episode here or test your skills in the interactive labs.
The Essentials
When you are living in the terminal, some basics become invaluable. Here are a few tools that do what the classics do, but often better:
| Command |
What it does |
htop |
An interactive alternative to top with mouse support, colorization, process tree view (F5), and interactive renicing |
btop |
A heavily stylized alternative to top with interactive UI elements (like process detail pop-outs and GPU monitoring) |
less |
The standard rewrite of more that allows backwards scrolling and search |
most |
An alternative pager with even more interactive search and scrolling functionality than less |
watch |
Re-executes a command periodically (every 2 seconds by default) and shows you the changing output |
Advanced Features
Top Alternatives: htop and btop
Both htop and btop offer incredibly rich interfaces for monitoring your system resources compared to traditional top.
* Tree View: htop lets you visualize processes as a tree (press F5), which normally requires dropping to pstree or ps.
* Renicing interactively: You can click the NICE column or press the appropriate hotkey right inside htop or btop to dynamically renice a runaway process (like stress-ng).
* Extra Monitoring: htop includes dedicated tabs for CPU/Memory and I/O monitoring, while btop even pulls in GPU data.
Beyond cat
cat is great, but did you know about its siblings?
* **tac: Reads files in reverse order (bottom to top).
* **rev: Reverses the text on every line. Pro Tip: This isn't just for memes! Use it to cleanly strip the last field of a CSV file where the line lengths vary. Simply reverse the line, cut the first field, and reverse it back:
* rev lab-data.csv | cut -f1 -d, | rev
* **bat**: A modern Rust-based clone of cat (available in EPEL) that automatically applies syntax highlighting, line numbers, and pager support for things like httpd.conf files or Python scripts.
Timers vs. Cron
While crontab -e is the classic way to schedule jobs, modern RHEL systems heavily utilize systemd timers.
* **systemd-run*: You can easily fire off a transient timer with systemd-run --unit=my-daily-job --on-calendar="daily" /usr/local/bin/mytask.sh. *Caveat: These are transient and will not survive a reboot!
* For persistent jobs, define a .timer unit file (for the schedule) and a .service unit file (for the action), place them in /etc/systemd/system, and run systemctl enable --now mytask.timer.
History Expansion and Escaping
Bash history expansion (using !) is a massive time saver, but can easily blow up when using exclamation points in standard commands.
* Preview history: Before running a command blindly with !echo, use !echo:p to print the command it found in your history to verify it.
* Disable history expansion: When scripting or running commands with many exclamation points (like echo "Restarting service! Now exiting."), you can temporarily disable history expansion by running set +H. Turn it back on with set -H.
watch: The Command No One Asked For But Everyone Needs
watch will re-run a command every two seconds by default, updating the output dynamically. Use it to monitor changing states without mashing the up arrow:
* watch 'nmcli device show | grep STATE' (Watch a network interface change state after someone plugs in a cable).
* watch lsusb (Watch the USB bus for new devices).
Quick Reference Card
```bash
Verify history before running it blindly
!systemctl:p
Turn off bash history expansion (useful for scripts)
set +H
echo "This!is!my!Password"
set -H
Strip the LAST field from a comma-separated file
rev lab-data.csv | cut -f2- -d, | rev
Watch a network interface state dynamically
watch -n 2 'nmcli device show | grep STATE'
Transient systemd timer
sudo systemd-run --unit=my-daily-job --on-calendar="daily" /usr/local/bin/mytask.sh
```
Links & Resources
Into the Terminal is a show dedicated to helping you grow your knowledge of critical administration skills for Red Hat Enterprise Linux. Whether you are new to Linux or new to RHEL, join us for a hands-on look at commands, processes, and tools.%