10 Most Useful Bash Commands Every Developer Must Know About

10 Most Useful Bash Commands Every Developer Must Know About

ยท

7 min read

Featured on daily.dev

Introduction

If you are a developer, you must have used or at least heard about Linux. So in this blog post, we're gonna be looking at the 10 most important and useful commands that Every Developer Must Know About!

Ok so without any further ado, lets get started.gif

A bit about Bash and Terminal in Linux

For those of you, who don't know about terminal, terminal is the Unix shell. We can type commands in it and it executes them. Basically, terminal acts as an interface to interact with different software and hardware of the computer. It is also known as Command Line Interface (CLI). Terminal is similar to Command Prompt or Powershell in Windows.

Bash on the other hand is the programming language that is executed in the terminal. Bash has multiple commands, out of which we're gonna look at the useful ones in this blog!

1. ls

This command is used to list the files and directories in the terminal.

Suppose you are in the folder named "Dogs" and it has files named "labrador.png", "pug.png" etc. So, the command will output the names of files in the folder "Dogs".

2. cd

The cd command stands for "change directory" and it literally does what it says ๐Ÿ˜…. It changes the directory you are currently present in.

Its syntax is as follows

cd <path of the directory>

You can also type the following command to go to the parent directory

cd ..

3. cat

The cat command stands for "concatenate". It is used to print out the contents of any file. Let's say you have input.txt file in your current directory and it contains the text "Hello World!". If you type cat input.txt it will print "Hello World!" on the screen.

Its syntax is as follows

cat <name of the file>

4. shutdown

Stuck in the GUI of linux and can't find a way to shutdown your computer? Well, that's why the shutdown command exists!

The shutdown command can also restart your computer!

To shutdown the computer, type the following command in the terminal

shutdown

To restart your computer, type the following command in the terminal

shutdown -r

5. cp

Want to copy a file quickly without using the mouse? Well, you can do that using the terminal.

To copy a file from one folder to another, just type the following command.

cp <path of the file to copy> <destination folder>

To copy a file to the current folder, just type the following command.

cp <path of the file to copy> .

6. mv

This command is the same as cut and paste. It removes the file from the source folder and pastes it to the destination folder.

Its syntax is similar to the cp command.

To move a file, just type the following command in the terminal.

mv <path of the file to copy> <destination folder>

To move a file to the current folder, just type the following command.

mv <path of the file to move> .

7. pwd

pwd stands for "print working directory". pwd command prints the directory in which you are present.

To know the folder you are in, just type the command given below in the terminal.

pwd

8. mkdir

The mkdir command is used to create a new directory/folder. It is really handy at times.

To create a new directory, just type the following command in the terminal.

mkdir <name of the directory to create>

9. touch

Want to create a file quickly? You can use the touch command for that!

You can also create multiple files at the same time with the touch command.

The syntax for the touch command is as follows.

touch <name of file 1> <name of file 2> <name file 3>

You can type as many files name as you want to create but I have taken only 3 over here.

10. unzip

Downloaded source code from Github and wanna unzip it quickly? ๐Ÿ˜‚

Well, you might wanna use the unzip command :)

The unzip command is not installed in most Linux Distros by default, but you can install it by typing the command below.

sudo apt install unzip

After installing the unzip command, you can unzip the files by typing the command below.

unzip <name of the zip file>

To unzip a password-protected zip file, just type the following command.

unzip -P <password of the file> <name of the zip file>

Conclusion

In this post, I gave a brief about all the commands. If you want to read more about these commands (which I encourage you to), you can have a look at the linux man pages.

So those were the top 10 most useful linux commands for developers! Though I wanted to cover some more commands, I didn't want to make this post very long. So, I might post the second part in which I'll be talking about some more commands.

Comment below if you want the second part! ๐Ÿ˜Š

That's all for this post! Comment down below if you liked it! Also please suggest me some topics you want to read next!