10+Terminal Commands Every Web Developer Should Know About

By Focusoncode November 6, 2018

The terminal is one of the most important productivity tools in a developer’s arsenal. Mastering it can have a very positive effect on your workflow, as many everyday tasks get reduced to writing a simple command and hitting Enter.

In this article, we’ve prepared for you a collection of Unix commands that will help you get the most out of your terminal. Some of them are built in, others are free tools that are time-tested and can be installed in less than a minute.

Curl

Curl is a command line tool for making requests over HTTP(s), FTP and dozens of other protocols you may have not heard about. It can download files, check response headers, and freely access remote data.

In web-development curl is often used for testing connections and working with RESTful APIs.

Curl commands can get much more complicated than this. There are tons of options for controlling headers, cookies, authentication, and more. You can read more about curl in the excellent free book Everything curl.

Tree

The tree is a tiny command line utility that shows you a visual representation of the files in a directory. It works recursively, going over each level of nesting and drawing a formatted tree of all the contents. This way you can quickly glance over and find the files you are looking for.

Tmux

According to its Wiki, Tmux is a terminal multiplexer, which translated in human language would mean that it’s a tool for connecting multiple terminals to a single terminal session.

It lets you switch between programs in one terminal, add split screen panes, and attach multiple terminals to the same session, keeping them in sync. Tmux is especially useful when working on a remote server, as it lets you create new tabs without having to log in again.

Disk usage – du

The du command generates reports on the space usage of files and directories. It is very easy to use and can work recursively, going through each subdirectory and returning the individual size of every file.

A common use case for du is when one of your drives is running out of space and you don’t know why. Using this command you can quickly see how much storage each folder is taking, thus finding the biggest memory hoarder.

Htop

Htop is a more powerful alternative to the built-in top task manager. It provides an advanced interface with many options for monitoring and controlling system processes.

Although it runs in the terminal, htop has very good support for mouse controls. This makes it much easier to navigate the menus, select processes, and organize the tasks thought to sort and filtering.

Git

Git is by far the most popular version control system right now. It is one of the defining tools of modern web dev and we just couldn’t leave it out of our list.

There are plenty of third-party apps and tools available but most people prefer to access git natively through the terminal. The git CLI is really powerful and can handle even the most tangled project history.

Tar

Tar is the default Unix tool for working with file archives. It allows you to quickly bundle multiple files into one package, making it easier to store and move them later on.

Using the -x option it can also extract existing .tar archives.

Note that most other formats such as .zip and .rar cannot be opened by tar and require other command utilities such as unzip.

SSH

With the ssh command, users can quickly connect to a remote host and log into its Unix shell. This makes it possible to conveniently issue commands on the server directly from your local machine’s terminal.

To establish a connection you simply need to specify the correct IP address or URL. The first time you connect to a new server there will be some form of authentication.

If you want to quickly execute a command on the server without logging in, you can simply add a command after the URL. The command will run on the server and the result from it will be returned.

Alias

Many Unix commands, including some featured in this article, tend to get pretty long after you add all the options to them. To make them easier to remember, you can create short aliases with the alias bash built-in command:

The alias will be available as long as you keep that terminal open. To make it permanent you can add the alias command to your .bashrc file.

Grep

Grep is the standard Unix utility for finding strings inside text. It takes an input in the form of a file or direct stream, runs its content through a regular expression, and returns all the matching lines.

This command comes in handy when working with large files that need to be filtered. Below we use grep in combination with the date command to search through a large log file and generate a new file containing only errors from today.

Another great command for working with strings is sed. It is more powerful (and more complicated) than grep and can perform almost any string-related task including adding, removing or replacing strings.

Leave a Comment

Your email address will not be published.