Saturday, 23 February 2019

LINUX


Chapter 1

What is Linux?


For premium DevOps and AWS Courses: https://imojo.in/2cox7em
  1. AWS with the project 
  2. DevOps Real-Time 
  3. DevOps with the project 
  4. AWS Real-Time
  5. Linux Admin


Linux is the best-known and most-used open source operating system. As an operating system, Linux is software that sits underneath all of the other software on a computer, receiving requests from those programs and relaying these requests to the computer’s hardware.



Some important directories:



  •         /bin : All the executable binary programs (file) required during booting, repairing, files required to run into single-user-mode, and other important, basic commands viz.catdudftarrpmwc, history, etc.


  •         /boot : Holds important files during boot-up process, including Linux Kernel.


  •         /dev : Contains device files for all the hardware devices on the machine e.g., cdromcpu, etc

  •                  /etc : Contains Application’s configuration files, startup, shutdown, start, stop script for every individual program

  • /opt : Optional is abbreviated as opt. Contains third party application software. Viz., Java, etc.



  • /sbin : Contains binary executable programs, required by System Administrator, for Maintenance. Viz., iptablesfdiskifconfig, swapon, reboot, etc.

  • /usr : Contains executable binariesdocumentationsource codelibraries for second level program.



  • /var : Stands for variable. The contents of this file is expected to grow. This directory contains loglockspoolmail and temp files.






Chapter 2

Basic Commands



·       ls , ls –lt , ls –lr , ls –ld

·       cd, cd /home/ , cd .. , cd –

·       pwd

·       touch, view , more, cat , head ,tail

·       cp, mv, diff

·       df –h, du –h

·       find / -name *file*

·       grep, awk , xargs

·       chmod, chown

·       mkdir, rm –r

·       telnet



Chapter 3

Diff btw su and sudo


Linux System is much secured than any of its counterpart. One of the way to implement security in Linux is the user management policy and user permission and normal users are not authorized to perform any system operations.



If a normal user needs to perform any system wide changes he needs to use either ‘su‘ or ‘sudo‘ command.


su – need root passwd
sudo – execute system commands without root passwd



Entry in /usr/sbin/visudo file is needed in order to run the command.
%addm,%gbladdmgrp ALL=(root) NOPASSWD: /bin/netstat




Chapter 4

Network Interface



#cd /etc/sysconfig/network-scripts/
# more ifcfg-enp0s3
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s3
DEVICE=enp0s3
ONBOOT=yes
HWADDR=08:00:27:d3:46:62
NM_CONTROLLED=no



# more ifcfg-enp0s8
TYPE=Ethernet
BOOTPROTO=static
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=enp0s8
UUID=316eed70-31ca-41c3-abdc-519d695682b4
DEVICE=enp0s8
ONBOOT=yes
GATEWAY=192.168.56.1
NETMASK=255.255.255.0
NETWORK=192.168.56.0





Chapter 5

Package Management



YUM:

1. Install a Package
#yum install firefox

2. Removing a Package
#yum remove firefox

3. Updating a Package
#yum update firefox

4. List a Package
#yum list openssh


5. Search for a package
#yum search firefox

6. Get info
#yum info firefox

7. list all installed packages
#yum list installed

8.Package containing file
#yum provides /etc/httpd/conf/httpd.conf

9. Check available updates
#yum check-update

10.Update system
#yum update

11. List enabled repositories
#yum repolist
#yum repolist all ( enabled and disabled)




Chapter 6

Increase the Swap Space


#dd if=/dev/zero of=/swapfile count=500 bs=1MiB
#chmod 0600 /swapfile
#mkswap /swapfile
#swapon
#swapon /swapfile
#swapon -s
#free -m

Above step is for other file system type not for ext4, for ext4 follow below
Instead of dd use
#fallocate -l 500MB /swapfile








Chapter 7

Netstat Command


To find process listening on a particular Port

# netstat -tulpn