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

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.

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

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/' *

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

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]](https://img.php.cn/upload/article/001/242/473/174580357418126.jpg?x-oss-process=image/resize,p_40)
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: 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

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


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

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
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor
