• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • 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
  • 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
6
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.

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

ADVERTISEMENT

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
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.

ADVERTISEMENT

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

Next Post
Linux Networking: netplan DHCP Configuration on Ubuntu

Linux Networking: netplan DHCP Configuration on Ubuntu

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

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

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

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

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

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

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

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

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

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

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

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

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

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

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

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

Browse by Category

  • 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

Recent News

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

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

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

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

  • 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
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.