search
HomeSystem TutorialLINUX10 Hidden Linux Commands Every Sysadmin Should Know

10 Hidden Linux Commands Every Sysadmin Should Know

As Linux users, we often rely on the commonly used commands ls , grep , awk , sed and find to complete the work. But Linux has a large number of lesser-known commands that can save time, automate tasks and simplify workflows.

This article will explore some underrated but powerful Linux commands that deserve more attention.

  1. rename – efficient batch rename files

The rename command is the savior when you need to rename multiple files at once. Without using a loop containing mv , rename allows you to easily apply complex renaming patterns.

Change all .txt files to .log .

 rename 's/\.txt$/\.log/' *.txt

Convert filename to lowercase.

 rename 'y/AZ/az/' *

Add a prefix to all .jpg files.

 rename 's/^/photo_/' *.jpg

The rename command is much faster than using mv in a loop and avoids potential filename conflicts.

  1. pv – Monitor data transmission progress

Do you want to know how quickly your data is transferred between files or devices? pv (Pipe Viewer) command helps by displaying progress bars, estimating time, and transfer rates.

Monitor file copy progress.

 pv bigfile.iso > /mnt/usb/bigfile.iso

Monitor the progress of compressed backups.

 tar cf - /home | pv | gzip > backup.tar.gz

This is very useful when working with large files, as you can see real-time progress without having to wait blindly.

  1. timeout – Automatically terminate command after setting time

Sometimes the command runs longer than expected and you want it to stop automatically after a specific period of time, you can use the timeout command.

Stop the command after 10 seconds.

 timeout 10s ping google.com

Stop the process after 1 hour.

 timeout 1h rsync -av /source/ /destination/

This is very useful in scripts and prevents commands from hanging indefinitely.

  1. shuf – Randomize input lines or select random entries

Need to mess up the lines in the file or select a random item? shuf is a simple and powerful command for randomizing tasks.

Chaos lines in the file.

 shuf file.txt

Select a line from the file.

 shuf -n 1 file.txt

Generate a random password (12 characters).

 shuf -zer -n12 {A..Z} {a..z} {0..9} | tr -d '\0'

The shuf command is ideal for random sampling, testing and generating random data.

  1. comm – Line to line comparison of two sorted files

When working with lists or logs, comm allows you to compare two sorted files and find common or unique rows.

Compare the two user lists.

 comm file1.txt file2.txt

Show only public rows.

 comm -12 file1.txt file2.txt

comm command can be used for log analysis, user management, and comparison configuration.

  1. tac – reverse the order of lines in a file

You know cat , but have you tried tac ? It displays the contents of the file in reverse order, which is a simple and effective trick.

View log files in reverse order.

 tac /var/log/syslog

Reverse the contents of the file and save it.

 tac file.txt > reversed.txt

This is very convenient for quickly reading the latest log entries without using tail -r .

  1. nl – Add line number to the file

Need to add line number to the file? nl can do this immediately without modifying the original file.

Number each line of the file.

 nl file.txt

Skip empty lines when numbering.

 nl -ba file.txt

This is very useful when dealing with code snippets, debugging, or formatting logs.

  1. yes – Automatic answer tips

Tired of pressing "y" repeatedly to confirm? The yes command automatically enters a response for the prompt.

Automatically confirm the installation of the software package.

 yes | apt install package-name

Test CPU performance by generating infinite output.

 yes > /dev/null

careful! If used improperly, yes may overload your system.

  1. watch – Repeat command

Want to monitor the output of commands in real time? watch runs the command at fixed time intervals and refreshes the output.

Monitor available disk space every 2 seconds.

 watch -n 2 df -h

Track changes in the directory.

 watch -d ls -l

Check the system running time every 5 seconds.

 watch -n 5 uptime

This is useful for real-time monitoring of system statistics, log files, or process status.

  1. expr – Perform mathematical calculations in shell

Need to perform fast arithmetic operations in shell scripts? expr allows you to add, subtract, multiply and divide.

Basic arithmetic operations.

 expr 10 5
expr 10 \* 5 # Multiply with backslash

Find the remainder of division.

 expr 20 % 3

This is very useful for fast calculations in scripts without using Python or calculator.

Summarize

These little-known Linux commands can simplify tasks, increase efficiency and save time. Whether you are managing files, monitoring processes, or automating tasks, mastering these commands will make you a more powerful Linux user.

Which commands do you find most useful? Please let us know in the comments! ?

The above is the detailed content of 10 Hidden Linux Commands Every Sysadmin Should Know. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does the boot process differ between Linux and Windows?How does the boot process differ between Linux and Windows?Apr 29, 2025 am 12:12 AM

The startup process of Linux includes: 1. Start BIOS/UEFI, 2. Load GRUB, 3. Load kernel and initrd, 4. Execute init process, 5. Start system services, 6. Start login manager; the startup process of Windows includes: 1. Start BIOS/UEFI, 2. Load WindowsBootManager, 3. Load winload.exe, 4. Load tonskrnl.exe and HAL, 5. Start system services, 6. Start login screen; Linux provides more customization options, while Windows pays more attention to user experience and stability.

How to Automatically Restart a Failed Service in LinuxHow to Automatically Restart a Failed Service in LinuxApr 28, 2025 am 09:39 AM

This guide details how to configure automatic service restarts in Linux using systemd, enhancing system reliability and minimizing downtime. System administrators often rely on this functionality to ensure critical services, such as web servers (Apa

10 Hidden Linux Commands Every Sysadmin Should Know10 Hidden Linux Commands Every Sysadmin Should KnowApr 28, 2025 am 09:35 AM

As Linux users, we often rely on commonly used commands ls, grep, awk, sed and find to complete the work. But Linux has a large number of lesser-known commands that can save time, automate tasks and simplify workflows. This article will explore some underrated but powerful Linux commands that deserve more attention. rename – efficient batch rename files The rename command is the savior when you need to rename multiple files at once. Without using loops containing mv, rename allows you to easily apply complex renaming patterns. Change all .txt files to .log. rename 's/\.txt$/\.log/' *

How to List All Running Services Under Systemd in LinuxHow to List All Running Services Under Systemd in LinuxApr 28, 2025 am 09:29 AM

Linux systems provide various system services (such as process management, login, syslog, cron, etc.) and network services (such as remote login, email, printer, web hosting, data storage, file transfer, domain name resolution (using DNS), dynamic IP address allocation (using DHCP), and so on). Technically, a service is a process or group of process (usually known as a daemon) that runs continuously in the background, waiting for incoming requests (especially from the client). Linux supports different ways to manage services (start, stop, restart, enable automatic startup at system startup, etc.), usually through a process or service manager. Almost all modern Linux distributions now use the same

CrossOver 25: Run Windows Software and Games on LinuxCrossOver 25: Run Windows Software and Games on LinuxApr 28, 2025 am 09:27 AM

Run Windows Software and Games on Linux with CrossOver 25 Running Windows applications and games on Linux is now easier than ever, thanks to CrossOver 25 from CodeWeavers. This commercial software solution lets Linux users run a wide variety of Wind

pCloud - The Most Secure Cloud Storage [50% Off Offer]pCloud - The Most Secure Cloud Storage [50% Off Offer]Apr 28, 2025 am 09:26 AM

Secure Your Data with pCloud: A Comprehensive Guide to Linux Installation pCloud, a leading secure cloud storage service, provides a robust platform for managing your files and data. This guide details the installation process on Linux systems. About

MangoHud - Monitor FPS, CPU & GPU Usage in Linux GamesMangoHud - Monitor FPS, CPU & GPU Usage in Linux GamesApr 28, 2025 am 09:25 AM

MangoHud: A powerful tool for real-time monitoring of Linux gaming performance MangoHud is a powerful and lightweight tool designed for gamers, developers, and anyone who wants to monitor system performance in real time. It acts as an overlay for Vulkan and OpenGL applications, displaying important information such as FPS, CPU and GPU usage, temperature, etc. This article will explore the functions, working principles and usage of MangoHud, and provide step-by-step instructions for installing and configuring MangoHud on Linux systems. What is MangoHud? MangoHud is an open source project available on GitHub and aims to provide a simple and customizable way to monitor

5 Must-Know Linux Command Line Archive Tools – Part 15 Must-Know Linux Command Line Archive Tools – Part 1Apr 28, 2025 am 09:23 AM

Managing archived files is a common task in Linux. This article, the first of a two-part series, explores five powerful command-line archive tools, detailing their features and usage with examples. 1. The tar Command: A Versatile Archiving Utility t

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor