Tuesday, July 28, 2020

ShellScript Examples - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 


File Name: userCreation.sh

##############################################################################################
#Purpose : This Script is to create a user and add it to devops group and set the  password.
#Author: Mithun Reddy Lacchannagari
#Date Created : June 24th 2010
##############################################################################################

clear
echo "Please enter the user name for the account you want to create!"
read userName
echo "The name you entered is: "  $userName
/usr/sbin/useradd   $userName
/usr/sbin/usermod -G devops $userName
echo ".......User is created..........."
echo ".......Now Set the password for  ....... $userName"
passwd $userName
---------------------------------------------------------------------------------------------------------------------------
File Name: createUser.sh

##############################################################################################
#Purpose : This Script is to create a user , set the  password add it into sudoers file.
#Author: Mithun Reddy Lacchannagari
#Date Created : June 24th 2010
##############################################################################################


#!/usr/bin/env bash

if [ $# -ne 1 ]
then
  echo "Usage: $0  username"
  exit
else
  USERNAME=$1
fi

# creating user
/usr/sbin/useradd $USERNAME
passwd $USERNAME

echo "User has created successfully.."
echo "Providing sudo access.."

# Giving sudo access
sed -i "/NOPASSWD/a\\$USERNAME ALL=(ALL)       NOPASSWD: ALL" /etc/sudoers

echo "Sudo access provided successfully.."




Wednesday, July 15, 2020

Grafana Installation - Linux RHEl - 8 - Mithun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Grafana Installation

#Login as a root user
sudo su -

#Create file called grafana.repo in /etc/yum.repos.d directory and add the below content.
vi /etc/yum.repos.d/grafana.repo

[grafana]
name=grafana
baseurl=https://packages.grafana.com/oss/rpm
repo_gpgcheck=1
enabled=1
gpgcheck=1
gpgkey=https://packages.grafana.com/gpg.key
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt

#Install the grafana.
yum install grafana -y

#Enable the grafana-server service.
systemctl daemon-reload

systemctl enable grafana-server

#Start the grafana-server service.
systemctl start grafana-server

#Check  the grafana-server service status.
service grafana-server status


Troubleshooting
---------------------
Unable to access Grafana URL?
----------------------------------------
https:<<IP Address>>:3000/

Deafult Credentails
User Name: admin
Password:  admin

a)make sure port 3000 is opened in security groups in AWS ec2 instance.

Docker Commands - Mitun Technologies - 9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 
Docker Commands

docker info: It will give status of weather docker is running or not  and also It will display the detailed information about docker engine. 

docker version: Show the Docker version information.

docker images (OR) docker image ls : List all images that are locally stored with the Docker engine.

docker run <<Docker Image>> : It will run the docker image.

Example: docker run hello-world: This command will download the hello-world image, if it is not already present, and run the hello-world as a container.

docker images <<Image Name>>: It will display the information about image.

docker images -q: It will display only the images IDs.

docker rmi << Image ID/Image Name>> (OR) docker image rm << Image ID/Image Name>>: It will delete an image from the local image store.
Example: docker rmi nginx

docker rmi $(docker images -q) (OR) docker rmi -f $(docker images -q) : It will remove all the images from docker engine.

docker run --name “hello-world-container” helloworld: Start the hello-world image with “hello- world-container” container name. 

docker create “hello-world-cont” helloworld : It will create a container called “hello-world-cont” from the image hello-world and it won’t start the container.

docker ps (OR) docker container ls: Lists running containers
(It will not display the stopped containers)

docker ps –a (OR) docker container ls --all (OR) docker container -a: Lists all containers (It will display the stopped containers along with running containers.)
                                                    
docker start <Container name|id>: It will start the container.

docker start webserver: It will start the webserver.

docker stop <container name|id> (OR) docker container stop <container name|id>: It will stop the docker container.

docker stop webserver: It will stop the container called webserver.

docker pause CID/CNAME: It will pause the container.

docker unpause CID/CNAME: It will unpause the container.

Docker Container status are, created, restarting, running, removing, paused, exited, or dead

docker ps -a --filter "name=mithun16thjune": It will display all the containers with name mithun16thjune name.

docker ps -a --filter 'exited=0' :

docker ps --filter status=running: It will display the all the running state containers.

docker ps --filter status=paused: It will display the all the paused state containers.

docker logs <container name>: It will display the logs for that container.

docker logs --tail 100 <<Container Name>>: Print the last 100 lines of a container’s logs.

docker top <<Container ID>>: This will shows the top processes in within in a container.

docker reanme <<Container Old Name>> <<Container New Name>>: It will rename the conatiner.

docker rm -f <<Container Name>>: It will remove the container.

docker rm -f webserver: It will stop and remove the running container with a single command.

docker stop $(docker ps -a -q): It will stop all the containers.

docker rm -f $(docker ps -aq): Delete all running and stopped containers.

docker kill <<CID/C Name>>: It will kill the container.

docker container prune: It will delete all stopped containers.

docker search <<Image Name>>: It will search all of the publicly available images on Docker
Hub(https://hub.docker.com).

docker pull <<Image Name>: Pull an image from Docker Hub

docker inspect <<CID>> : It will give information for container.

docker attach <<CID>> : It will connect to running container.

docker exec <<CID>> : Run a linux command in a running container.

docker stats <<CID>> : It will display a live stream of container resource usage statics.

docker network ls: List the networks.

docker network create mithuntechnologies : It will create the network with name called as mithuntechnologies.

docker network inspect bridge: Display detailed information on one or more networks.

docker network connect: Connect a container to a network.

docker network prune: Remove all unused networks.

docker run -it -v /Users/mithunreddyl/Desktop/dockervolumes:/mithuntechnoVol1 ubuntu : Create a container with volume mithuntechnoVol1.


docker run -it -v /Users/mithunreddyl/Desktop/dockervolumes:/mithuntechnoVol1:ro --name ubuntucontainer16 ubuntu : Create the Read only Volume.


docker run -it --volumes-from ubuntucontainer16 --name ubuntucontainer1604 ubuntu:16.04:
Create a container ubuntucontainer1604 that uses the same volumes as ubuntucontainer16

Can I mount same volume to multiple docker containers?
Ans) Yes you can add same location as a volume to many docker containers.

docker login: To sign into the Docker Hub.

docker logout: To logout from the Docker Hub. If no server is specified, then the default is used.


Saturday, July 11, 2020

Package Management in Linux (RHEL) using yum (Yellowdog Updater, Modified) - Mithun Technologies - +91-9980923226

Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com

                                                       http://mithuntechnologies.com/
                                                       http://mithuntechnologies.co.in/ 

The package management is a method of installing,updating,removing software on the system.

In RedHat Linux Distribution we can use yum command for installing, updating and removing the software.

Note: yum command need to execute as a root user or with sudo access.

Install a Package with YUM

To install a package any, use below command syntax.

Syntax: yum install <<package name>>
Example: yum install tree

The above command will ask confirmation before installing any package on your system. If you want to install packages automatically without asking any confirmation, use option -y as shown in below example.

Syntax: yum install <<package name>> -y
Example: yum install vim -y
We can install multiple packages with separated by space for each package name as follows.

#yum install zip unzip tar -y

Updating a Package using YUM
Using yum command we can update the package as follows.

Syntax: yum update <<package name>> -y
Example: yum update tree -y

UN-Install /Remove a Package using YUM
Using yum command we can uninstall the package as follows.

Syntax: yum remove <<package name>> -y
Example: yum remove tree -y

Get Information of a Package using YUM
Using yum command we can get the package information as follows.

Syntax: yum info <<package name>>
Example: yum info tree

List all Available Packages using YUM

To display all the package which are available in yum repository, use the below command.

#yum list

List all Installed Packages using YUM

To display all the package which are installed in Linux server, use the below command.

#yum list installed

Check for Available Updates using Yum

To find how many of installed packages on your system have updates available, to check use the following command.

#yum check-update

Update System using Yum

To keep your system up-to-date with all package updates, run the following command. It will install all latest patches and security updates to your system.

#yum update

List all available Group Packages

In Linux, number of packages are bundled to particular group. Instead of installing individual packages with yum, you can install particular group that will install all the related packages that belongs to the group. For example to list all the available groups, just issue following command.

#yum grouplist

Install a Group Packages

To install a particular package group, we use option  groupinstall as follows.

#yum groupinstall 'Development Tools'

To know how many packages are available in particular group, execute the below command.

#yum groupinfo 'Development Tools': Here Development Tools is a group name.

Update a Group Packages

To update any existing installed group packages, just run the following command as shown below.

#yum groupupdate 'Development Tools'

Remove a Group Packages

To delete or remove any existing installed group from the system, just use below command.

#yum groupremove 'Development Tools'



Ansible Installation in Amazon Linux - Mithun Technologies - 9980923226

  Mithun Technologies            +91-9980923226              devopstrainingblr@gmail.com                                                 ...