Useful Linux Commands — Network and Compression

Spread the love

Linux is an operating system that many developers will use.

Therefore, it’s a good idea to learn some Linux commands.

In this article, we’ll look at some useful Linux commands we should know.


The export command let us export variables to child processes.

For instance, we run:

export TEST="test"

to set the TEST variable to 'test' .

We can also reference another variable by using the $ in the expression on the right side.

For example, we run:

export PATH=$PATH:/new/path

to reference the existing value of the PATH environment variable on the right side.


We can run the tar command to archive files.

To create a tar archive, we run:

tar -cf archive.tar file1 file2

to create a tar archive with the file1 and file2 files in the tar archive.

We can extract files from an archive in the current folder by running:

tar -xf archive.tar

And we can extract an archive into a specific directory with:

tar -xf archive.tar -C dir

x stands for extract and f means write files.

c means create.

The z option lets us create a gzip archive.

For instance, we run:

tar -czf archive.tar.gz file1 file2

to create a gzip archive with file1 and file2 inside.

And we can gunzip a gzip archive with:

tar -xf archive.tar.gz


The traceroute command lists all the nodes traversed to reach a host.

For instance, we run:


to see where the packets go to reach Google.


The ping command lets us ping a network host to see if it responds.

For instance, we run:


to see if Google is up.

We can continually ping it with the -c switch:

ping -c

It stops pinging only when we press ctrl+c.


The gunzip command lets us unzip a zip archive.

For instance, we can run:

gunzip filename.gz

to extract the files in the filename.gz file.

We can use the -c switch extract a file to a different filename:

gunzip -c filename.gz > bar

Then we extract filename.gz to the bar file.


The gzip command lets us create a compressed file.

For instance, we run:

gzip filename

to compress the filename file.

We can rename the gzipped file with the -c switch:

gzip -c filename > filename.gz

Then we compress the file into the filename.gz file.

The -k option also lets us change the name of the compressed file:

gzip -k filename

We can set the compression level with the -<number> switch.

For instance, we run:

gzip -1 filename

to compress filename with level 1 compression.

We can compress multiple file by adding the file names separated with spaces:

gzip file1 file2

We compress file1 and file2 with one gzip command.

Also, we can compress all files in a directory recursively with the -r switch:

gzip -r folder

The -v switch prints the compression percentage info.

The -d switch decompresses a file:

gzip -d filename.gz


We can compress files and folders, and do basic network tasks with some basic Linux commands.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *