10 Advanced Linux Commands You’ve Probably Never Used (Part 3)

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:

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
Edit Your Last Terminal Command
Edit Your Last Terminal Command

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
Quick Disk Usage Overview
Quick Disk Usage Overview

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!

💡 Want to Level Up Your Linux Skills?

Check out Pro.Tecmint.com for ad-free reading, exclusive guides, downloadable resources, and certification prep (RHCSA, RHCE, LFCS) - all with lifetime access.

Ravi Saive
I'm Ravi Saive, an award-winning entrepreneur and founder of several successful 5-figure online businesses, including TecMint.com, GeeksMint.com, UbuntuMint.com, and the premium learning hub Pro.Tecmint.com.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

20 Comments

Leave a Reply
    • @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!

      Reply
  1. I found that in Debian, if some of these commands do not work, you can use:

    sudo apt install ANOTHERcOMMAND4U
    or
    sudo apt-get install ANOTHERcOMMAND4U
    

    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.

    Reply
  2. 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 :)

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

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

    Reply
    • @ ZIADI Mohamed-Ali, True ^foo^bar works with single substitution only, for multiple substitution, wait for our next article.

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

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.