7 time-saving Linux commands

Some Linux commands can make your time on the command line easier and more productive. This post covers some commands that can come in very handy.

1. Using the tldr command to simplify man pages

The tldr command displays simplified man pages, providing practical examples of how to use a command and its options. It helps users to learn about a command without having to read through what might be an extensive man page. For example, if you want a quick view of how you can use the date command, you could use a command like what is shown below. Note that explanations of various options are provided along with the example commands.

$ tldr date

date

Set or display the system date.
More information: https://www.gnu.org/software/coreutils/manual/html_node/date-invocation.html.

- Display the current date using the default locale's format:
date +%c

- Display the current date in UTC, using the ISO 8601 format:
date -u +%Y-%m-%dT%H:%M:%S%Z

- Display the current date as a Unix timestamp (seconds since the Unix epoch):
date +%s

- Convert a date specified as a Unix timestamp to the default format:
date -d @1473305798

- Convert a given date to the Unix timestamp format:
date -d "2018-09-01 00:00" +%s --utc

- Display the current date using the RFC-3339 format (`YYYY-MM-DD hh:mm:ss TZ`):
date --rfc-3339 s

- Set the current date using the format `MMDDhhmmYYYY.ss`:
date 093023592021.59

- Display the current ISO week number:
date +%V

2. Using the ncdu command to view disk usage

The ncdu command is a user-friendly command for analyzing disk usage. It also allows you to use your keyboard arrow keys to move up and down the listing, which will contain entries like what you see below.

ncdu 1.20 ~ Use the arrow keys to navigate, press ? for help
--- /home/shs --------------------------------------------------------------------
114.6 MiB [#################] /.cache
21.6 MiB [### ] /.mozilla
3.4 MiB [ ] /.local
428.0 KiB [ ] /.config
388.0 KiB [ ] /videos
28.0 KiB [ ] /bin
20.0 KiB [ ] report

3. Using the rsync command to synchronize data

The rsync command is a tool that is used for efficient file and directory synchronization between two systems or two locations on a single system. The command below would make a copy of the local bin directory in the /tmp directory, creating a /tmp/bin directory.

$ rsync -r bin /tmp
$ ls /tmp/bin
backup FindFiles run_stats update_system

4. Using the pv command to monitor progress in a pipe

The pv (pipe viewer) command allows you to monitor the progress of data through a pipe. Until the command is finished, it updates the display of the data transfer rate, elapsed time, percentage completed, and completion ETA (estimated time of completion), allowing you to monitor the process of the data movement.

$ cat largefile | pv | gzip > largefile.gz
1.23GiB 0:00:15 [ 85MiB/s]
[====> ] 12% ETA 00:50

5. Using the fortune, rev and shuf commands to generate random text

The fortune and rev commands are very different, but they both can be useful when you want to generate random text. The fortune command will generate a quick quote or “fortune,” while the rev command reverses the letters in text provided to it. Here’s an example of using them together.

$ fortune | rev
!ti deteled dna ,ti daer resu-repus eht tub ,liam dah uoY

The shuf command allows you to randomize the lines in a file. Here’s a sample file and the results of shuffling its contents.

$ cat names
Bill
Danny
Dorothy
Jim
Joanne
John
Marty
Nancy
Sandra
Stewart

$ shuf names
Jim
Nancy
Joanne
Marty
Sandra
Dorothy
Stewart
Bill
Danny
John

Each time you run shuf, the output should be different.

When you just need some random text for testing a script, these commands can help you out.

6. Using the watch command to monitor changes

The watch command allows you to run a command repeatedly and watch for the output changes you might be expecting to see. By default, it runs every 2 seconds, but you can change the interval by using the -n option. The command below uses the -d option to highlight changes in the command output.

$ watch -d free -m
Every 2.0s: free -m fedora: Fri Feb 14 15:52:23 2025

total used free shared buff/cache available
Mem: 3784 1121 819 135 1844 2190
Swap: 3783 77 3706

7. Using the tree command to view directory contents in an user-friendly way

The tree command provides a file listing that displays directories and files in a tree-like display, giving you a quick but useful view of what’s inside some particular directory. Notice how the indentation makes the structure of the directory easy to understand.

$ tree bin
|----- backup
|----- FindFiles
|----- NOTES
| |----- report_formats
| |----- meeting notes
|----- scripts

Wrap-up

Some commands can make seeing what you’re looking for on the command line a lot easier. Just don’t forget to turn the more complex commands into aliases to make them easier to use.

Source:: Network World