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!

Similar Posts