Continuing our exploration of lesser-known Linux commands, let’s dive into some more hidden gems that can help you manage your Linux system more effectively right from the command line.
If you missed them, check out the earlier parts:
- 11 Lesser-Known Useful Linux Commands – Part I
- 10 Lesser-Known Linux Commands – Part 2
- 10 Lesser-Known Effective Linux Commands – Part IV
- 10 Lesser-Known Useful Linux Commands- Part V
This article brings a few more lesser-known Linux commands that can come in handy. Perhaps some of them are already on your radar if you’re an experienced Linux user who loves exploring new possibilities.
22. ^foo^bar Command – Quick Text Substitution
Ever typed a command and realized you made a small mistake? Instead of retyping the whole command, you can use the ^foo^bar
syntax to fix it on the fly.
This command will substitute the first occurrence of foo
in the previous command with bar
, which is a quick, easy, and real time-saver when you just need to make a small edit.
echo Hello foo Hello foo ^foo^bar Hello bar

23. > file.txt Command – Overwrite a File
If you need to quickly empty a file, you can use > file.txt
, which overwrites the file and clears its contents without needing to open it. It’s a handy shortcut when you just want to reset a file’s content.
> file.txt
24. at Command – Schedule One-Time Tasks
The at command lets you schedule tasks to run at a specific time. Unlike cron jobs, at
is for one-off tasks. Just type the command, set a time, and you’re all set.
For example, to run a command at 3:00 PM:
at 3pm > echo "Time to backup files" >> backup.log
25. du -h –max-depth=1 Command – Check Disk Usage
The du (disk usage) command with the -h
(human-readable) and --max-depth=1
options is perfect for checking how much space each folder takes up.
It gives you a quick overview of disk usage without overwhelming you with too much detail.
du -h --max-depth=1

26. expr Command – Evaluate Expressions
The expr
command is a simple yet powerful tool for performing arithmetic operations or evaluating expressions, which can be used for addition, subtraction, multiplication, and even string manipulation.
For example, to add two numbers:
expr 5 + 3 8
27. look Command – Search for Words in a File
Want to search for words that start with a certain prefix? The look
command lets you search for words in a dictionary or file that begin with a specified string, which is great for quickly finding relevant terms.
For example:
look hel hello help helper
28. yes Command – Repeatedly Output a String
The yes
command will output a string repeatedly, which is useful for automatically answering prompts or for testing purposes. You can specify the string you want it to repeat.
For example, to automatically answer “y"
to a prompt:
yes y y y y
29. factor Command – Find the Prime Factors of a Number
The factor
command is a great way to quickly find the prime factors of a given number. If you need to break down a number into its prime components, factor will do it in no time.
For example:
factor 18 18: 2 3 3
30. ping -i 60 -a IP_address Command – Ping with a Custom Interval
The ping command is often used to check the availability of a host, but you can modify it to send pings at custom intervals and even have an audible sound when each ping response is received.
The -i
option sets the interval, and -a
enables a sound for each successful ping.
ping -i 60 -a 192.168.1.1
31. tac Command – Reverse the Order of File Contents
The tac command is like cat, but it prints the contents of a file in reverse order. It’s a neat trick when you need to inspect the last few lines of a log file but don’t want to scroll all the way down.
For example:
tac myfile.txt
That’s a wrap on this round of lesser-known Linux commands! By incorporating these into your command-line toolkit, you’ll be able to streamline your workflow and become even more efficient with your Linux system. Give them a try and see how they fit into your daily tasks!
Thanks.
Forgot some of these commands.
@Kal,
Thanks for reading!
Glad it was a helpful refresher, it’s easy to forget some of these lesser-used commands.
Part 4 is on the way soon, so stay tuned for more!
I found that in Debian, if some of these commands do not work, you can use:
to install it. Sometimes it installs, but sometimes it does not work.
With these pages, I have found a few more, bringing my list up to about 260.
great! Some of the commands were not known to me….but hey…the system already had it…feeling ashamed :) :) maybe I should list the bin-directories in a free minutes to see, if there’s something I’m missing so far :)
gpasswd – to remove user from group
Got set of articles. After 30+ years of *nix experience, I learned quite a bit, and these articles are going into my archives of “useful” stuff! :-)
Thanks for your efforts. I see a great career for you in this domain.
P.S. I am a senior systems engineer for a tier-one tech company and help handle performance engineering for thousands of Linux servers world-wide, supporting 150M+ users.
@ Rubberman, Thanks for your valueable comment. Your comment is a gem :)
Problem :
# vgscan; pvscan; lvscan
# ^scan^display
gives :
#vgscan; pvscan; lvdisplay
Solution: full substitution with gs :
# vgscan; pvscan; lvscan
# !:gs/scan/display
gives:
#vgdisplay; pvdisplay; lvdisplay
@ ZIADI Mohamed-Ali, True ^foo^bar works with single substitution only, for multiple substitution, wait for our next article.
Great column. I just found your website last week and it is very useful. Thank you for sharing.
Thanks @ Kathy for making us feel proud.
My favourite:
du -ch –max-depth=1 * | sort -rh
:)
How about du -ch –max-depth=0 * | sort -rh
du -sh *
Awesome pro tips. I completely forgot about the “factor” command, I could have used that on Monday! “the more you know”
@ Josh, Thanks for your feedback.
For the > command, you might say “truncate” instead of flush. I can’t be the only one here thinking flush as in write all changes to disk from cache.
the command “fc” from bash is also quite nice
Thanks @ toma.
we will consider your’s provided command in one of our next article.