Introduction to Linux: Day 2

Introduction to Linux: Day 2

What is Linux?

Day 2 of #90DaysOfDevOps with the #TrainWithShubham Community. The challenge is for the DevOps Community to get stronger in DevOps. It is a great initiative by Shubham Londhe. Documenting my learning and also sharing it with the community is helping me to get more clear with the concepts.

What is Linux?

Linux is a community of open-source Unix-like operating systems that are based on the Linux Kernel. It was initially released by Linus Torvalds on September 17, 1991. It is a free and open-source operating system. The biggest success of Linux is Android(operating system) it is based on the Linux kernel.

Why Linux

  • Multi-User & Multi-Tasking

  • Open Source

  • Security

  • Need fewer resources

Linux Flavours

  • RHEL (Red Hat Enterprise Linux)

  • CentOS

  • Ubuntu

  • Amazon Linux

  • Fedora

  • Linux Mint

  • OpenSUSE

Architecture of Linux

Hardware Layer

This layer consists of all peripheral devices like RAM/ HDD/ CPU etc.

Kernel

The architecture of an operating system, the kernel is the most important or heart of the operating system as it manages the communication between a machine’s hardware and its software. The visibility of the kernel’s operation is invisible and so it is not accessible to the end-user. These userspace tools only have GUI file systems, web browsers, and the Bash shell. In short, the kernel behaves as the heart of the system and manages the memory, peripheral devices, and CPU. The kernel stands at the “lowest” level of the OS.

Shell

It is an interface to the kernel which hides the complexity of the kernel’s functions from the users. It takes commands from the user and executes the kernel’s functions.

System Utility

It provides the functionalities of an operating system to the user. Like Screen Savers, System Monitors, Network Utilities, etc.

Application

Desktop environments do not offer any lend to the full array of applications. As mac and Windows, Linux similarly offers hundreds of high-quality feasible software that is easily available and can be installed anytime anywhere.

File system hierarchy

  • / - This is a top-level directory

  • /root - It is the home directory for the root user

  • /home - It is the home directory for other users

  • /boot - It contains bootable files for Linux

  • /etc - It contains all configuration files

  • /usr - by default software is installed in this directory

  • /bin - It contains commands used by all users

  • /sbin - It contains commands used by the only root user (root)

Linux basic Commands

  • cat (create & append file)

  • touch (create the blank file)

  • nano (create & edit file)

  • vi/vim (create & edit file)

  • ls (list)

  • ls -a (list all files including hidden)

  • ls -la (list all files with permissions)

  • cd (change directory)

  • pwd (print working directory)

  • mkdir (create a directory)

  • cp (copy)

  • mv (move)

  • mv (rename)

  • rm (remove the file)

  • rm -rf(remove directory & recursive)

  • head (see top 10 lines)

  • tail (see last 10 lines)

  • sort (display in Alphabetic/Numeric order)

  • /tar (to pack)

  • wget (to download)

File/Directory Permissions:

  • chmod (change permissions)

  • chown (owner)

  • chgrp (group)

  • hostname (to see hostname)

  • ifconfig (to get an IP address)

  • apt get install name (to install package)

  • which (to see whether the package is installed or not)

  • sudo (to get root privileges)

  • whoami (to see user)

  • find -type f (to see all files in the current directory)

  • find -type d (to see all directories in the current directory)

  • find / -type f (to see all files under the top-level root directory)

  • find / -type d (to see all directories under the top-level root directory)

  • find / -type f -name <file_name> (to search specific file under top-level root directory)

  • find / -type d -name <dir_name> (to search specific dir under top-level root directory)

User Commands

  • adduser <newuser> (Adding a User if signed in as the root user)

  • sudo adduser <newuser> (Adding a User if you not signed in as the root user)

  • sudo passed <username> (To change a specific user’s password)

  • su <username> (command stands for substitute user, and it is mostly used for switching from one user to another)

  • su -l <username> (the logged-in user can run all system commands.)

Task:

Check your present working directory.

$ pwd

List all the files or directories including hidden files.

$ ls -a

Create a nested directory A/B/C/D/E

$mkdir -p A/B/C/D/E

Flag -p is short for --parents - it creates the entire directory tree up to the given directory.