LINUX for Developers

Aditya Shinde
9 min readFeb 19, 2024

--

The blog content is creating according to the certain set of requirement nessary for a developer, mostly in case of deployment of applications, the linux env is widely used. For that developer must have an introuductory skills about linux OS, environmrnt, commands, tools and other stuff which will be covered further. Let’s dive into the topics.

Introduction to Linux

Genesis of UNIX

  • Linux: It is an open-source operating system
  • 1969: Ken Thompson and Dennis Ritchie develop UNIX at Bell Laboratories
  • UNIX rewritten in C for portability
  • UNIX becomes a widely used operating system

Importance of the Kernel

  • Kernel as the core of the operating system
  • Facilitates communication between hardware and software

Linux Today

  • Evolution of Linux into a powerful, versatile, and community-driven OS
  • Prevalence in servers, embedded systems, and personal computers

Linux Community

  • Diverse and global community of developers and users
  • Collaboration, forums, and contribution to the ecosystem

Installation and Distributions

The above described image lists the logo’s of different variant of Linux Operating System.

  1. Ubuntu: Known for being easy to use and free.
  2. Debian: A stable and reliable choice.
  3. Fedora: Cutting-edge and innovative, sponsored by Red Hat.
  4. Arch Linux: Lightweight and flexible, great for advanced users.
  5. CentOS: Stable and reliable, often used for servers.
  6. openSUSE: Focuses on security and stability.
  7. Linux Mint: User-friendly, with pre-installed multimedia codecs.
  8. Gentoo: Highly customizable and performance-oriented.
  9. Elementary OS: Simple and elegant, based on Ubuntu.
  10. Kali Linux: Designed for security testing and hacking.
  11. Parrot Security OS: Designed for penetration testing and security research, known for its extensive collection of tools and utilities for security testing. It is often used by security professionals and researchers.

Each has its own strengths and purposes, so you can choose the one that fits your needs best.

Fun Fact : Tiny Core

The smallest is the “Core” edition (17 MB), which provides a command line interface and some tools without any graphical desktop environment. The second is TinyCore (23 MB), which includes the base system and GUI extensions for a graphical desktop environment.

Virtualization

Before getting into the installation and accessing the linux, it’s important to know basics of virtualization. Virtualization in itself is a separate discipline that lays the groundwork for cloud computing.

Virtualization refers to the process of creating virtual instances of computer systems or resources, abstracted from the underlying physical hardware.

Types: There are various types, including hardware virtualization, software virtualization, and OS-level virtualization.

Functionality: Virtualization enables the division of hardware resources into multiple virtual machines (VMs), allowing efficient utilization and management of computing resources.

Benefits: It improves resource utilization, scalability, flexibility, and reduces hardware costs.

Implementation: Virtualization can be implemented through various technologies, such as hardware virtualization and software virtualization.

Lets understand the last part Virtualization Architecture:

https://www.manageengine.com/network-monitoring/images/virtualization-architecture.png

Type 1/Bare-metal Hypervisor: Runs directly on the host machine’s physical hardware, without the need for an underlying operating system.

Type 2/Hosted Hypervisor: Installs on top of an operating system like any other software application. It creates and manages virtual machines within the host operating system.

We will be using Hosted hypervisor as it meets our requirements.
Virtulization Softwares : VMWARE | VIRTUALBOX | HYPER V

Installation Platform:

Linux is a versatile and can be used and accessed in multiple ways. It can be seen from below image taken the Kali Linux variant webpage. Moreover, The cloud service providers also provides the linux OS as IAAS, PAAS and OS Images so that user can choose as per their requirements.

https://www.kali.org/get-kali/#kali-platforms

Keeping the blog shorter, if anyone is interested to practically dive into the linux OS and play with it.
The installation step by step process can be followed:
1. Virtual Machine : It’sFoss it is well documented. The Ubuntu variant is used in the installation. The virtulization software specifically used is VMWare which I personally prefer over VirtualBox.

2. WSL: I have added the link below, it has provided multiple ways with links, screenshots and commands to install WSL2 in smooth easiest way possible to use linux-distro cli on windows. https://contabo.com/blog/how-to-install-wsl2-on-windows-10/

Linux Directories

It is important to understand the Linux SystemDirectories, what type of files are stored in which folder. As when production app is deployed there fiels are stored is the folder taking example of logs, it can be found in /var/{app}/files.log

/ : The directory called “root.” It is the beginning point for the file system hierarchy.

/bin : Binaries and other executable programs.

/etc : System configuration files.

/home : Home directories.

/opt : Optional or third party software.

/tmp: Temporary space, typically cleared on reboot.

/usr: User related programs.

/var : Variable data, most notably log files.

Text Editors : To work with regular file editing, linux provide different text editors in both cli and gui based.
The most commonly used CLI based is vim, gedit and nano.
The GUI based Text Editors are — cherry, notepad++,

Importance of CLI

The majority of new developers struggle with the command-line interface (CLI) when first introduced to it. Let ease out the heat.

  • Introduction: Command-Line Interface (CLI) in Linux is a powerful tool for interacting with the operating system.
  • Efficiency: CLI allows users to perform tasks swiftly and efficiently, often with more control than graphical interfaces.
  • Customization: Offers extensive customization and scripting capabilities for automation and complex operations.

Types of Shells

  • Overview: Various shells are available in Linux, each with its unique features and purposes.
  • Mentioned Shells: bash (Bourne Again shell), ksh, zsh, tsch.
  • Emphasis on Bash: This course focuses on Bash, the default shell in most Linux distributions.
  • Comparision: Windows — Command Prompt , PowerShell | MAC — Terminal

Brief about Bash Scripting

  • Definition: Bash scripting involves writing sequences of commands that can be executed in a shell.
  • Automation: Bash scripts automate repetitive tasks, enhancing efficiency and consistency.
  • Versatility: Useful for creating complex workflows, handling file operations, and system administration tasks.
  • Integration: Bash scripting facilitates the integration of various commands and utilities in a cohesive manner.

File Permissions:

This is bit confusing part, let’s break it into the parts and simplify. Each file has the permissions.

  • Representation: The file permissions are represented by a 10-character string, such as -rwxr-xr — .
  • Meaning:

The first character denotes the file type, which can be

  • -: Represents a regular file.
  • d: Represents a directory.
  • l: Represents a symbolic link.
  • c: Represents a character device.
  • b: Represents a block device.
  • s: Represents a socket.
  • p: Represents a named pipe (FIFO).

The next three characters represent the owner’s permissions.

The following three characters represent permissions for the group.

The last three characters represent permissions for others.

  • Permission Symbols:

r: Read

w: Write

x: Execute

-: No permission

  • Example:

drwxr-xr — represents a directory where the owner has read, write, and execute permissions, the group has read and execute permissions, and others have only read permission.

  • Change Permission:

Chmod {permission} {filename}

Chmod +x {file} : Used to provide execution permission

CLI Commands

just the “bae haath ka khel “ for one’s working as system adminstration and cyber security while a nightmare for developers in remembering the commands. The Only key is to practise and hands-on.

The foremost helpful and useful command, when you’re lost in Linux, think of man or --help as your superhero, swooping in to save the day by explaining things in a way anyone can understand.

  1. Man : This utility command might not be installed initally, for that you’ll need to install first. Use command (for debian distro)
sudo apt install man

How to use this command:

If you encounter issue with any command just add add man in front it. It will provide brief and crisp documentation for that command or utility. The same can also be acheived by using — — help tag

uname man

2. Uname: To retrieves and displays system information such as the operating system name, kernel version, and hardware architecture. (The above screenshot explain’s in more better way, lets use it.)

uname -a

3. Echo: It is simlar to print commad, logs the content on console.

echo "Hello Readers!"

4. Pwd: (Present Working Directory) : It tells the current directory along with the path.

pwd

5. ls: list the contents of a directory.

ls
  1. ls -l (list files and folders with details in list format)
ls -l
  1. -a (list all files including hidden files and folders)
ls -a

Please Note: hidden files are represented by .{name}

  1. -al (list all files and folders with their details)
ls -al

6. Cd : (Changing Directory) Navigating in the os directories.

cd

. (current directory) — This is the directory you are currently in.

.. (parent directory) — Takes you to the directory below your current directory

-(previous directory) — This will take you to the previous directory you were just at.

cd or cd ~ (Home Directory) — This directory defaults to your “home directory”. Such as /home/fractxadi.

7. Create File:

touch command is used to create a new empty file and to change the timestamps of existing files.

Note : you dont need to always know abt command everything about can be fecth with — help

touch --help

A file with abc name with extension txt is created, initally it creates the empty file.

to add the content to the file either it can be addded using echo command seen earlier or using texteditor.

7. cat command : To view the content of the file, a command line/ gui based text editor. I prefer using nano cli based text editor.

cat abc.txt

To add multi- line text using echo use -e which treats \n as break and start with next line and to add the content to file use operator “>” {fielname}.{fileextension}

echo -e "abababbabababa\nhajshajshajshajshajshajsh" >> abccc.doc

To create multiple files use syntax filename{1..10}.{filetype}

touch Month{1..12}.pdf

7.1 Reading log files

head command helps to retrive the top most line (here 1st five line are loged on console.)

head -5 vmware-network.8.log

similary tail command performs opposite

tail -5 adb.txt

8. Remove file/folder/app

rm Month{1..12}.pdf

--

--