Friday 30 August 2019

How to install P4Merge by Raj Gupta

Download and install it after that add the path(C:\Program Files\Perforce) to environment variable so that it can accessible from any where

https://www.perforce.com/downloads/visual-merge-tool


After setting path in environment variable when you give below command then it will open p4Merge


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ p4merge





Now do the below configuration to use with git

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global merge.tool p4merge

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global mergetool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global mergetool.prompt false

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global diff.tool p4merge

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global difftool.p4merge.path "C:/Program Files/Perforce/p4merge.exe"

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ $ git config --global difftool.prompt false
bash: $: command not found

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global difftool.prompt false

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~
$ git config --global --list
user.name=Raj Gupta
user.email=rajkumargupta14@gmail.com
alias.hist=log --all --graph --decorate --oneline
merge.tool=p4merge
mergetool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
mergetool.prompt=false
diff.tool=p4merge
difftool.p4merge.path=C:/Program Files/Perforce/p4merge.exe
difftool.prompt=false



Thursday 29 August 2019

Cleanup and Back to Origin(GitHub) by Raj Gupta

After all changes we need to push the code to github

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git pull origin master
From https://github.com/rajkumargupta14/hello-world
 * branch            master     -> FETCH_HEAD
Already up to date.

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git push origin master
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 841 bytes | 210.00 KiB/s, done.
Total 9 (delta 4), reused 0 (delta 0)
remote: Resolving deltas: 100% (4/4), completed with 1 local object.
To https://github.com/rajkumargupta14/hello-world.git
   5e8e01d..8637d7a  master -> master

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)

Ignoring Unwanted files and folders in Git by Raj Gupta


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls -al
total 19
drwxr-xr-x 1 Administrator 197121    0 Aug 29 08:35 ./
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 ../
drwxr-xr-x 1 Administrator 197121    0 Aug 29 08:35 .git/
-rw-r--r-- 1 Administrator 197121  133 Aug 29 07:52 Dockerfile
-rw-r--r-- 1 Administrator 197121 5969 Aug 29 07:52 pom.xml
-rw-r--r-- 1 Administrator 197121   38 Aug 29 07:52 README.md
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 server/
-rw-r--r-- 1 Administrator 197121   29 Aug 29 08:35 start2.txt
drwxr-xr-x 1 Administrator 197121    0 Aug 29 07:52 webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi ramu.yyy

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  ramu.yyy  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        ramu.yyy

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ cat .gitignore
*.yyy

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .gitignore

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git add .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   .gitignore


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git commit .gitignore -m "ignore"
[master 8637d7a] ignore
 1 file changed, 1 insertion(+)
 create mode 100644 .gitignore

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$

Git Alias by Raj Gupta


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log --all --graph --decorate --oneline
* 805a6ac (HEAD -> master) Deleting new file
* 2678aa7 test
* e144111 rename the file
* 5e8e01d (origin/master, origin/HEAD) Adding start test file
* 977ca2d Initial commit
* 34b2c44 updated file
* 0425ad1 update2
* d8113f6 new line added
* a29c62b modified index.jsp
* a99e804 Update index.jsp
* 57a67c2 Update index.jsp
* e18726d Update index.jsp
* 4a487a7 promotions comment
* 3a90027 Update index.jsp
* f3ccb36 Update index.jsp
* ad497a6 Update index.jsp
* 521d0fd modified index.jsp
* 73e663e modified index.jsp file for docker demo
* 691a7a2 modified index.jsp file
* 3e3afd8 Update Dockerfile
* 740736a Update Dockerfile
* 22e01c8 added docker file
* 1aa6466 Update index.jsp
* 5c693b0 latest code updated
* 7c81f41 Update index.jsp
* 4762ccd ansible added
* 9066612 new update
* 8127737 updated coc name
* 037bd4f updated index file
* 8d8c0b6 updated index file
* 5e95a23 Update index.jsp
* a25d199 new update on index.html
* 438be18 Update README.md
* 3b7bdcd initial commit
* 2047f57 Create README.md

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git hist
git: 'hist' is not a git command. See 'git --help'.

The most similar command is
        bisect

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git config --global alias.hist "log --all --graph --decorate --oneline"

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git hist
* 805a6ac (HEAD -> master) Deleting new file
* 2678aa7 test
* e144111 rename the file
* 5e8e01d (origin/master, origin/HEAD) Adding start test file
* 977ca2d Initial commit
* 34b2c44 updated file
* 0425ad1 update2
* d8113f6 new line added
* a29c62b modified index.jsp
* a99e804 Update index.jsp
* 57a67c2 Update index.jsp
* e18726d Update index.jsp
* 4a487a7 promotions comment
* 3a90027 Update index.jsp
* f3ccb36 Update index.jsp
* ad497a6 Update index.jsp
* 521d0fd modified index.jsp
* 73e663e modified index.jsp file for docker demo
* 691a7a2 modified index.jsp file
* 3e3afd8 Update Dockerfile
* 740736a Update Dockerfile
* 22e01c8 added docker file
* 1aa6466 Update index.jsp
* 5c693b0 latest code updated
* 7c81f41 Update index.jsp
* 4762ccd ansible added
* 9066612 new update
* 8127737 updated coc name
* 037bd4f updated index file
* 8d8c0b6 updated index file
* 5e95a23 Update index.jsp
* a25d199 new update on index.html
* 438be18 Update README.md
* 3b7bdcd initial commit
* 2047f57 Create README.md

This alias are saved in below file

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi ~/.gitconfig


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$

How to check history of Git by Raj Gupta


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git logs
git: 'logs' is not a git command. See 'git --help'.

The most similar command is
        log

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log
commit 805a6ac80a64923150a702334fc6260e3dad38ac (HEAD -> master)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:29:28 2019 +0000

    Deleting new file

commit 2678aa7022d33d2d65f6a9c115ed02fea09ddcaa
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:27:50 2019 +0000

    test

commit e14411148b83b15aab594e9f6bd005b868718d8a
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:01:25 2019 +0000

    rename the file

commit 5e8e01d997b76ef16b68db043099f7a99c151dbe (origin/master, origin/HEAD)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Fri Aug 23 11:27:00 2019 +0000

    Adding start test file

commit 977ca2dfcdb467fc73e69d8b18b9aafb39347d34
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Wed Jan 30 14:42:16 2019 +0530

    Initial commit

commit 34b2c4436021da9763d7eb891e76d5520ca444dd
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Fri Jan 25 15:37:24 2019 +0530

    updated file

commit 0425ad19e580b745d554a8f281fb5aadc5ebda55
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Mon Jan 14 20:07:27 2019 +0530

    update2

commit d8113f638d0b2aa813d93a7db3b3c28a3d2fe1e3
Author: root <root@ip-172-31-22-126.ap-southeast-1.compute.internal>
Date:   Tue Dec 25 06:47:49 2018 +0000

    new line added

commit a29c62b0253122f7e43e05d6af77af08c076f02c

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log --abbrev-commit
commit 805a6ac (HEAD -> master)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:29:28 2019 +0000

    Deleting new file

commit 2678aa7
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:27:50 2019 +0000

    test

commit e144111
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:01:25 2019 +0000

    rename the file

commit 5e8e01d (origin/master, origin/HEAD)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Fri Aug 23 11:27:00 2019 +0000

    Adding start test file

commit 977ca2d
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Wed Jan 30 14:42:16 2019 +0530

    Initial commit

commit 34b2c44
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Fri Jan 25 15:37:24 2019 +0530

    updated file

commit 0425ad1
Author: rajkumargupta14 <37054671+rajkumargupta14@users.noreply.github.com>
Date:   Mon Jan 14 20:07:27 2019 +0530

    update2

commit d8113f6
Author: root <root@ip-172-31-22-126.ap-southeast-1.compute.internal>
Date:   Tue Dec 25 06:47:49 2018 +0000

    new line added

commit a29c62b

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log --oneline --graph --decorate
* 805a6ac (HEAD -> master) Deleting new file
* 2678aa7 test
* e144111 rename the file
* 5e8e01d (origin/master, origin/HEAD) Adding start test file
* 977ca2d Initial commit
* 34b2c44 updated file
* 0425ad1 update2
* d8113f6 new line added
* a29c62b modified index.jsp
* a99e804 Update index.jsp
* 57a67c2 Update index.jsp
* e18726d Update index.jsp
* 4a487a7 promotions comment
* 3a90027 Update index.jsp
* f3ccb36 Update index.jsp
* ad497a6 Update index.jsp
* 521d0fd modified index.jsp
* 73e663e modified index.jsp file for docker demo
* 691a7a2 modified index.jsp file
* 3e3afd8 Update Dockerfile
* 740736a Update Dockerfile
* 22e01c8 added docker file
* 1aa6466 Update index.jsp
* 5c693b0 latest code updated
* 7c81f41 Update index.jsp
* 4762ccd ansible added
* 9066612 new update
* 8127737 updated coc name
* 037bd4f updated index file
* 8d8c0b6 updated index file
* 5e95a23 Update index.jsp
* a25d199 new update on index.html
* 438be18 Update README.md
* 3b7bdcd initial commit
* 2047f57 Create README.md

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log 805a6ac...e144111
commit 805a6ac80a64923150a702334fc6260e3dad38ac (HEAD -> master)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:29:28 2019 +0000

    Deleting new file

commit 2678aa7022d33d2d65f6a9c115ed02fea09ddcaa
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:27:50 2019 +0000

    test

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log --since="3 days ago"
commit 805a6ac80a64923150a702334fc6260e3dad38ac (HEAD -> master)
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:29:28 2019 +0000

    Deleting new file

commit 2678aa7022d33d2d65f6a9c115ed02fea09ddcaa
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:27:50 2019 +0000

    test

commit e14411148b83b15aab594e9f6bd005b868718d8a
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:01:25 2019 +0000

    rename the file

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git log -- start2.txt
commit e14411148b83b15aab594e9f6bd005b868718d8a
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:01:25 2019 +0000

    rename the file

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git show 2678aa7022d33d2d65f6a9c115ed02fea09ddcaa
commit 2678aa7022d33d2d65f6a9c115ed02fea09ddcaa
Author: Raj Gupta <rajkumargupta14@gmail.com>
Date:   Thu Aug 29 08:27:50 2019 +0000

    test

diff --git a/raj90.txt b/raj90.txt
new file mode 100644
index 0000000..876c72e
--- /dev/null
+++ b/raj90.txt
@@ -0,0 +1 @@
+This is test file.

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$

Deleting files in Git by Raj Gupta


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ vi raj90.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git ststus
git: 'ststus' is not a git command. See 'git --help'.

The most similar command is
        status

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        raj90.txt

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git add raj90.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   raj90.txt


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git rm raj90.txt
error: the following file has changes staged in the index:
    raj90.txt
(use --cached to keep the file, or -f to force removal)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  raj90.txt  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   raj90.txt


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git commit raj90.txt -m "test"
[master 2678aa7] test
 1 file changed, 1 insertion(+)
 create mode 100644 raj90.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git rm raj90.txt
rm 'raj90.txt'

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    raj90.txt


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git commit -m "Deleting new file"
[master 805a6ac] Deleting new file
 1 file changed, 1 deletion(-)
 delete mode 100644 raj90.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git rm stsrt2.txt
fatal: pathspec 'stsrt2.txt' did not match any files

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git rm start2.txt
rm 'start2.txt'

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        deleted:    start2.txt


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git reset HEAD start2.txt
Unstaged changes after reset:
D       start2.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    start2.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git checkout -- start2.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start2.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Adm

Renaming and Moving files in Git by Raj Gupta

Renaming file by using Git


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ cd level2/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$ cd level3/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ ls
raj3.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ git mv raj3.txt raj10.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ ls
raj10.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        renamed:    raj3.txt -> raj10.txt


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ git commit -m "rename file"
[master 0b8224b] rename file
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename level1/level2/level3/{raj3.txt => raj10.txt} (100%)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 4 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ cd ..

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$ ls
level3/  raj2.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$


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

Renaming files without using Git command


Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start.txt  webapp/

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ mv start.txt start2.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        deleted:    start.txt

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        start2.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git add -A

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        renamed:    start.txt -> start2.txt

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)
$ git commit -m "rename the file"
[master e144111] rename the file
 1 file changed, 0 insertions(+), 0 deletions(-)
 rename start.txt => start2.txt (100%)

Administrator@EC2AMAZ-8EUJ4RB MINGW64 ~/projects/hello-world (master)




Tuesday 27 August 2019

Backing out changes in Git by Raj Gupta


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'   README.md
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         level1/
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ cd level1/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ ls
level2/  raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ vi raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   raj1.test

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ ls
level2/  raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git add raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   raj1.test


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git reset HEAD raj1.test
Unstaged changes after reset:
M       level1/raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   raj1.test

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git checkout -- raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$

Recursive add in Git by Raj Gupta


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ mkdir -p level1/level2/level3/level5

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'   README.md
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         level1/
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ cd level1/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ vi raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ ls
level2/  raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1 (master)
$ cd level2/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$ vi raj2.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$ ls
level3/  raj2.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2 (master)
$ cd level3/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ vi raj3.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ ls
level5/  raj3.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ rm -rf level5/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ ls
raj3.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer/level1/level2/level3 (master)
$ cd ../../..

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'   README.md
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         level1/
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        level1/

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git add .

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   level1/level2/level3/raj3.txt
        new file:   level1/level2/raj2.txt
        new file:   level1/raj1.test


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git commit -m "added file"
[master 3283852] added file
 3 files changed, 3 insertions(+)
 create mode 100644 level1/level2/level3/raj3.txt
 create mode 100644 level1/level2/raj2.txt
 create mode 100644 level1/raj1.test

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)

Editing files in Git by Raj Gupta


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         raj.txt
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   README.md

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ vi raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   raj.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git add raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   raj.txt


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git commit -m "added more information to file"
[master f5eb7aa] added more information to file
 1 file changed, 2 insertions(+), 1 deletion(-)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Tracked files in Git by Raj Gupta


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ cd projects/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         raj.txt
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   README.md

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ vi raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   raj.txt

no changes added to commit (use "git add" and/or "git commit -a")

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git commit -am "Adding more test to file"
[master cc6f979] Adding more test to file
 1 file changed, 1 insertion(+), 1 deletion(-)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git ls-files
How to Install a LAMP Web Server on Amazon Linux 2
How to Install phpMyAdmin on LAMP server
How to Secure the LAMP Server Database
How to choose an AMI by Root Device Type
How to host a WordPress Blog with in Amazon Linux
How to resolve InstanceLimitExceeded error of EC2 server
How to retrieve the System Logs of our EC2 Server by Raj Gupta
README.md
raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$

Basic Git workflow(add,commit,pull & push) by Raj Gupta


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         README.md
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ vi raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         raj.txt
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'   README.md

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        raj.txt

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git add raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   raj.txt


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git commit -m raj.txt
[master e98096a] raj.txt
 1 file changed, 1 insertion(+)
 create mode 100644 raj.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git pull origin master
From https://github.com/rajkumargupta14/Amazon-Web-Services-AWS-Cloud-Engineer
 * branch            master     -> FETCH_HEAD
Already up to date.

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git push origin master
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 275 bytes | 137.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/rajkumargupta14/Amazon-Web-Services-AWS-Cloud-Engineer.git
   3ea9d7d..e98096a  master -> master

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$

Starting on GitHub by joining an Existing Project by Raj Gupta

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git clone https://github.com/rajkumargupta14/Amazon-Web-Services-AWS-Cloud-Engineer.git
Cloning into 'Amazon-Web-Services-AWS-Cloud-Engineer'...
remote: Enumerating objects: 29, done.
remote: Counting objects: 100% (29/29), done.
remote: Compressing objects: 100% (28/28), done.
remote: Total 29 (delta 14), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (29/29), done.

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd Amazon-Web-Services-AWS-Cloud-Engineer/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls
'How to choose an AMI by Root Device Type'            'How to Install phpMyAdmin on LAMP server'                        'How to Secure the LAMP Server Database'
'How to host a WordPress Blog with in Amazon Linux'   'How to resolve InstanceLimitExceeded error of EC2 server'         README.md
'How to Install a LAMP Web Server on Amazon Linux 2'  'How to retrieve the System Logs of our EC2 Server by Raj Gupta'

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ ls -al
total 16
drwxr-xr-x 1 Administrator 197121   0 Aug 27 09:26  ./
drwxr-xr-x 1 Administrator 197121   0 Aug 27 09:26  ../
drwxr-xr-x 1 Administrator 197121   0 Aug 27 09:26  .git/
-rw-r--r-- 1 Administrator 197121 228 Aug 27 09:26 'How to choose an AMI by Root Device Type'
-rw-r--r-- 1 Administrator 197121 225 Aug 27 09:26 'How to host a WordPress Blog with in Amazon Linux'
-rw-r--r-- 1 Administrator 197121 224 Aug 27 09:26 'How to Install a LAMP Web Server on Amazon Linux 2'
-rw-r--r-- 1 Administrator 197121 224 Aug 27 09:26 'How to Install phpMyAdmin on LAMP server'
-rw-r--r-- 1 Administrator 197121 227 Aug 27 09:26 'How to resolve InstanceLimitExceeded error of EC2 server'
-rw-r--r-- 1 Administrator 197121 229 Aug 27 09:26 'How to retrieve the System Logs of our EC2 Server by Raj Gupta'
-rw-r--r-- 1 Administrator 197121 228 Aug 27 09:26 'How to Secure the LAMP Server Database'
-rw-r--r-- 1 Administrator 197121  82 Aug 27 09:26  README.md

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/Amazon-Web-Services-AWS-Cloud-Engineer (master)
$

Adding Git to an existing project by Raj Gupta

Suppose we have already project initializr-verekia-4.0.zip or any other project and we want to add Git to it

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ unzip ~/Downloads/initializr-verekia-4.0.zip
Archive:  /c/Users/Administrator/Downloads/initializr-verekia-4.0.zip
  inflating: initializr/index.html
  inflating: initializr/css/main.css
  inflating: initializr/css/bootstrap-theme.css
  inflating: initializr/css/bootstrap-theme.min.css
  inflating: initializr/css/bootstrap.css
  inflating: initializr/css/bootstrap.min.css
  inflating: initializr/css/bootstrap.css.map
  inflating: initializr/css/bootstrap-theme.css.map
  inflating: initializr/fonts/glyphicons-halflings-regular.eot
  inflating: initializr/fonts/glyphicons-halflings-regular.svg
  inflating: initializr/fonts/glyphicons-halflings-regular.ttf
  inflating: initializr/fonts/glyphicons-halflings-regular.woff
  inflating: initializr/js/vendor/bootstrap.js
  inflating: initializr/js/vendor/bootstrap.min.js
  inflating: initializr/js/vendor/npm.js
  inflating: initializr/robots.txt
  inflating: initializr/js/main.js
  inflating: initializr/js/plugins.js
  inflating: initializr/crossdomain.xml
  inflating: initializr/js/vendor/modernizr-2.8.3-respond-1.4.2.min.js
  inflating: initializr/.htaccess
  inflating: initializr/apple-touch-icon.png
  inflating: initializr/browserconfig.xml
  inflating: initializr/tile-wide.png
  inflating: initializr/tile.png
  inflating: initializr/js/vendor/jquery-1.11.2.min.js
  inflating: initializr/404.html
  inflating: initializr/favicon.ico
  inflating: initializr/humans.txt
   creating: initializr/img/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
 initializr/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ mv initializr/ web-project

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
web-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd web-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project
$ ls
404.html  apple-touch-icon.png  browserconfig.xml  crossdomain.xml  css/  favicon.ico  fonts/  humans.txt  img/  index.html  js/  robots.txt  tile.png  tile-wide.png

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project
$ git init
Initialized empty Git repository in C:/Users/Administrator/projects/web-project/.git/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ ls -al
total 91
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:20 ./
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:19 ../
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:20 .git/
-rw-r--r-- 1 Administrator 197121 39014 Aug 27 08:17 .htaccess
-rw-r--r-- 1 Administrator 197121  1272 Aug 27 08:17 404.html
-rw-r--r-- 1 Administrator 197121  3959 Aug 27 08:17 apple-touch-icon.png
-rw-r--r-- 1 Administrator 197121   416 Aug 27 08:17 browserconfig.xml
-rw-r--r-- 1 Administrator 197121   603 Aug 27 08:17 crossdomain.xml
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:18 css/
-rw-r--r-- 1 Administrator 197121   766 Aug 27 08:17 favicon.ico
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:18 fonts/
-rw-r--r-- 1 Administrator 197121   191 Aug 27 08:17 humans.txt
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:17 img/
-rw-r--r-- 1 Administrator 197121  5329 Aug 27 08:17 index.html
drwxr-xr-x 1 Administrator 197121     0 Aug 27 08:18 js/
-rw-r--r-- 1 Administrator 197121    78 Aug 27 08:17 robots.txt
-rw-r--r-- 1 Administrator 197121  3482 Aug 27 08:17 tile.png
-rw-r--r-- 1 Administrator 197121  1854 Aug 27 08:17 tile-wide.png

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        .htaccess
        404.html
        apple-touch-icon.png
        browserconfig.xml
        crossdomain.xml
        css/
        favicon.ico
        fonts/
        humans.txt
        index.html
        js/
        robots.txt
        tile-wide.png
        tile.png

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ git add .

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   .htaccess
        new file:   404.html
        new file:   apple-touch-icon.png
        new file:   browserconfig.xml
        new file:   crossdomain.xml
        new file:   css/bootstrap-theme.css
        new file:   css/bootstrap-theme.css.map
        new file:   css/bootstrap-theme.min.css
        new file:   css/bootstrap.css
        new file:   css/bootstrap.css.map
        new file:   css/bootstrap.min.css
        new file:   css/main.css
        new file:   favicon.ico
        new file:   fonts/glyphicons-halflings-regular.eot
        new file:   fonts/glyphicons-halflings-regular.svg
        new file:   fonts/glyphicons-halflings-regular.ttf
        new file:   fonts/glyphicons-halflings-regular.woff
        new file:   humans.txt
        new file:   index.html
        new file:   js/main.js
        new file:   js/plugins.js
        new file:   js/vendor/bootstrap.js
        new file:   js/vendor/bootstrap.min.js
        new file:   js/vendor/jquery-1.11.2.min.js
        new file:   js/vendor/modernizr-2.8.3-respond-1.4.2.min.js
        new file:   js/vendor/npm.js
        new file:   robots.txt
        new file:   tile-wide.png
        new file:   tile.png


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ git commit -m "My first commit, inline"
[master (root-commit) 88a4cee] My first commit, inline
 29 files changed, 10594 insertions(+)
 create mode 100644 .htaccess
 create mode 100644 404.html
 create mode 100644 apple-touch-icon.png
 create mode 100644 browserconfig.xml
 create mode 100644 crossdomain.xml
 create mode 100644 css/bootstrap-theme.css
 create mode 100644 css/bootstrap-theme.css.map
 create mode 100644 css/bootstrap-theme.min.css
 create mode 100644 css/bootstrap.css
 create mode 100644 css/bootstrap.css.map
 create mode 100644 css/bootstrap.min.css
 create mode 100644 css/main.css
 create mode 100644 favicon.ico
 create mode 100644 fonts/glyphicons-halflings-regular.eot
 create mode 100644 fonts/glyphicons-halflings-regular.svg
 create mode 100644 fonts/glyphicons-halflings-regular.ttf
 create mode 100644 fonts/glyphicons-halflings-regular.woff
 create mode 100644 humans.txt
 create mode 100644 index.html
 create mode 100644 js/main.js
 create mode 100644 js/plugins.js
 create mode 100644 js/vendor/bootstrap.js
 create mode 100644 js/vendor/bootstrap.min.js
 create mode 100644 js/vendor/jquery-1.11.2.min.js
 create mode 100644 js/vendor/modernizr-2.8.3-respond-1.4.2.min.js
 create mode 100644 js/vendor/npm.js
 create mode 100644 robots.txt
 create mode 100644 tile-wide.png
 create mode 100644 tile.png

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/web-project (master)
$ git status
On branch master
nothing to commit, working tree clean

Starting with a Fresh Project with GIT by Raj Gupta



Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ pwd
/c/Users/Administrator

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ ls
'3D Objects'/         Desktop/    'Local Settings'@   ntuser.dat.LOG1                                                                                ntuser.ini  'Saved Games'/   Videos/
 AppData/             Documents/   Music/             ntuser.dat.LOG2                                                                                Pictures/    Searches/
'Application Data'@   Downloads/  'My Documents'@     NTUSER.DAT{a057f24c-e827-11e8-81c0-0a917f905606}.TM.blf                                        PrintHood@   SendTo@
 Contacts/            Favorites/   NetHood@           NTUSER.DAT{a057f24c-e827-11e8-81c0-0a917f905606}.TMContainer00000000000000000001.regtrans-ms   projects/   'Start Menu'@
 Cookies@             Links/       NTUSER.DAT         NTUSER.DAT{a057f24c-e827-11e8-81c0-0a917f905606}.TMContainer00000000000000000002.regtrans-ms   Recent@      Templates@

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ cd projects/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ pwd
/c/Users/Administrator/projects

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git init fresh-project
Initialized empty Git repository in C:/Users/Administrator/projects/fresh-project/.git/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
fresh-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd fresh-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ ls

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ ls -al
total 4
drwxr-xr-x 1 Administrator 197121 0 Aug 27 07:46 ./
drwxr-xr-x 1 Administrator 197121 0 Aug 27 07:46 ../
drwxr-xr-x 1 Administrator 197121 0 Aug 27 07:46 .git/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ cd .git/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project/.git (GIT_DIR!)
$ ls
config  description  HEAD  hooks/  info/  objects/  refs/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project/.git (GIT_DIR!)
$ cd ..

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ pwd
/c/Users/Administrator/projects/fresh-project

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ vi hipster.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git status
On branch master

No commits yet

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        hipster.txt

nothing added to commit but untracked files present (use "git add" to track)

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git add hipster.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
        new file:   hipster.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git commit -m hipster.txt
[master (root-commit) 752c16b] hipster.txt
 1 file changed, 1 insertion(+)
 create mode 100644 hipster.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ git status
On branch master
nothing to commit, working tree clean

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/fresh-project (master)
$ cd ..

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ pwd
/c/Users/Administrator/projects

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
fresh-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ rm -rf fresh-project/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$

Friday 23 August 2019

Install and configure Notepad++ with Git by Raj Gupta


Open then link https://notepad-plus-plus.org/  and click on download after download just install it by clicking next next


Now configure Notepad++ with Git

Take the path in which notepad++ install in my case

C:\Program Files (x86)\Notepad++

Then right click on PC ----> Then go to Property ----> Then Advance system setting -----> Then go to  Advance Tab -------->>. Then click on Environment variables ------->>> Then under system  variables select path and click edit ----->>> Then click on new and then add path C:\Program Files (x86)\Notepad++ of notepad++ then click ok


Now close the git and open once again then when you give notepad++ then notepad++ will be open


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ notepad++


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ npp

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ cat ~/.gitconfig
[user]
        name = Raj Gupta
        email = rajkumargupta14@gmail.com

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ git config --global core.editor "notepad++.exc -multiInst -nosession"

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ git config --global --list
user.name=Raj Gupta
user.email=rajkumargupta14@gmail.com
core.editor=notepad++.exc -multiInst -nosession




Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ git config --global -e

Git command by Raj Gupta



Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ pwd
/c/Users/Administrator

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ mkdir projects

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ cd projects/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ pwd
/c/Users/Administrator/projects

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git config --global user.name "Raj Gupta"

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git config --global user.email "rajkumargupta14@gmail.com"

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git config --global --list
user.name=Raj Gupta
user.email=rajkumargupta14@gmail.com

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git clone https://github.com/rajkumargupta14/Raj2.git
Cloning into 'Raj2'...
warning: You appear to have cloned an empty repository.

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ git clone https://github.com/rajkumargupta14/hello-world.git
Cloning into 'hello-world'...
remote: Enumerating objects: 200, done.
remote: Total 200 (delta 0), reused 0 (delta 0), pack-reused 200
Receiving objects: 100% (200/200), 25.79 KiB | 628.00 KiB/s, done.
Resolving deltas: 100% (35/35), done.
Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ ls
hello-world/  Raj2/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects
$ cd hello-world/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  webapp/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ echo "This is Git Quick Start demo" >> start.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ ls
Dockerfile  pom.xml  README.md  server/  start.txt  webapp/

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ cat start.txt
This is Git Quick Start demo

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        start.txt

nothing added to commit but untracked files present (use "git add" to track)
Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git add start.txt

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   start.txt


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git commit -m "Adding start test file"
[master 5e8e01d] Adding start test file
 1 file changed, 1 insertion(+)
 create mode 100644 start.txt


Now push it to github

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)
$ git push origin master   ---------------->>>>.It will ask user name and password of github
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 312 bytes | 156.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/rajkumargupta14/hello-world.git
   977ca2d..5e8e01d  master -> master

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~/projects/hello-world (master)


How to install GIT on window by Raj Gupta

1. Open the link  https://gitforwindows.org/  then click on download after download click on next next after choosing option as per your requirement .

2. After installion click on icon created on desktop and run the below command to confirm.


Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ git version
git version 2.23.0.windows.1

Administrator@EC2AMAZ-H8K4U2K MINGW64 ~
$ close

Thursday 22 August 2019

Docker swarm Label and Constraint by Raj Gupta

We can create label in two way

1. Node labels  ----for this we need to run on master, we need access on master
2. Engine labels  ----we need to run on worker, so we don't required access of master.

If you want to create some service on only master then

[root@ip-172-31-83-166 ~]# docker service create --replicas=3 --constraint="node.role==manager" alpine ping 172.31.83.166
mr0nf8wjykhd8vhzzpexs20vl
overall progress: 3 out of 3 tasks
1/3: running   [==================================================>]
2/3: running   [==================================================>]
3/3: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#

--------------------------------------------------------------------------
and to create on only worker

[root@ip-172-31-83-166 ~]# docker service create --replicas=3 --constraint="node.role==worker" alpine ping 172.31.83.166
qixhwn2mje7guhqlcazl56bxt
overall progress: 3 out of 3 tasks
1/3: running   [==================================================>]
2/3: running   [==================================================>]
3/3: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#

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


In this way we can add label to node

[root@ip-172-31-83-166 ~]# docker node update --label-add="ssd=true" ip-172-31-81-43
ip-172-31-81-43
[root@ip-172-31-83-166 ~]#

In this way we can create service on only particular label node

[root@ip-172-31-83-166 ~]# docker service create --constraint="node.labels.ssd==true" --replicas=3 -d alpine 172.31.81.43
0a6ezsi9x2qhy7d523ctca0g8
[root@ip-172-31-83-166 ~]#



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

We can also create label on worker by using below

Run the below command on worker02

[root@ip-172-31-81-43 ~]# vi /etc/docker/daemon.json
[root@ip-172-31-81-43 ~]# cat /etc/docker/daemon.json
{
        "labels : ["name=raj"]
}
[root@ip-172-31-81-43 ~]# service docker restart

Now run the below command on master it will create on service on worker02 only

[root@ip-172-31-83-166 ~]# docker service create --constraint="engine.labels.name==raj" --replicas=3 -d alpine 172.31.81.43
mcvert6gvmw3u464ikhjwid2y
[root@ip-172-31-83-166 ~]#



Docker Service Mode (Replicated, global) by Raj Gupta



[root@ip-172-31-83-166 ~]# docker service create -d --replicas=3 alpine ping 172.31.83.166
gnbq42aqu083vcsf1f8w8d7uz
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
gnbq42aqu083        gallant_lamport     replicated          3/3                 alpine:latest
ip6hivkzqohi        happy_thompson      replicated          1/1                 alpine:latest
r3emkkfmh4a3        tender_chaplygin    replicated          1/1                 nginx:latest        *:8090->80/tcp



If you want to see the visual diagram of all your master and node then run the below command on master

[root@ip-172-31-83-166 ~]# docker service create   --name=viz   --publish=8080:8080/tcp   --constraint=node.role==manager   --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock   dockersamples/visualizer
6iamsonw3jrsedeudqhun1bmx
overall progress: 1 out of 1 tasks
1/1: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#

Now you in browser use the blow to see

http://34.203.202.233:8080/

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


If you want to create container service on all nodes even if you add any node in future then

[root@ip-172-31-83-166 ~]# docker service create --mode=global alpine ping 8.8.8.8
snrsqqnnblwx39tgccjp3w4ts
overall progress: 3 out of 3 tasks
vvj0e7oybvg7: running   [==================================================>]
ly6ri9vtmku7: running   [==================================================>]
nlkj6kdokxk3: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE                             PORTS
snrsqqnnblwx        festive_edison      global              3/3                 alpine:latest
gnbq42aqu083        gallant_lamport     replicated          3/3                 alpine:latest
ip6hivkzqohi        happy_thompson      replicated          1/1                 alpine:latest
r3emkkfmh4a3        tender_chaplygin    replicated          1/1                 nginx:latest                      *:8090->80/tcp
6iamsonw3jrs        viz                 replicated          1/1                 dockersamples/visualizer:latest   *:8080->8080/tcp
[root@ip-172-31-83-166 ~]#





Wednesday 21 August 2019

Docker service(scale,port mapping) Part-3 by Raj Gupta


on master
[root@ip-172-31-83-166 ~]# docker service create -d --replicas 2 alpine ping 172.31.83.166
uz034gaq968jxsriuuob4lxsa
[root@ip-172-31-83-166 ~]#

on worker02
[root@ip-172-31-83-166 ~]# docker service create -d --replicas 3 alpine ping 172.31.81.43
wkk7l8bacrrld2qaupubdr0m2
[root@ip-172-31-83-166 ~]#


[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
befib2ehy1bk        optimistic_kilby     replicated          4/4                 alpine:latest
wkk7l8bacrrl        sharp_hawking        replicated          3/3                 alpine:latest
[root@ip-172-31-83-166 ~]#


now to increase and decrease replicas

[root@ip-172-31-83-166 ~]# docker service scale wkk7l8bacrrl=7
wkk7l8bacrrl scaled to 7
overall progress: 7 out of 7 tasks
1/7: running   [==================================================>]
2/7: running   [==================================================>]
3/7: running   [==================================================>]
4/7: running   [==================================================>]
5/7: running   [==================================================>]
6/7: running   [==================================================>]
7/7: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#


At same time

[root@ip-172-31-83-166 ~]# docker service scale wkk7l8bacrrl=5 befib2ehy1bk=8
wkk7l8bacrrl scaled to 5
befib2ehy1bk scaled to 8
overall progress: 5 out of 5 tasks
1/5: running   [==================================================>]
2/5: running   [==================================================>]
3/5: running   [==================================================>]
4/5: running   [==================================================>]
5/5: running   [==================================================>]
verify: Service converged
overall progress: 8 out of 8 tasks
1/8: running   [==================================================>]
2/8: running   [==================================================>]
3/8: running   [==================================================>]
4/8: running   [==================================================>]
5/8: running   [==================================================>]
6/8: running   [==================================================>]
7/8: running   [==================================================>]
8/8: running   [==================================================>]
verify: Service converged
[root@ip-172-31-83-166 ~]#

[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
befib2ehy1bk        optimistic_kilby     replicated          8/8                 alpine:latest
wkk7l8bacrrl        sharp_hawking        replicated          5/5                 alpine:latest
[root@ip-172-31-83-166 ~]#


Now to remove service 

[root@ip-172-31-83-166 ~]# docker service rm befib2ehy1bk wkk7l8bacrrl
befib2ehy1bk
wkk7l8bacrrl
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
uz034gaq968j        laughing_rosalind    replicated          2/2                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
[root@ip-172-31-83-166 ~]#


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

Port mapping:-

[root@ip-172-31-83-166 ~]# docker service create -d -p 8090:80 nginx
r3emkkfmh4a37wuxrneh0ovru
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
r3emkkfmh4a3        tender_chaplygin    replicated          1/1                 nginx:latest        *:8090->80/tcp
[root@ip-172-31-83-166 ~]#


now you are able to access it from any nodes(master,worker01,worker02)
http://54.210.168.62:8090/


Docker service Part-2 by Raj Gupta

To create the four copy of container

[root@ip-172-31-83-166 ~]# docker service create -d --replicas 4 alpine ping 172.31.83.166
befib2ehy1bkmpduqv98qip60
[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest
befib2ehy1bk        optimistic_kilby     replicated          4/4                 alpine:latest
[root@ip-172-31-83-166 ~]#


To get the details of all process of service 

[root@ip-172-31-83-166 ~]# docker service ps befib2ehy1bk
ID                  NAME                 IMAGE               NODE                DESIRED STATE       CURRENT STATE           ERROR               PORTS
of1nea5konsa        optimistic_kilby.1   alpine:latest       ip-172-31-81-43     Running             Running 6 minutes ago
x2vcdvzoh0q0        optimistic_kilby.2   alpine:latest       ip-172-31-81-43     Running             Running 6 minutes ago
hcky0bjjk9v3        optimistic_kilby.3   alpine:latest       ip-172-31-88-27     Running             Running 6 minutes ago
b7xovnxo2u6p        optimistic_kilby.4   alpine:latest       ip-172-31-83-166    Running             Running 6 minutes ago

replicas services will act like auto-scaling in above case if some delete the 1 or more container then master will create again new container so that total count will be four


What is docker service(create,ls,logs) in docker swarm by Raj Gupta


-------------------------------------------------------------------------------------------------------
after running below command on Master it will create a container on Worker01(172.31.88.27) then  it will start pining to it

[root@ip-172-31-83-166 ~]# docker container run -it alpine ping 172.31.88.27
Unable to find image 'alpine:latest' locally
latest: Pulling from library/alpine
9d48c3bd43c5: Pull complete
Digest: sha256:72c42ed48c3a2db31b7dafe17d275b634664a708d901ec9fd57b1529280f01fb
Status: Downloaded newer image for alpine:latest
PING 172.31.88.27 (172.31.88.27): 56 data bytes
64 bytes from 172.31.88.27: seq=0 ttl=254 time=0.942 ms
64 bytes from 172.31.88.27: seq=1 ttl=254 time=0.644 ms
64 bytes from 172.31.88.27: seq=2 ttl=254 time=0.572 ms
64 bytes from 172.31.88.27: seq=3 ttl=254 time=0.635 ms
64 bytes from 172.31.88.27: seq=4 ttl=254 time=0.616 ms
^Z64 bytes from 172.31.88.27: seq=5 ttl=254 time=0.708 ms
64 bytes from 172.31.88.27: seq=6 ttl=254 time=0.716 ms
64 bytes from 172.31.88.27: seq=7 ttl=254 time=0.765 ms
64 bytes from 172.31.88.27: seq=8 ttl=254 time=0.645 ms
64 bytes from 172.31.88.27: seq=9 ttl=254 time=0.629 ms
^C
--- 172.31.88.27 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max = 0.572/0.687/0.942 ms
[root@ip-172-31-83-166 ~]#


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

[root@ip-172-31-83-166 ~]# docker service --help

Usage:  docker service COMMAND

Manage services

Commands:
  create      Create a new service
  inspect     Display detailed information on one or more services
  logs        Fetch the logs of a service or task
  ls          List services
  ps          List the tasks of one or more services
  rm          Remove one or more services
  rollback    Revert changes to a service's configuration
  scale       Scale one or multiple replicated services
  update      Update a service

Run 'docker service COMMAND --help' for more information on a command.
[root@ip-172-31-83-166 ~]#

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

This is also create a container on worker and run the ping command

To create the docker service 

[root@ip-172-31-83-166 ~]# docker service create alpine ping 172.31.81.43

docker service ls will list the created services

[root@ip-172-31-83-166 ~]# docker service ls
ID                  NAME                 MODE                REPLICAS            IMAGE               PORTS
8ybsu9bgen5e        confident_poincare   replicated          1/1                 alpine:latest
lc7l8xvo9a0o        nifty_albattani      replicated          1/1                 alpine:latest


To see the detail of docker service 

[root@ip-172-31-83-166 ~]# docker service inspect 8ybsu9bgen5e


To check the logs of service 

[root@ip-172-31-83-166 ~]# docker service logs 8ybsu9bgen5e