Published in


4 Must-Have Linux Commands for Software Developers

If you are a software developer, chances are you will be dealing with Linux systems and having to debug code. The best way to debug existing software is to find logs related to the issue, thus saving you loads of time enabling you to understand the situation and determine the best solution.

Personally, debugging is not my strongest suit, but it is essential to be an effective developer. Since learning these commands, I have become an excellent solver of production issues as well as developer of new software. As such, I hope they can help you too.

The four commands: cat, grep, less, and find, are important when you want to debug in an existing Linux machine.


Courtesy of wallpapercave

What is cat? Do I mean the animal cat? Unfortunately not! In Linux, cat (which stands for concatenate) is a command to sequentially output the content of a file in the command line.

To use it, you can simply run the following:

cat your-file.txt

You would then get the contents of the file:

contents of the file
line 2 of the file
line 3, other contents etc...

This is great for quickly printing out current configurations and short log files, but it isn’t actually very useful by itself. To unlock cat’s power, we need to know about the next command.


What is grep? grep (which stands for globally search a regular expression and print) is a command that can search for the occurences of specific content and printing the lines in the file of those occurences. This is especially useful when used with the pipe ‘|’ command to pass the output of cat into the grep command as follows:

cat your-file.txt | grep contents

In the command, we take the contents of the file and search for the occurences of the word ‘contents’. We get the following output:

contents of the file
line 3, other contents etc...

How is this useful?

This is especially useful when searching logs for a specific identifier, like an order id or account id. This can then help you track down the exception that occurred relating to the specific identifier.

Another useful case is to determine if a specific pattern (e.g. the word ‘Exception’) occurred in the log file, thus allowing you to determine the weight of an issue, whether it is critically affecting numerous users, or a specific few.

BONUS: You can chain the output of the grep command with the wc command using the paramer -l to output the line count as follows:

cat your-file.txt | grep contents | wc -l

Your output in this case would then be



In some cases, the log file may be too large, thus using cat would print WAY too much content, or using grep would not show you other parts of the errors in the file. In these cases, less is here to save the day!(As the old adage goes, “less is more!”)

What is less? It is an interactive command in Linux to show you a small portion of a large file at a time. It also allows you to navigate the file with arrow keys, or jump to certain lines with certain commands. The following are commands that are very useful for using less

G          : Jump to the start of the file
shift + G : Jump to the end of a file
/ :
Search forwards for a pattern
? :
Search backwards for a pattern

How less can help

With these commands, you can find the occurence of an identifier or an exception (e.g. with shift+G then ?1234 to find the last instance of the id 1234) and find surrounding log output to better understand the issue.


Finally, if you do not know the location of the log file (which is usually the case in projects with a lack of documentation!), you can use find to locate possible log files.

What is find?

find is a command that outputs the filenames in a directory which contains the pattern that you indicate. It searches the directory with recursion, thus helping you find files where you might not have guessed.

The basic usage of find is:

find {location} -name {pattern}

For example, the following command searches the current directory . for all files containing the word “log” (e.g. server.log). The * is a wildchard character to match any string

find . -name "*log*"

Be warned!

Using find at the root directory / as shown below can take a long time since it will search all the files in the system. The command will print out all the files in the system since we do not include a -name argument.

find / 


There you have it! Using the commands cat, grep, less, and find can help save you a great deal of time, thus allowing you to find the root cause of an issue earlier and become an efficient developer.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store