Intro To Linux [For Beginners]
Tags: linux, beginners, productivity, bash
Published: 2020-07-09 14:38:53

One of the most important tools for a programmer is the **Operating System**, it runs your whole device and it's important to choose the one that suits you the best!

In this post, I'll be sharing why Linux could be the best choice for your 'Developer' workflow.

**Have never heard about Linux ?** Don't worry, I'll explain everything. But first, allow me to share a quick **fact** with you, whether you know it or not,
  <br/>

#  YOU USE LINUX EVERYDAY.  
  
  <br/>
Yes, you read that correct. Over **850,000** Android Phones running Linux are activated every single day. Meaning, about **100 devices came online, since you started reading this article 😉**. Nearly **700,000** Televisions running Linux are sold every day. 8 out of 10 **Financial Trades** are powered by Linux. 9 out of 10 **World's Supercomputers** run Linux. Most of the **websites you visit** (Even this!) are powered by Linux. Hell, even most of the **Satellites** in the space, are powered by Linux!

#### That's the sheer scale, versatility & power of Linux!

and that is also one of the most important reasons that you should learn to use Linux, using Linux you'll be able to command such a huge variety of devices.

Let's get started.

## What Is Linux?

Linux is actually a kernel.

The Linux kernel is the main component of a Linux operating system (OS) and is the core interface between a computer’s hardware and its processes. It communicates between the two, managing resources as efficiently as possible.

The Linux kernel is world's largest open source project in the computing history! It's available [here](https://github.com/torvalds/linux).

Many Operating systems are based on this including Ubuntu, Kubuntu, Debian, Fedora, PopOS, Kali Linux etc. These are called Linux distributions.

When someone says to you that they use linux, what they actually mean is that they use some distribution of Linux.

I hope this is insightful and encourages someone else to make the jump into Linux for doing development work, I have enjoyed the OS so much that I'm actually taking courses on Linux administration and working on becoming a power user. Something I never felt inspired to do on Windows.

## What's So Special About Linux?

1. Open source.
1. Flexibility
1. It's Free.
1. High Security.
1. Highly Customizable.

### 1. Open Source

Linux is great for the open-source benefits, which encompass not only the freedom of the software but also that a lot of the open-source projects do not track and sell user data like closed-source projects have been known to do. The customization of Linux is a second-tier factor, but still super imperative for users like you and I. I love to be able to use different shells, the package management solutions, the wide array of software to choose from, and the community support offered by the service. With Windows 10, so many trackers come on the system now, I would say privacy is a big win for Linux right now.

### 2. Flexibility

Linux is flexible. Linux is used in a lot of different types of computers. From smart toasters and refrigerators, IOT devices, internet routers, Android smartphones to satellites in the space. You can install Linux on your laptop or desktop today and be up and running with little set up! This flexibility is possible because a Linux operating system is designed to be the sum of many different tools that do one job and do it well. You could piece together a version of Linux that works for your device and is optimized for your needs.

### 3. It's Free

Linux is free. Free in multiple ways, you don't need to pay to use Linux and you're free to view, edit, and distribute the source code. When you buy a computer with Windows or mac-OS, the cost of creating and maintaining these operating systems is included in the price.

### 4. High Security

Linux is an open operating system, the codes which can be read by everyone. So there are far better chances that when thousands of contributors are collaborating over the same software, it is less probable for any bug or security loopholes to exist, even if they do, they'll usually be fixed in a short amount of time. Also, the ground up design of the Linux distributions is made to be redundant, users have a lower access rights, and, theoretically, even if a virus gets installed, the virus can only access local files and folders, and the system will remain safe.

### 5. Customization

If you know your way around the Linux system and you can customize every single corner of it, the whole project code is open-source, therefore you can modify the code to customize the OS and even distribute it as a distribution of your own.

## So, Which one should I choose?

There are **hundreds** of Linux distributions to choose from.\

As the kernel is open source, it allows basically anyone to use it and build their own custom operating system. According to Wikipedia, there are **over 600 Linux Distributions**, you can check the facts [here](https://en.wikipedia.org/wiki/Linux_distribution#:~:text=Almost%20six%20hundred%20Linux%20distributions,of%20those%20in%20active%20development.).

But for the general usage, **Ubuntu, Fedora, Debian** are much popular. For penetration testing, **Kali Linux** is a popular choice and also **CentOS** for enterprise grade.

![Linux Distributions](https://dev-to-uploads.s3.amazonaws.com/i/7gw1mvajmv4bwyzhiy6l.png)

Each of these distributions have their own strengths & weaknesses, so before switching to a distribution, do check out some sources about which one to choose. If you're absolute beginner, my personal recommendation would be using **Ubuntu**.

## Basic Linux Commands

Now that you know what Linux is, why you should consider using it and once you've chosen a Distribution, it's time to dig into the actual OS.

Let's see some basic commands in Linux.

`NOTE : Linux commands are case sensitive hence you need to be careful about what you are typing.`

`1.` **ls** command  
   It refers to List directory contents. If you know windows you 
   would know that the command dir is used to list the contents in 
   a directory. In Linux, the ls command is used to list out files 
   and directories.

   `ls -l` helps to paginate the output so you can view page by 
   page. Otherwise the listing scrolls down rapidly.

  ```bash
  ls -l filename|foldername
  ```

`2.` **cd** command  
   It helps to change the current directory. In linux, forward slash is used to denote the contents of a directory.

  ```bash
  cd /etc/
  ```

`3.` **grep** command  
   It is used to find text in a file. The grep command searches through many files at a time to find a piece of text you are looking for.

  The below command will find all of the words in the linux.txt file that matched the word ‘ishandeveloper’.

  ```bash
  grep 'ishandeveloper' linux.txt
  ```
  It's syntax is : **grep PATTERN [FILE]**.

`4.` **sudo/su** command  
  There are some commands that need elevated rights to run on a Linux system. So you run them as a System Administrator which normal users cannot do.

  su command changes the shell to be used as a super user and until you use the exit command you can continue to be the super user

  sudo – if you just need to run something as a super user once, you can use the sudo command instead.

  ```bash
  sudo shutdown 5
  ```

`5.` **pwd** command  
  To identify the directory you are working in you can use the pwd command.
  It displays the current working directory path and is useful when directory changes are often

  ```bash
  pwd
  ```

`6.` **touch** command  
  It is used to create a new empty file in the existing directory.

  ```bash
  touch old.txt
  ```
  It's syntax is : **touch [FileName]**.  
  You'll notice that a new file 'old.txt' will be created in the current directory.

`7.` **mv** move command  
  It is used to move a file or rename a file.

  ```bash
  mv old.txt new.txt
  ```

`8.` **cp** copy command  
  It is used to make a copy of an existing file, with a new name in the same directory or similar name in another directory.

  ```bash
  cp new.txt newest.txt
  ```
  It's syntax is : **cp [SOURCEFILE]&nbsp;&nbsp;[DESTINATIONFILE]**.

`9.` **rm** command  
  This command is used to remove files in a directory or the directory itself. A directory cannot be removed if it is not empty.

  ```bash
  rm file.txt
  rm -r directory
  ```
  rm –r removes all the contents in a directory and the directory as well.  
  It's syntax is : **rm [name of the file]**

`10.` **mkdir** command  
  It is used to create a new directory/folder in the current location
  ```bash
  mkdir newFolder
  ```
  It's syntax is : **mkdir [directory name]**

`11.` **chmod** command  [Thanks to @kailyons]
  It is used to change the mode of a file system object. Files can have r – read, w- write and x-execute permissions.

  It is fairly easy to change the permissions of a file for a quick edit. All you need to do is `chmod +/-<permission_char>`
  
  To gain executable permissions for a script file you can use : 
   ```bash
   chmod +x script.sh
   ```
  To remove those permissions for a script file you can use : 
   ```bash
   chmod -x script.sh
   ```

   You can refer to [this](https://chmod-calculator.com/), to learn more about the permission codes in Linux.

`12.` **apt –get** command
  apt -get is actually a very powerful and free front-end package manager. It is used to install new software packages, remove available software packages, upgrade existing software packages as well as upgrade the entire operating system. Here, apt – stands for advanced packaging tool.

  ```bash
  sudo apt-get update
  ```
  The above command will update all the packages currently installed on your system.

Linux doesn’t end here. There are several other amazing features including ssh or others, which just can't be covered in a single post. You can learn more about it by reading articles, documentation or explore them on your own by using Linux in your daily life.

#### That's all for now, catch you guys in the next one 👋🏻.

Originally Published on my [Personal Blog](https://blog.ishandeveloper.com/linux-intro).