Sunday, 22 September 2019

INSTALL JAVA 8 AND TOMCAT 7 IN A AWS EC2 RHEL INSTANCE?

login as: ec2-user
Authenticating with public key "imported-openssh-key"
Last login: Mon Mar 18 06:11:11 2019 from 183.82.115.14
[ec2-user@ip-172-31-33-91 ~]$ sudo -i
[root@ip-172-31-33-91 ~]# ls





    cd /opt/
    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz"
    yum install wget -y
    wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "https://download.oracle.com/otn-pub/java/jdk/8u201-b09/42970487e3af4f5aa5bca3f542482c60/jdk-8u201-linux-x64.tar.gz"
    tar xzf jdk-8u201-linux-x64.tar.gz
    cd jdk1.8.0_201/
    alternatives --install /usr/bin/java java /opt/jdk1.8.0_201/bin/java 2
    alternatives --config java
    alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_201/bin/jar 2
    alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_201/bin/javac 2
    alternatives --set jar /opt/jdk1.8.0_201/bin/jar
    alternatives --set javac /opt/jdk1.8.0_201/bin/javac
    export JAVA_HOME=/opt/jdk1.8.0_201
    export JRE_HOME=/opt/jdk1.8.0_201/jre
    export PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/bin
    clear
    cd ..
    java --version


If PATH didnt set properly use this lines

    javexport JAVA_HOME=/opt/jdk1.8.0_201
    export JRE_HOME=/opt/jdk1.8.0_201/jre
    export PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/binexport                     
    JAVA_HOME=/opt/jdk1.8.0_201
    export JRE_HOME=/opt/jdk1.8.0_201/jre
    export PATH=$PATH:/opt/jdk1.8.0_201/bin:/opt/jdk1.8.0_201/jre/bina
    java -version
 
 
 
TOMCAT 7 Installation 
 
    wget http://mirrors.wuchna.com/apachemirrer/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-                  7.0.92.zip
    yum install wget -y
    wget http://mirrors.wuchna.com/apachemirrer/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-                  7.0.92.zip
    cd /tmp
    wget http://www-us.apache.org/dist/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz
    cd ..
    cd /opt
    wget http://mirrors.estointernet.in/apache/tomcat/tomcat-7/v7.0.93/bin/apache-tomcat-                         7.0.93.zip
    ls
    unzip apache-tomcat-7.0.93.zip
    yum install unzip
    unzip apache-tomcat-7.0.93.zip
    ls
    cd apache-tomcat-7.0.93
    ls
    cd lib
    ls
    chmod 777 startup.sh
    chmod 777 catalina.sh
    sh startup.sh
    ls
    clear
    ls
    cd /opt/apache-tomcat-7.0.93
    vi conf/tomcat-users.xml

In tomcat-users.xml paste this lines to get


<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="manager-gui"/>
  <role rolename="manager-script"/>
  <role rolename="manager-jmx"/>
  <role rolename="manager-status"/>
  <role rolename="admin-gui"/>
  <role rolename="admin-script"/>
  <user username="admin" password="admin" roles="manager-gui, manager-script, manager-jmx,           manager-status, admin-gui, admin-script"/>
</tomcat-users>

wq!

chmod 777 conf/tomcat-users.xml
cd bin

sh startup.sh
sh shutdown.sh
sh startup.sh

Saturday, 14 September 2019

PYTHON

Python :-

1. High-level programming languages are close to business problems.
Whereas low-level programming languages are close to system's problems.
Example of high-level programming languages: Python, Java, c#, Rube etc.
Low-level Programming languages: C, Assembly programming languages etc..
A high-level programming language makes the process of translating business requirements to computerized solutions faster than low-level languages.

2. Interpreted
    Python is interpreted programming language. Code which is written in english, has to be translated to binary code and understood by a computer. This is the process of translation.
There are two types of translations
1. Compilation. 
2. Interpretation.
In compilation a compiler translates all the lines of code at the same time then starts the execution. In interpretation an interpreter takes the first line, translates to machine code and executes, then takes the second line and so on.

3. Multi-purpose  :-
Python can be used for developing multiple application types. Web Applications using django, flask Data analysis using pandas, numpy, bokeh Devops Automation using boto Embedded apps using raspberry pi API Deeplearning using google's Tensorflow API

4. Not just a scripting language Python is a general purpose language. One can use python as a scripting language or as a programming language, the puspose for which we use different. In automation field, python programming is called as scripting. And in application development side, it is called programming. In both cases, a single set of python keywords and constructs are used. As a computer language there is no difference between scripting and Programming in python.

5. Extensible :- 
High-level languages are not performant, because they are more focused to provide developer friendly environment than optimizing for speed.     In real-time and time-critical applications, when performance required, we still have to consider languages with low-level features, like C and C++. Python provides futures required to merge other programming languages with python code. Java code can be used in python using 'jython', C# code can be accessed using 'IronPython'.

6. Multi paradigm  :-
Python welcomes programmers from various backgrounds, as python supports procedural, functional and object oriented programming styles.
Software Installation All the code examples in this book, are developed and tested using cutting edge tools, jupyter notebook and PyCharm IDE.


Variables:-
varaibles are place holders for values. Variables are for identification. Variables make things reusable. If we define variables, we do not need to change entire expression, instead change the values assigned to variables.






























Docker commands

1.  When do you use Docker?
     
  • For replicating the environment on your server, while running your code locally on your laptop
  • For Docker CI/CD during numerous development phases (dev/test/QA)
  • For distributing your app’s OS with a team, and as a version control system.
2.  How do you setup a docker locally?

      Download a Docker edition and the Docker Toolbox

  • Make sure your BIOS has Virtualization Technologies, AMD-V, or KVM enabled
  • Install the Extension Pack in the Oracle Virtual Box and Run the Setup.
3.  How Do You Use a Docker?

  • The biggest advantage of VMs is that they create snapshots which can be revisited instantly later. Docker containers further enhance the lightweight process virtualization by being OS independent and using the Linux Kernel’s functionality. They are created from Docker images – like snapshots. Docker images are created using a Docker file which can be customized or used as is. The default execution driver for creating a docker container is ‘libcontainer’.  Docker Hub can be used for searching docker images and seeing the way they have been built.
    • To create a Docker container, download the ‘hello world’ image, by typing the following command in the terminal –
    $ docker run hello world
    • For checking the number of images on your system, use the following command –
    $ docker images
    • For searching an image in the Docker Hub –
    $ docker search <image>

    4The base commands used for the Docker CLI.

    • docker run             -         Runs a command in a new container.
    • docker start           -         Starts one or more stopped containers
    • docker stop           -         Stops one or more running containers
    • docker build          -        Builds an image form a Docker file
    • docker builder       -        Manage Builds
    • docker pull            -        Pulls an image or a repository from a registry
    • docker push           -       Pushes an image or a repository to a registry
    • docker export        -       Exports a container’s file system as a tar archive
    • docker exec           -       Runs a command in a run-time container
    • docker search        -       Searches the Docker Hub for images
    • docker attach         -      Attaches to a running container
    • docker commit      -      Creates a new image from a container’s changes
    • docker checkpoint   -    Manage checkpoints
    • docker configs         -    Manage Docker configs
          docker info              -     Display system-wide information
          docker export          -     Export a container’s filesystem as a tar archive
            docker kill               -     kill one or more running containers







Thursday, 12 September 2019

ED, EX, VI EDITORS FOR LINUX

Three editors available in almost all versions of unix.
There are  :
                  1. ed editor
                  2. ex editor
                  3. vi  editor
ed editor  :-
               The ed program is basically a line editor, which means that ed assigns line numbers to lines                  in the file;  every time you do something, you must tell ed which line or lines to do it to.

ex editor :-
               An improved version of ed, called ex, understands all the commands of ed.
               Compared to ed it is shade better in  user_friendliness with more informative errors                             messages.

vi editor :-
               Compared to ed or ex the vi text editor is head and shoulders above them in almost every                     way. It is a screen editor rather than a line editor; it shows you as much of the file as it can                   fit on the screen. Vi is case-sensitive. Vi is available on almost all unix systems.

Modes of operation :-

The vi program has three modes of operation :

1). Command Mode :
              This is the default mode. In this mode all the keys pressed by the user are interpreted to be                  editor commands.

2). Insert Mode :
               This mode permits insertion of new text, editing of existing text or replacement of existing                   text.

3). The ex Command Mode :
                 This mode permits us to give commands at the command line. The bottom line of the vi screen is called the command line. Vi uses the command line to display messages and commands.
All commands entered in the ex command mode are displayed in the command line. This mode is so called because commands given in this mode are compatible with the commands of the ex editor.        
COMMAND MODE COMMANDS    

Commands for to shift command mode into insert mode.

COMMAND                         FUNCTION
         A                 -----           It places cursor at end of the current line.
         a                  -----           It places cursor right side of the current line.
         I                  -----           It places cursor at beginning of the current position.
         i                  -----           It places cursor left side of the cursor position.
         o                 -----           Enters text input mode by opening a new line immediately below                                                            the current line.
        O                 -----           Enters text input mode by opening a new line immediately above the                                                      current line.
        R                 -----           Enters text input mode and over writes from current cursor position.

To edit your text, you need to move the cursor to the point on the screen where you will begin the correction. This is easily done with four keys h, j, k and l.

        h                                    moves the cursor one character to the left.
        I                                     moves the cursor one character to the left.
        j                                     moves the cursor down on line.
        k                                    moves the cursor up on line.

POSITIONING BY CHARACTER

Command
Function
h
Moves the cursor one character to the left.
Backspace
Moves the cursor one character to the left.
L
Moves the cursor one character to the right.
Space bar
Moves the cursor one character to the right.
0
Moves the cursor to the beginning of the current line.
$
Moves the cursor to the end of the current line.


Positioning by line
Command
Function
j
Moves the cursor down one line from it’s present position, in the same coloumn.
k
Moves the cursor up one line from it’s present position, in the same direction.
+
Moves the cursor down to the begging of next line.
-
Moves the cursor upto the beginning of previous line.
Enter
Moves the cursor down to the begging of the next line..

Positioning by word
Command
Function
w
Moves the cursor to the right, to the first character of the next word.
b
Moves the cursor back to the first character of the previous word.
e
Moves the cursor down to the end of the current word.

Positioning by window
Command
Function
H
Moves the cursor to the first line on the screen, or “home”.
M
Moves the cursor back to the middle line on the screen.
L
Moves the cursor to the last line on the screen.



Commands for positioning in the File
Scrolling
Command
Function
Ctrl f
Scrolls the screen forward a full window, revealing the window of text below the current window
Ctrl b
Scrolls the screen back a full window, revealing the window of text above the current window


Commands for deleting text
Command
Function
x
Deletes the character at current cursor position.
X
Deletes the character to the left of the cursor.
dw
Deletes a word (or part of word) from the cursor to the next space or to the next punctuation.
dd
Deletes the current line
nx, ndw, ndd
Deletes  n characters, n words or n lines
d0
Deletes the current line from the cursor to the beginning of the line.
d$
Deletes the current line from the cursor to the end of the line.


Commands for copying and paste text
Command
Function
yw
Y anks word from cursor position.
yy
Y anks line from cursor position.
y$
Y anks line from cursor position of line.
y0
Y anks line from cursor position to beginning of line.
p
Paste last yanked buffer

Commands for Quitting vi

Command
Function
ZZ
Writes the buffer to the file and quits vi
:wq
Writes the buffer to the file and quits vi
:w filename
And :q
Writes the buffer to the file (new) and quits vi
:w! filename and :q
Over writes the existing file filename with the contents of the buffer and quits vi.
:q!
Quits vi whether or not changes made to the buffer were written to file. Does not incorporate changes made to the buffer and quits vi.
:q
Quits vi changes made to the buffer were written to a file.
:set nu
Setting line numbers for file
:set nonu
Removing line numbers




























Tuesday, 10 September 2019

PERMISSIONS FOR FILES IN LINUX

PERMISSIONS FOR FILES AND DIRECTORIES IN LINUX :

PERMISSIONS FOR FILES :-
            There are three classes of file permissions for the three classes of users :
1. The owner( or user) of the file
2. The group the file belongs to, and all other users of the system.

$ls -l
-rwxr-xr--

The first three letters of the permissions field refer to the owner's permissions
      rwx --- owner can have the read , write, execute the file.
The second three to the members of the file's group and the last to any other users.
The  second group of of three characters, r-x, indicates that members of the group can read and execute the file but cannot write it, The last three characters, r-x, show that all others can read and execute  the file but not write to it.
If you have read permission for a file, you view its contents. Write permission means that you can alter its contents. Execute permission means that you can the file as program.

PERMISSIONS FOR DIRECTORIES :
     For directories, read permission allows users to list the contents of the directory, write permission allows users to create or remove files or directories inside that directory, and execute permission allows users to change to this directory using the cd command or use it as part of a path name.           


CHANGING FILE PERMISSION

chmod is the command to change file permission's or directory permission's.

Syntax
               $chmod [who] [+/-/=] [permissons] filename
In using, first specify which permissions you are changing, second specify how should be changed, Third, specify the file permission type :
                       
                 u for user or owner
                 g for group
                 o for others

                  +    for to add permission
                  -     for to substract permission
                  =     for to assign permission (i.e., add specified permission and take away all other                                     permissions, if present)

                  r for to read
                  w for write
                  x for to execute

                  Eg :- add write permission to group members on devops file
                           $ chmod g+w devops

                   Eg :- add execute permission to others and owner on devops_team file
                            $ chmod u+x, o+x devops_team
                             or
                            $ chmod o=r,g-w devops_team

Another form of the chmod command lets you set permissions directly, by using a numeric(octal) code to specify them .
               This code represents a file's permissions, by three octal digits: one for owner permissions, one for group permissions, and one for others. These three digits appear together as one three- digit number.


                                        PERMISSION                      WEIGHT
                                                Read                                     4
                                                 write                                    2
                                                 Execute                               1
                                                 Read and write                    6
                                                 Write and execute               3
                                                 Read and execute                5
                                                 Read, Write and execute     7
           
Eg :-
         $ chmod 700 devops_team
          The above command sets read, write and execute permissions for the owner only and allows no one else to do anything with the devops_team file.


Eg :-
         $chmod 754 devops_team
           The above command sets all permisions for owner and sets only read and execute to group and sets only read permission to others on devops_team file.

































































                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

Monday, 9 September 2019

BASIC COMMANDS OF LINUX

BASIC COMMANDS OF LINUX :

1. $logname   :   It displays the current user name.

2. $pwd          :   It displays the current working directory.

3. $clear         :   It clear the screen.

4. $exit           :   To logout from the current user.

5. $date          :   It displays system date & time.
                            Sat   Mar    4     04:40:10    IST     2005

6. $Who am i :   It displays the current user name, terminal number, date and time at which                                            you logged into the system.
                                                 tecno    ty01    mar   4    09:30

7. $Who         :   To display the information about all the users who have logged into the system                                      currently. i.e. each user login name, terminal number, date and time that the                                          person logged in.
                                 loginname        terminal name        date                time
                                  tecno1                tty01                       mar 4             09:30
                                  tecno2                tty03                       mar 4             10:30
                                  tecno2                tty06                       mar 4             10:40
8. $finger       :    It displays complete information about all the users who are logged in.

9. $cal            :    It displays previous month, current month and next month calender.

10. $cal year  :    It display the given year calender.
                             e.g:- $cal 2005 = It takes year from 1 to 9999

11. $cal month year :  It display the given month calender only.
                                      $cal 3 2005 enter

12. #init          :   To change system run levels.

      1. #init 0   :   To shut down the system.

      2. #init 1   :   To bring the system to single user mode.

      3. #init 2   :    To bring the system to multi user mode with no resource shared.

      4. #init 3   :    To bring the system multi user mode with source shared.

      5. #init 6   :    Halt and reboot the system to default run level.

13. $ banner "tecno"  :  It prints a message in large letters.
--------------------------------------------------------------------------------------------------------------------------

CREATING FILES :

There are two commands to create files : touch and cat

1. $ Touch filename : It creates zero byte file size.
     Eg :- $ touch sample
        Touch does not allow you to store anything in a file. It is used to create several empty files                  quickly.

Eg :- $ touch file1 file2 file3 file4 file5

2. $ Cat command 
  Syntax
               1. $ cat > filename
                         e.g : $ cat > sample 
                                  -------------------
                                  ---------------------
                                  ------------------------
                                  ctrl + d ( To clase a file)

                2. $ cat >> sample (To oppened data to the file)
                 -------------------------
                 --------------------------- 
                 --------------------------------
                 Ctrl + d
                 
                 3. $ cat file1 file2 file3 > file4
                      This would create file4 contains contents of file1 followed by file2 and followed by that of file3.
                      It concatenates file1, file2, and file3 contents and redirects to file4. If file4 already contains something it woud be over written.

3. $ cat < filename or $ cat file name
      Eg :- $ cat sample                                                                                                                                              It displays sample file contents.
                  Eg :- $cat file1 file2 file3
                  It displays file1 contents followed by file2 then followed by file3
--------------------------------------------------------------------------------------------------------------------------

REMOVING FILES :-                                                                                                                             1. rm command :  To remove the given file.

Syntax
           $rm filename
           $rm sample   :  It removes sample file.
           $rm -i filename : It asks confirmation before deleting the file.
           $rm -i sample 
                  remove sample? y - It removes sample file.
                                              n - It won't remove
$ rm file1 file2 file3   :  It removes three files.
$ rm* : It removes all files in current directory.

--------------------------------------------------------------------------------------------------------------------------

CREATING DIRECTORY :-

1. mkdir Command :-  
      To make directory
    Syntax :     
                  $ mkdir directory name
                     Eg :- mkdir devops
2. Creating multiple directories 
                $mkdir dir1 dir2 dir3 ..................dirn
--------------------------------------------------------------------------------------------------------------------------

Change directory  :

Syntax: 
             $cd directory name
             $cd techin
             $pwd
              /usr/tecno/techin

$cd ..  :  To change into parent directory.
$cd\    :  To change to root directory.
--------------------------------------------------------------------------------------------------------------------------

Remove Directory  :

1.  $rmdir directoryname : To delete a directory but directory should be empty.
2.  $rm -r directoryname  :  It removes all files and sub directories, sub directory files                                                                  including  directory.
--------------------------------------------------------------------------------------------------------------------------
Copy a file:-
$cp file1 file2   :    This will copy the contents of file1 into a file2.  If file2 is already existed it                                           overwrites.
$cp -i file1 file2   :   If file2 is already existed then it asks the confirmation.
                                  Eg :- cp -i sample1 sample2
                                            overwrite sample2?
--------------------------------------------------------------------------------------------------------------------------

Rename a file :
     1. $mv old filename new filename   :   To rename the file.
--------------------------------------------------------------------------------------------------------------------------

Comparision of files  : 

1. $cmp file1 file2    :   It compares file1 and file2. If both file contents are same number output if files are different then it displays line number and number and character location.
--------------------------------------------------------------------------------------------------------------------------
























































































Streamlining the usage of GITHUB

Streamlining the usage of Github with Commands 1. Start a new git repository under one directory locally In this step, we need to bui...