Get started with Linux: A developer's friend
Tags: beginners, terminal, devops, unix
Published: 2024-02-02 10:56:46

Do you want to take full control of your system operations? Want to know what happens behind the scenes? Well you need to know how to interact with the terminal. In this tutorial, we will go through some important Linux commands. This tutorial is not only for developers. System administrators, Devops engineers and cyber security professionals need this too! 

## What is Linux?
Linux is an open source Unix-like operating system. This means the commands that you run on any Unix machine will be similar to the ones you run on Linux.

## Linux distributions
The Linux ecosystem has various distributions such as ubuntu, arch linux, fedora etc. In this tutorial we will be using ubuntu.

## Installation
To get started, make sure you have a Linux distribution installed in your machine. For those using MacOs or Unix machines, you do not need to install anything. You just need to open your terminal and you are good to go. 

For those using windows OS, you will need to first of all install WSL in your system. WSL is a feature that enables you to have a Unix like terminal in your windows machine.

## Steps to follow:

- Open windows powershell as an administrator
- Write pip install wsl
- Install ubuntu
- Set your username and password for your ubuntu
- Navigate to Microsoft official website and type windows terminal
- Pick download windows terminal
- After downloading windows terminal it will open in powershell

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5r60epzjm7ktfdb2oneg.png)

You can change the terminal from powershell to ubuntu by clicking the dropdown arrow and choosing ubuntu as shown below

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rdtrwi1wdma77duwgh03.png)
Once your screen appears this way, then you are ready to start!

## Basic Linux commands
**whoami:** This returns the name of the currently logged in user
Navigate to your terminal then type **whoami**. Press enter and see the magic

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b3onrzgh1ny0588uh14e.png)

**man:** This command stands for manual. It gives us information about other commands and usage. You can call it the linux google! 
Type man then press enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2w6926wyfb8qujl36jr6.png)
Now type **man** **whoami**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tj7kyjfjxk1dppa7km65.png)
To get out of man page, press **q **and get back to the terminal

**pwd:** This command tells you the current directory in which you are.
This really helps a lot especially when you have to run commands in a specific directory. 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahjivi9naz1g2mcpyo7b.png)
Type **pwd **then press enter

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzdhuj95he6up7hmyytn.png)

**mkdir:** This command is used to make a new directory or folder
Type **mkdir** followed by the name of the directory you want to make
Example let's make directory named Friday


**cd:** To navigate to the directory you just made. type **cd **followed by name of the directory.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/85ammmer1cj6mq8fxh7g.png)

**ls:** This command is used to list the contents of your folder.
Our current directory Friday has no content. So when you type the ls command you will not see anything. Try it.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u3a1s7j43muxswygdvar.png)
To see some content in our directory we will need to add some content. let us do this using the next command we will learn.

**touch:** This command is used to create files
write touch followed by the name of your new file

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/26aa1esnqncuuwaezk37.png)
now use the **ls** command to check if the new file created is present

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rwqcr7zauo71d2qa75gy.png)

**ls -l:** This lists contents of your folder or file in long list format. It shows you the person who created the files or folder, when it was created, file permissions etc.
type **ls -l** then press enter

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7zjb1oxvto5prs7zwmjq.png)

**mv:** This command has two main uses. it is used to rename a file and also used for moving files to a different folder.
Let's first check the first use of renaming a file. 
type **mv** followed by the current file name then the new file name
eg **mv afternoon evening**. Press enter then type **ls** to check the new file name

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/evhe9503on3urhm1thfu.png)

To implement the second use of **mv** command, we need to make a new directory.
Use the command **mkdir** to make a new directory called day

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3qjej9kqv20yvv7h0cy4.png)
Now to transfer the evening file into day folder, write **mv evening /day**. Please note that sometimes when you type this command you will get permission denied. This is a linux feature for security that ensures some actions are only performed by authorized users. To bypass this, write **sudo mv evening /day**. The sudo command gives you administrative privileges. You will be prompted for a password when you use **sudo**. Type in your linux password then press enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qu3crib7juf2e6z2u5cq.png)
Please note the / sign before name of folder. press enter.
To check the contents of the new folder day, type **ls /day**

**rmdir:** This command is used to delete a directory. Let us delete the directory day. Type **rmdir** followed by name of directory you want to delete. eg **rmdir day**. Type ls to check that the directory no longer exists

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4v2pq7g0c099lbc1drkj.png)
**rm:** This is used to delete a file
let's make another file called tutor then we delete it. 
type **touch tutor** to make the file then type **ls** to confirm that it is present. Now type **rm** **tutor** to delete it then type ls to see what happens

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b1vr7chhdzz1uy1p9fxn.png)

**cd -:** We looked at cd command that means changing directory. Now what does **cd -** do? The **cd -** takes you back to your previous directory. Type cd - then press enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wwdg1l8d1pklpc2dbyui.png)

## Conclusion
We have come to our end of this tutorial. This should form as a basis to get you started in the world of Linux or Unix systems. Feel free to leave your feedback and suggestions on the topics I should discuss with you. Thank you and see you in my next tutorial!