Linux Learnings

Linux Learnings

Linux is an open source Operating system. Its lightweight (System requirements for running it is less than other OS), provides high performance, stability & is very flexible.

2 Types of commands in linux -

  1. Internal / Built - in commands - They are part of the shell itself, & come bundled with it. Eg. echo, cd, pwd, set, etc.

  2. External commands - They're binary programs / scripts which are usually located in distinct files in the system. They either come pre-installed with the distributions package manager or can be created or installed by the user.

  3. To determine if the command is Internal / External use the type command. ( type )

Commands

To know about various linux commands refer to this Blog - Linux Commands

Kernel

Its the core interface between computer hardware & its processes. It communicates between 2 managing resources as efficiently as possible.

Its responsibilities are Memory & Process management. ( Memory -> Keep track of how much memory is used to store what & where. ) ( Process -> Determine which processes can use the CPU when, & how long. )

To get info about kernel -> uname -i

Files

To create a file use commands -> cat, touch.

To edit a file use editors -> vim, nano.

To view size of a file use commands -> du -sk OR ls -lh OR du -sh ( Here sk -> size in kilobytes, sh -> size in human readable format)

To search a file use commands -> locate OR find

Package Manager

First things first, what 's a Package?

-> Package is a compressed archive that contains all the files that are required by our particular software to run.

Now what 's a Package Manager?

-> Package Manager is a software in a linux system that provides a consistent & automated process of installing, upgrading, configuring & removing packages from the OS.

Package Manager features -

  1. Ensuring integrity & authenticity of a package, by verifying their original certificates & checksums.

  2. Grouping packages by function to reduce user confusion.

  3. Managing dependencies to ensure a package is installed with all packages it requires, thus avoiding what is dependency hell.

rpm vs yum

rpm (Red Hat Package Manager) - It does not resolve package dependencies on its own, this is why we use a higher - level package manager called yum.

yum (Yellow dog Updater Modifier) - Open source package manager, provides dependency management, automatic updates, easy package management.

Partitions

The entire Hard disk can be broken down into smaller segments of usable space called partitions. We can use each partition for a specific purpose.

To see partition info -> lsblk OR fdisk

3 Types of Partitions -

  1. Primary - Used to boot the OS.

  2. Extended - Host logical Partitions. Its like a disk drive which has its own partition table pointing to 1 or more logical partitions.

  3. Logical - Created within an extended partition.

MBR & GPT

Master Boot Record (MBR) partitioning scheme - Allows only 4 primary partitions. Maximum size per disk -> 4 TB.

GUID Partitioning Scheme (GPT) - Latest partitioning scheme to overcome limitations in MBR.

GPT allows unlimited no. of partitions per disk. (Only limited by restrictions set by the OS, Eg. RHEL only allows 128 partitions per disk). No maximum size per disk set here like in MBR.

Cron

Cron is a service which allows us to schedule tasks & do automation.

crontab - Files which has set of commands to be executed.

cron.webp

To see list of crontab active -> crontab -l (Here time is according to UTC & no other timezone)

SSH

Secure Shell (SSH) protocol uses encryption to secure the connection between a client & a server.

Note :- The remote server / machine you're logging into should have SSHD / open SSH daemon, which listens for SSH connections.

ssh.png

To ssh into AWS EC2 instance from your linux machine then use -> ssh -i amiName@publicIp4 DNS.

-i -> Identity file

aws ec2 instance public ip is changed when we restart it, so we use public ip4 dns.