Summary

As someone looking to get things done quickly and easily, I’m always on the lookout for new Linux tools. There are many handy Linux commands which seem better than the regular commands you’re using. In this guide, I’m sharing some of my favorites.

1bat: cat With Syntax Highlighting

The cat commandon Linux is commonly used to display text content from a file on the terminal.The bat commandis an enhanced version of cat that supports syntax highlighting, Git integration, and automatic paging. It also shows non-printing characters more clearly than cat.

To install bat on Debian, Ubuntu, and their derivatives, run:

Using the bat command to display a text file on Linux.

Install it on openSUSE running:

After installing bat, you simply use it like cat—pass a file name to display its content, like this:

If you installed bat on Debian/Ubuntu using the APT package manager, you’d have to use batcat instead of bat to avoid conflict with another package called bat. So, in that case, run:

Using the ncdu command to analyze the disk space of the current directory.

You can useBash aliasesto map batcat to bat or even cat if you like. With the bat command, you can change the themes used to display text on the terminal. The –list-themes flag lets you check all the themes. To change to another theme, you use the –theme=theme_name option. Suppose you want to use the Dracula theme, you use the below command to use it:

If you want to set a theme permanently, you canset an environment variablein your .bashrc file. you’re able to also add new themes and syntax definitions to bat.

Full disk analysis using the ncdu command.

2ncdu: More User-Friendly Than du

Thencdu (NCurses Disk Usage) commandis a great tool for analyzing your disk space. The traditional du command provides disk usage that’s hard to parse. The ncdu command makes it easier to see what’s eating up your space.

To install ncdu on Debian, Ubuntu, and their derivatives, run:

Using the eza command to list files and directories in the terminal with full details.

Install it on openSUSE by running:

If you want to analyze the disk space usage of the current directory, run:

To analyze a specific directory, add that directory path as an argument. For example, if you want to analyze the snap directory, run this command:

Running the fd command shows the content of the current directory.

Likewise, for a full disk analysis, run:

Once the scanning is done, you’ll get an overview of the files and directories in a list structure with their sizes in descending order. You can navigate the list using the arrow buttons, press i to see more information about specific files, and press -d to delete them. If you want to analyze the disk space only of your internal drive and skip any connected storages, run:

When you’re done with the analysis, press q to return to the command line.

Using the fdfind command to search files using a string.

3eza: Beautiful Alternative to ls

eza makes file listing much more useful and cool-looking thanthe ls command. It offers many intuitive features, such as colored files, hyperlink support, and better readability.

The easiest way to install eza is by using the cargo package manager, which comes with the Rust development environment. First, install and set up Rust with these commands:

Using the fdfind command to search files using a string in a specific directory.

If you don’t havecurlinstalled, you’ll need to install that first. You’ll also need the build-essential package before running the next command.

You can use eza just like ls, without any parameters.

You can list the items with full details and icons as well. Your system needs to support the icons.

4fd: Fast and Friendly find

Thefd commandisn’t a direct replacement for the find command. However, you may perform most of find’s functionalities with it. fd has a more intuitive syntax than find and supports regular expressions.

To install fd on Ubuntu and its derivatives, run:

Using the fdfind command to search files by extensions.

On some distros such as Ubuntu, the command you need to run isfdfindinstead offd

A simple run of the commandfdfindwill return the content of the current directory, like this:

Using the ripgrep tool to search a string in a single file

The most basic way to use the fd command is by passing a pattern as an argument. Suppose, you want to search for files that contain the string “file”, then you need to pass that as an argument.

If you want to search in a specific directory, you can pass that directory path as an argument, like this:

Using the ripgrep tool to search a string in a directory

Another useful way of using fd is to find files by its extension. For example, if I want to search for bash scripts, I’ll search for files with the “.sh” extension. The command for that is:

If you want to learn more, check out ourfull fd command guide.

5ripgrep: grep, but Faster

ripgrepis a command-line search tool for recursively searching string patterns in multiple files in the current directory. It offers a better user experience than grep andis faster in many instances. If you’re a developer, you may use ripgrep to search for patterns in a codebase.

To install ripgrep on Debian, Ubuntu, and their derivatives, run:

To demonstrate ripgrep, I’ve made some demo directories and files containing text. If you already have a codebase or multiple files, then you can use it there. The command for ripgrep is rg. To search inside a single file, you pass the search string inside double quotes and the file name as arguments.

To search all files in a directory, pass that directory as an argument instead of the file name.

If you want to search in a specific type of file, you need to use the –type flag and pass that file extension, like this:

If you have hidden files, directories, ripgrep ignores them while searching.

6zoxide: Smarter Than cd

cd is one of the mostbasic Linux commands. It’s used for navigating through the file system on the terminal.zoxidemakes navigating much easier by remembering your most visited directories. You can install zoxide on any Linux distro using the provided installation script. Run this command:

If you don’t havecurlinstalled, you’ll need to install that first.

You can also use the package manager of your distro if you prefer that. Next, you need to initialize it. The command depends on which shell you’re using. For Bash, it’s this:

Let’s take a look at a quick example of how zoxide is better than cd. Suppose you need to navigate into a directory deep inside the system. With zoxide, you do it like this:

Once you do that, zoxide will remember it for the future. You won’t have to type the whole directory path and instead write the one you need to enter last.

If there are multiple directories with the same name, you’ll see a list of directories, and you can choose from there. For that, you’ll need the fzf tool as well.

7btop: More Interactive Than top

If you find it hard and boring to usethe top commandtomonitor your system, then btop is a great alternative. With full mouse support and gamified looks, it offers a better user experience.

To install btop, first download the suitable binary fromthe releases page. Then go to the directory where you downloaded the file. Run these commands:

After installing, run:

you may monitor disk usage, RAM usage, battery life, network, processes, and more.

8tldr: The Simplified Version of man

When you’re new to Linux and you want to learn more about a command, you’re often asked to usethe man command. However, as a beginner, it may seem confusing and intimidating. That’s wherethe tldr commandcomes in. It simplifies manual pages and provides practical use cases of the command.

The recommended way to install tldr is using npm, which requiresNode.JSinstalled. Once done, install tldr with this command:

Pick a command name and pass it as ar argument to see how tldr displays its details. Here’s an example for thermcommand:

9sd: Easier Syntax Than sed

The sd command supports commonly usedRegexsyntax, unlikethe sed command. It also has a string-literal mode, making it much easier to use. You can install sd using cargo.

Let’s see how sd is different from sed. I have a file where I’d like to replace ‘quick brown fox’ with ‘swift red fox’. The command for that is as below in both cases:

There are many more advanced uses of sd where you can apply complicated search patterns.

While some of these commands can’t fully replace the good old ones, they can come in handy in many cases. If you’d like to learn moreimportant Linux commands, check out our guide for that.