Here Are 11 Console Commands Every Developer Should Know

Boost your everyday productivity with these console commands

Indrek Lasn
Nov 8 · 7 min read
Photo by Sai Kiran Anagani on Unsplash

The command line makes our life so much easier since we can automate several mundane tasks and make things run smoother. Instead of clicking around in the Graphical User Interface (GUI), we can fire off a couple of commands and call it job done.

A Unix shell is a command-line interpreter or shell that provides a command-line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting language and is used by the operating system to control the execution of the system using shell scripts.

Every Linux or Mac-based operating system has a command-line installed by default, usually under the name “Terminal.” The command line (CLI) lets us easily move and rename files, sort through data, and navigate around the computer.

Without further ado, here are 11 command line tricks that will make your life easier.

1. grep

The grep command searches for patterns in each file. It also looks for patterns separated by newline characters, and grep prints each line that matches a pattern.

Using the grep command to find all React keywords in a file

The -i option enables us to search for a string case-insensitively in the given file. It matches words like “REACT,” “REact,” and “react.”

We can find the number of lines that matches the given string/pattern with the -c (count) flag.

Counting the times the word “react” pops up in a life

Here’s a fun and an educational comic about the grep command I found on the internet.

Source: Wizard Zines

In addition, the variant programs egrep and fgrep are the same as
grep -E and grep -F, respectively. These variants are deprecated,
but are provided for backward compatibility.

You can do a lot with grep— read the documentation for an in-depth dive here.

2. ls

ls lists files and directories in the current active path. If the pathname is a file, ls displays information on the file according to the requested options. If the pathname is a directory, ls displays information on the files and subdirectories therein.

Using the ls command to show all files in the current directory

You might have noticed the files are being shown as a grey color, while the folders are blueish. This is to help us make a distinction between folders and files.

3. pwd

Printing out the current working directory (pwd)

The pwd command is a command-line utility for printing the current working directory. The output will print the full system path of the current working directory to standard output. By default, the pwd command ignores symlinks, although the full physical path of a current directory can be shown with an option.

4. cat

Displaying content of a file with cat

The cat command has three related functions with regard to a text file:

  • Displaying them
  • Combining copies
  • Creating new ones

The most common use of cat is to read the contents of files, and cat is often the most convenient program for this purpose.

In the following example, the standard output of cat is redirected using the output redirection operator (which is represented by a rightward pointing angular bracket) to file2:

Creating files with cat

5. echo

The echo command in Linux is used to display a line of text/string that’s passed as an argument. The echo is a built-in command that’s mostly used in shell scripts and batch files to output status text to the screen or a file.

6. touch

The touch command is used to create a file without any content. The touch command can be used when the user doesn’t have data to store at the time of file creation.

Creating a new file with touch

Notice how we’re using touch to create the file and cat to look inside the file. Since the newly created index2.js file is empty, the cat returns nothing.

Here are the main differences between cat andtouch:

  • cat— Used to create the file with the content.
  • touch— Creates a file without any content or empty files. Remember, the file created using touch command is empty. This command is useful when the user doesn’t have data to store at the time of file creation.

7. mkdir

As you guessed it, mkdir creates a new empty directory in the current active path. Instead of clicking around in your text editor or GUI, use this command to create new folders.

Creating a new directory with mkdir

Note: Notice how we can peek inside the directory with the previous ls command.

7.1 rm

Rm stands for remove, which does exactly what it says it does. Removes, or in other words, deletes a file.

Removing a file with the rm command

By default, the rm command doesn’t remove directories. You need to pass the -rf flag to remove directories.

Removing a directory with the rm command (notice we’re passing the flag to remove a directory)

Note: This removes the directory unconditionally, whether the directory has content inside or not.

7.2 rmdir

The rmdir command removes the directory if there’s no content inside the directory.

Removing an empty directory with rmdir

8. tail

The tail command reads a file and outputs the last part of it (the “tail”).

Output the last num lines, instead of the default (10)

The tail command is useful when going through crash reports or previous history logs. Here’s an example of its usefulness when working with file logs.

9. wget

GNU Wget is a free software package for retrieving files using HTTP, HTTPS, FTP, and FTPS — the most widely-used internet protocols. It’s a non-interactive command-line tool, so it may easily be called from scripts, CRON jobs, terminals without X-Windows support, etc.

wget to fetch information about a webpage

GNU Wget has many features to make retrieving large files or mirroring entire web or FTP sites easy, including:

  • Can resume aborted downloads using REST and RANGE
  • Can use filename wild cards and recursively mirror directories
  • NLS-based message files for many different languages
  • Optionally converts absolute links in downloaded documents to relative so that downloaded documents may link to each other locally
  • Runs on most UNIX-like operating systems as well as Microsoft Windows
  • Supports HTTP proxies
  • Supports HTTP cookies
  • Supports persistent HTTP connections
  • Unattended / background operation
  • Uses local file timestamps to determine whether documents need to be re-downloaded when mirroring
  • GNU Wget is distributed under the GNU General Public License.

Read the official GNU documentation for more information.

10. find

The find command lets you quickly lookup a file or directory. It’s useful when you’re working on a big project with hundreds of files and multiple directories.

Finding all files with the name of index.js

Search for files of a particular type

The find command also lets you search for the same type of files in a directory (and its subdirectories). For example, the following command will search for all .js files in your current working directory.

Finding all .js files in the components directory

11. mv

The mv command moves files or directories from one place to another. The mv command supports moving single files, multiple files, and directories.

Moving the some-directory from components to utils directory


Thanks for reading, I hope you learned something new. If you know a handy command-line trick, please let’s grow together and post it in the responses.

Stay curious and hungry!

Better Programming

Advice for programmers.

Indrek Lasn

Written by

Software Engineer. I try to be kind and friendly. Let’s change the world together for the better. Follow me on Twitter @

Better Programming

Advice for programmers.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade