• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Solutions

Solutions: Repeat Command in Ubuntu Terminal

neo by neo
May 27, 2025
in Solutions
0
Solutions: Repeat Command in Ubuntu Terminal

Solutions: Repeat Command in Ubuntu Terminal

0
SHARES
9
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Repeat Command in Terminal

Solutions: Repeat Command in Ubuntu Terminal can significantly boost your productivity. Repetitive tasks can often feel boring, even for seasoned Linux users. Whether you’re re-running a failed command, monitoring real-time outputs, or testing scripts, the ability to efficiently repeat commands in the Ubuntu terminal can significantly boost your productivity.

In this guide, we’ll explore practical methods to repeat commands in the terminal effortlessly. From leveraging Bash shortcuts and history features to using advanced command-line tools, you’ll discover solutions tailored to various scenarios. Whether you’re a beginner or a pro, these tips will help you save time and streamline your workflow.

Let’s dive into the world of terminal magic!

About the watch Command

watch runs command repeatedly, displaying its output and errors (the first screenfull). This allows you to watch the program output change over time. By default, command is run every 2 seconds and watch will run until interrupted.

ADVERTISEMENT

For more details about watch command, you can check the link.

Example of watch Command

Whether you’re monitoring system resources, tracking log file changes, or observing temperature readings from hardware sensors, watch provides a dynamic way to automate and visualize recurring command executions.

Monitor temperature every 2 seconds on Pi4 device:

The command continuously monitors the temp1 sensor’s value and displays only the second field (likely the temperature). The watch command refreshes this information at regular intervals, making it easy to track changes in real-time.

watch 'sensors | grep "temp1" | awk "{print \$2}"'
  • watch: Repeats the provided command at regular intervals (default is every 2 seconds). Useful for monitoring output over time.
  • sensors: Displays hardware sensor readings such as CPU temperature, fan speed, and voltage. Requires the lm-sensors package to be installed.
  • | (Pipe): Passes the output of sensors to the next command in the pipeline.
  • grep "temp1": Searches for lines in the sensors output that contain the text “temp1”. This is commonly associated with a specific temperature sensor.
  • awk "{print \$2}": Processes the filtered output from grep. It selects and prints the second field (usually the temperature value), assuming fields are separated by whitespace or similar delimiters.

Check the IP Address every 60 Seconds:

 watch -n 60 ip addr
  • -n 60: Sets the interval to 60 seconds.
  • ip addr: The command to execute.

Tracking Disk Usage with df

If you want to observe the disk usage of your system’s partitions at regular intervals, you can use:

ADVERTISEMENT
ADVERTISEMENT
watch -n 10 df -h
  • -n 10: Runs the df -h command every 10 seconds.
  • df -h: Displays disk usage in a human-readable format.

If you are interested in how to run a command in the background, see this link.

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Solutions: Find and Delete Log Data or Any Files Older Than 30 Days on Linux

Next Post

Linux Networking: netplan DHCP Configuration on Ubuntu

neo

neo

Related Posts

My Ultimate Docker Command Cheat Sheet (2025 Edition)
Docker

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script
Docker

Protect Docker-Hosted Application from HTTP Flood (DDoS) Attacks Using a Bash Script

Raspberry Pi Monitoring with Monit: Docker, Temperature, Network & More
Solutions

Raspberry Pi Monitoring with Monit: Docker, Temperature & More

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)
Docker

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Next Post
Linux Networking: netplan DHCP Configuration on Ubuntu

Linux Networking: netplan DHCP Configuration on Ubuntu

Recommended

Linux Files Operation: mv, rm, cp (Rename, Remove and Copy Files and Directories)

Linux Files Operation: mv, rm, cp (Rename, Remove and Copy Files and Directories)

Nextcloud: Security Concept with FortiGate Firewall

Nextcloud: Security Concept with FortiGate Firewall

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Docker Command Cheat Sheet (2025 Edition)

My Ultimate Docker Commands Cheat Sheet (2025 Edition)

Categories

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos
ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Recent News

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Way to Organize a Git Repository for Bash, Mikrotik, FortiGate and other Scripts

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.