================================================================= Issue Error while connecting through SSH (Putty or Winscp), following...


=================================================================

Issue
Error while connecting through SSH (Putty or Winscp), following errors can be seen in /var/log/messages:
Raw
Sep 15 16:25:40 hostname sshd[17397]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sep 15 16:25:40 hostname sshd[17397]: error: @ WARNING: UNPROTECTED PRIVATE KEY FILE!  @
Sep 15 16:25:40 hostname sshd[17397]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sep 15 16:25:40 hostname sshd[17397]: error: Permissions 0777 for '/etc/ssh/ssh_host_dsa_key' are too open.
Sep 15 16:25:40 hostname sshd[17397]: error: It is recommended that your private key files are NOT accessible by others.
Sep 15 16:25:40 hostname sshd[17397]: error: This private key will be ignored.
Sep 15 16:25:40 hostname sshd[17397]: error: bad permissions: ignore key: /etc/ssh/ssh_host_dsa_key
Sep 15 16:25:40 hostname sshd[17397]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Sep 15 16:25:40 hostname sshd[17397]: Disabling protocol version 2. Could not load host key
Sep 15 16:25:40 hostname sshd[17397]: sshd: no hostkeys available -- exiting.
Raw
Aug  7 08:02:15 hostname sshd[30600]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Aug  7 08:02:15 hostname sshd[30600]: error: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @ 
Aug  7 08:02:15 hostname sshd[30600]: error: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Aug  7 08:02:15 hostname sshd[30600]: error: Permissions 0711 for '/etc/ssh/ssh_host_rsa_key' are too open.
Aug  7 08:02:15 hostname sshd[30600]: error: It is recommended that your private key files are NOT accessible by others.
Aug  7 08:02:15 hostname sshd[30600]: error: This private key will be ignored.
Aug  7 08:02:15 hostname sshd[30600]: error: bad permissions: ignore key: /etc/ssh/ssh_host_rsa_key
Aug  7 08:02:16 hostname sshd[30600]: error: Could not load host key: /etc/ssh/ssh_host_rsa_key
Aug  7 08:02:16 hostname sshd[30600]: Disabling protocol version 1. Could not load host key

=============================================================================================================================

Resolution
1. Move the following files in /etc/ssh to another place, e.g. /root:

Raw
# cd /etc/ssh

# mv ssh_host_dsa_key ssh_host_dsa_key.pub ssh_host_key ssh_host_key.pub ssh_host_rsa_key ssh_host_rsa_key.pub /root
2. Restart the sshd service.

Raw
# service sshd restart
The sshd daemon will recreate new ssh rsa,dsa,rsa1 keys.

[root@node2 sample-project6]# docker-compose images Container   Repository   Tag   Image Id   Size --------------------------------------...

[root@node2 sample-project6]# docker-compose images
Container   Repository   Tag   Image Id   Size
----------------------------------------------
[root@node2 sample-project6]# docker-compose up -d
Creating sampleproject6_wepapp1_1 ... done
Creating sampleproject6_wepapp2_1 ... done

[root@node2 sample-project6]# docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
7bb3f287740a        nginx               "nginx -g 'daemon of…"   23 seconds ago      Up 21 seconds       0.0.0.0:8081->80/tcp   sampleproject6_wepapp2_1
86deb573d894        nginx               "nginx -g 'daemon of…"   23 seconds ago      Up 21 seconds       0.0.0.0:8082->80/tcp   sampleproject6_wepapp1_1
[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State          Ports       
------------------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Up      0.0.0.0:8082->80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Up      0.0.0.0:8081->80/tcp



[root@node2 sample-project6]# docker-compose pause
Pausing sampleproject6_wepapp1_1 ... done
Pausing sampleproject6_wepapp2_1 ... done
[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State           Ports       
-------------------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Paused   0.0.0.0:8082->80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Paused   0.0.0.0:8081->80/tcp
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose unpause
Unpausing sampleproject6_wepapp2_1 ... done
Unpausing sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State          Ports       
------------------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Up      0.0.0.0:8082->80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Up      0.0.0.0:8081->80/tcp
[root@node2 sample-project6]#


[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State          Ports       
------------------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Up      0.0.0.0:8082->80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Up      0.0.0.0:8081->80/tcp
[root@node2 sample-project6]#
[root@node2 sample-project6]#
[root@node2 sample-project6]# docker-compose kill
Killing sampleproject6_wepapp2_1 ... done
Killing sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]# docker-compose ps
          Name                   Command           State     Ports
------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Exit 137       
sampleproject6_wepapp2_1   nginx -g daemon off;   Exit 137       
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose start
Starting wepapp1 ... done
Starting wepapp2 ... done
[root@node2 sample-project6]#
[root@node2 sample-project6]#
[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State          Ports       
------------------------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Up      0.0.0.0:8082->80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Up      0.0.0.0:8081->80/tcp
[root@node2 sample-project6]#


[root@node2 sample-project6]# docker-compose port wepapp1 80
0.0.0.0:8082
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose logs
Attaching to sampleproject6_wepapp2_1, sampleproject6_wepapp1_1
[root@node2 sample-project6]# docker-compose logs -f
Attaching to sampleproject6_wepapp2_1, sampleproject6_wepapp1_1
wepapp2_1  | 2020/01/16 12:49:27 [error] 6#6: *1 open() "/usr/share/nginx/html/favicon.ico" failed (2: No such file or directory), client: 10.25.214.125, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "10.25.214.132:8081", referrer: "http://10.25.214.132:8081/"
wepapp2_1  | 10.25.214.125 - - [16/Jan/2020:12:49:27 +0000] "GET /favicon.ico HTTP/1.1" 404 555 "http://10.25.214.132:8081/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36" "-"


[root@node2 sample-project6]# docker-compose exec wepapp1 ls
bin   dev  home  lib64 mnt  proc  run srv  tmp  var
boot  etc  lib media opt  root  sbin  sys  usr

[root@node2 sample-project6]# docker-compose exec wepapp2 ls
bin   dev  home  lib64 mnt  proc  run srv  tmp  var
boot  etc  lib media opt  root  sbin  sys  usr
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose run wepapp1 ls
bin   dev  home  lib64 mnt  proc  run srv  tmp  var
boot  etc  lib media opt  root  sbin  sys  usr
[root@node2 sample-project6]#


[root@node2 sample-project6]# docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                  NAMES
7bb3f287740a        nginx               "nginx -g 'daemon of…"   12 minutes ago      Up 8 minutes        0.0.0.0:8081->80/tcp   sampleproject6_wepapp2_1
86deb573d894        nginx               "nginx -g 'daemon of…"   12 minutes ago      Up 8 minutes        0.0.0.0:8082->80/tcp   sampleproject6_wepapp1_1
[root@node2 sample-project6]#
[root@node2 sample-project6]# docker ps -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS                  NAMES
7fac18d212ef        nginx               "ls"                     27 seconds ago      Exited (0) 27 seconds ago                          sampleproject6_wepapp1_run_1
7bb3f287740a        nginx               "nginx -g 'daemon of…"   12 minutes ago      Up 9 minutes                0.0.0.0:8081->80/tcp   sampleproject6_wepapp2_1
86deb573d894        nginx               "nginx -g 'daemon of…"   12 minutes ago      Up 9 minutes                0.0.0.0:8082->80/tcp   sampleproject6_wepapp1_1
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose restart
Restarting sampleproject6_wepapp2_1 ... done
Restarting sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]#
[root@node2 sample-project6]# docker-compose pull
[root@node2 sample-project6]# docker-compose imgaes


[root@node2 sample-project6]# docker-compose scale wepapp1=4 wepapp2=2
WARNING: The scale command is deprecated. Use the up command with the --scale flag instead.
Starting sampleproject6_wepapp1_1 ... done
Creating sampleproject6_wepapp1_2 ... done
Creating sampleproject6_wepapp1_3 ... done
Creating sampleproject6_wepapp1_4 ... done
Starting sampleproject6_wepapp2_1 ... done
Creating sampleproject6_wepapp2_2 ... done
[root@node2 sample-project6]# docker-compose ps
          Name                   Command          State   Ports
----------------------------------------------------------------
sampleproject6_wepapp1_1   nginx -g daemon off;   Up      80/tcp
sampleproject6_wepapp1_2   nginx -g daemon off;   Up      80/tcp
sampleproject6_wepapp1_3   nginx -g daemon off;   Up      80/tcp
sampleproject6_wepapp1_4   nginx -g daemon off;   Up      80/tcp
sampleproject6_wepapp2_1   nginx -g daemon off;   Up      80/tcp
sampleproject6_wepapp2_2   nginx -g daemon off;   Up      80/tcp
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose down
Stopping sampleproject6_wepapp2_2 ... done
Stopping sampleproject6_wepapp1_3 ... done
Stopping sampleproject6_wepapp1_2 ... done
Stopping sampleproject6_wepapp1_4 ... done
Stopping sampleproject6_wepapp2_1 ... done
Stopping sampleproject6_wepapp1_1 ... done
Removing sampleproject6_wepapp2_2     ... done
Removing sampleproject6_wepapp1_3     ... done
Removing sampleproject6_wepapp1_2     ... done
Removing sampleproject6_wepapp1_4     ... done
Removing sampleproject6_wepapp2_1     ... done
Removing sampleproject6_wepapp1_1     ... done
Removing sampleproject6_wepapp1_run_1 ... done
Removing network sampleproject6_default
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose up -d
Creating network "sampleproject6_default" with the default driver
Creating sampleproject6_wepapp1_1 ... done
Creating sampleproject6_wepapp2_1 ... done
[root@node2 sample-project6]# docker-compose top
sampleproject6_wepapp1_1
UID    PID    PPID   C   STIME   TTY     TIME                        CMD                   
--------------------------------------------------------------------------------------------
root   4504   4488   0   08:07   ?     00:00:00   nginx: master process nginx -g daemon off;
101    4610   4504   0   08:07   ?     00:00:00   nginx: worker process                   

sampleproject6_wepapp2_1
UID    PID    PPID   C   STIME   TTY     TIME                        CMD                   
--------------------------------------------------------------------------------------------
root   4540   4511   0   08:07   ?     00:00:00   nginx: master process nginx -g daemon off;
101    4627   4540   0   08:07   ?     00:00:00   nginx: worker process                   
[root@node2 sample-project6]#




[root@node2 sample-project6]# docker-compose create WARNING: The create command is deprecated. Use the up command with the --no-start flag...

[root@node2 sample-project6]# docker-compose create
WARNING: The create command is deprecated. Use the up command with the --no-start flag instead.
Creating sampleproject6_wepapp1_1 ... done
Creating sampleproject6_wepapp2_1 ... done
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose rm
Going to remove sampleproject6_wepapp2_1, sampleproject6_wepapp1_1
Are you sure? [yN] y
Removing sampleproject6_wepapp2_1 ... done
Removing sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]#


[root@node2 sample-project6]# docker-compose up --no-start
Creating network "sampleproject6_default" with the default driver
Creating sampleproject6_wepapp1_1 ... done
Creating sampleproject6_wepapp2_1 ... done
[root@node2 sample-project6]# docker network ls
NETWORK ID          NAME                     DRIVER              SCOPE
05ce50c0dda0        bridge                   bridge              local
b22e6d7fcb00        host                     host                local
652f2a01662d        none                     null                local
9f3708f11f98        sampleproject6_default   bridge              local
[root@node2 sample-project6]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@node2 sample-project6]# docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
cbbd77c151da        nginx               "nginx -g 'daemon of…"   22 seconds ago      Created                                 sampleproject6_wepapp2_1
b96d8bf3ea24        nginx               "nginx -g 'daemon of…"   22 seconds ago      Created                                 sampleproject6_wepapp1_1
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose  start
Starting wepapp1 ... done
Starting wepapp2 ... done
[root@node2 sample-project6]# docker-compose  stop
Stopping sampleproject6_wepapp2_1 ... done
Stopping sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]#

[root@node2 sample-project6]# docker-compose rm
Going to remove sampleproject6_wepapp2_1, sampleproject6_wepapp1_1
Are you sure? [yN] y 
Removing sampleproject6_wepapp2_1 ... done
Removing sampleproject6_wepapp1_1 ... done
[root@node2 sample-project6]#
[root@node2 sample-project6]# docker container ls
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES


[root@node2 sample-project6]# docker network ls
NETWORK ID          NAME                     DRIVER              SCOPE
05ce50c0dda0        bridge                   bridge              local
b22e6d7fcb00        host                     host                local
652f2a01662d        none                     null                local
9f3708f11f98        sampleproject6_default   bridge              local
[root@node2 sample-project6]#





[root@node2 sample-project5]# cat docker-compose.yml version: '2' services:  database:    image: mysql:5.7    environment: ...

[root@node2 sample-project5]# cat docker-compose.yml
version: '2'

services:

 database:
   image: mysql:5.7
   environment:
     MYSQL_ROOT_PASSWORD: password

 wordpress:
    image: wordpress
    ports:
      - "8080:80"
    links:
      - database:mysql
    environment:
      WORDPRESS_DB_PASSWORD: password
===================================================================

[root@node2 sample-project6]# cat docker-compose.yml
version: '3'

services:
   wepapp1:
     image: nginx
     ports:
       - 8082:80
   wepapp2:
     image: nginx
     ports:
       - 8081:80

[root@node2 dockerfile-sample1]# mkdir dockerfile-sample2 [root@node2 dockerfile-sample1]# cd dockerfile-sample2/ [root@node2 dockerfile-...

[root@node2 dockerfile-sample1]# mkdir dockerfile-sample2
[root@node2 dockerfile-sample1]# cd dockerfile-sample2/
[root@node2 dockerfile-sample1]# ll -lrth
[root@node2 dockerfile-sample1]# vim Dockerfile
[root@node2 dockerfile-sample1]# vim index.html
[root@node2 dockerfile-sample1]# docker image build -t nginx-with-html .
[root@node2 dockerfile-sample1]# docker container run -p 80:80 --rm nginx-with-html

vim Dockerfile
FROM nginx:latest
WORKDIR /usr/share/nginx/html
COPY index.html index.html


===================================================================================

[root@node2 ~]# docker container run -d --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=True mysql
[root@node2 ~]# docker container inspect mysql
[root@node2 ~]# docker volume ls
[root@node2 ~]# docker container run -d --name mysql2 -e MYSQL_ALLOW_EMPTY_PASSWORD=True -v mysql-db:/var/lib/mysql mysql
[root@node2 ~]# docker volume ls
DRIVER              VOLUME NAME
local               ac6eef37956b3d3db63f0ac8d8f7ff3a4b4ac140467d37dac4304e3d1113bbf1
local               mysql-db

[root@node2 ~]# docker volume inspect mysql-db
[
    {
        "CreatedAt": "2019-12-21T09:12:26-05:00",
        "Driver": "local",
        "Labels": null,
        "Mountpoint": "/var/lib/docker/volumes/mysql-db/_data",
        "Name": "mysql-db",
        "Options": null,
        "Scope": "local"
    }
]
[root@node2 ~]#
[root@node2 ~]# docker container inspect mysql2
[root@node2 ~]# docker volume create ravi
ravi
[root@node2 ~]# docker volume ls
DRIVER              VOLUME NAME
local               ac6eef37956b3d3db63f0ac8d8f7ff3a4b4ac140467d37dac4304e3d1113bbf1
local               mysql-db
local               ravi
[root@node2 ~]#

[root@node2 dockerfile-sample2]# docker container run -d --name nginx -p 80:80 -v $(pwd):/usr/share/nginx/html nginx
[root@node2 ~]# docker container run -d --name psql -v psql:/var/lib/postgresql/data postgres:9.6.1
[root@node2 ~]# docker container logs psql
[root@node2 ~]# docker container stop psql
[root@node2 ~]# docker container run -d --name psql2 -v psql:/var/lib/postgresql/data postgres:9.6.2
[root@node2 ~]# docker container logs psql2
[root@node2 ~]# docker run -p 80:4000 -v $(pwd):/site bretfirsher/jekyll-serve

[root@node2 ~]# docker container run -p 80:80 --name webhost -d nginx 6608c2fdab1ea4252d239341b96161b438d669dd3687ffed1d4504587f050ecf [r...

[root@node2 ~]# docker container run -p 80:80 --name webhost -d nginx
6608c2fdab1ea4252d239341b96161b438d669dd3687ffed1d4504587f050ecf
[root@node2 ~]#
[root@node2 ~]# docker container port webhost
80/tcp -> 0.0.0.0:80
[root@node2 ~]# docker container inspect --format '{{ .NetworkSettings.IPAddress }}' webhost
172.17.0.5
[root@node2 ~]#
[root@node2 ~]# docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
a71c392d30d7        bridge              bridge              local
b22e6d7fcb00        host                host                local
652f2a01662d        none                null                local
[root@node2 ~]# docker network inspect bridge
[root@node2 ~]# docker network create my_app_net
[root@node2 ~]# docker container run -d --name new_nginx --network my_app_net nginx
195e2b4dc3d7522764f39623eda9be906ab22a262e461f9fa7df319b2c9f5413
[root@node2 ~]# docker network connect 74522dcf77e7 6608c2fdab1e
[root@node2 ~]# docker network disconnect 74522dcf77e7 6608c2fdab1e

[root@node2 ~]# docker container exec -it my_nginx /bin/bash
[root@node2 ~]# docker container exec -it my_nginx ping new_nginx


[root@node2 ~]# conatiner -d --net dude --net-alias search elasticsearch:2
[root@node2 ~]# docker conatiner run -d --net dude --net-alias search elasticsearch:2
[root@node2 ~]# docker container run -d --net dude --net-alias search elasticsearch:2
[root@node2 ~]# docker container ls
[root@node2 ~]# docker container run --rm --net dude alpine nslookup search
[root@node2 ~]# docker container run --rm --net dude centos curl -s search:9200

[root@node2 ~]# docker container run --publish 80:80 nginx [root@node2 ~]# docker container run --publish 80:80 --detach nginx [root@node...

[root@node2 ~]# docker container run --publish 80:80 nginx
[root@node2 ~]# docker container run --publish 80:80 --detach nginx
[root@node2 ~]# docker container run --publish 80:80 --detach --name webhost nginx
[root@node2 ~]# docker container logs webhost
[root@node2 ~]# docker container top webhost
[root@node2 ~]# docker container rm 1bd 4f9 d7a
[root@node2 ~]# docker container rm -f 1bd
[root@node2 ~]# docker run --name mongo -d mongo
[root@node2 ~]# docker top mongo
[root@node2 ~]# ps -aux |grep mongo
polkitd   3010  1.3  8.6 1576112 87776 ?       Ssl  08:41   0:00 mongod --bind_ip_all
root      3114  0.0  0.0 112660   972 pts/0    S+   08:42   0:00 grep --color=auto mongo
[root@node2 ~]# docker stop mongo
[root@node2 ~]# ps -aux |grep mongo
root      3158  0.0  0.0 112660   968 pts/0    R+   08:43   0:00 grep --color=auto mongo
[root@node2 ~]# docker start mongo
[root@node2 ~]# docker container run -d --name nginx nginx
[root@node2 ~]# docker container run -d --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=true mysql
[root@node2 ~]# docker container top mysql
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
polkitd             7599                7582                2                   08:57               ?                   00:00:01            mysqld
[root@node2 ~]# docker container top nginx
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                7462                7446                0                   08:54               ?                   00:00:00            nginx: master process nginx -g daemon off;
101                 7493                7462                0                   08:54               ?                   00:00:00            nginx: worker process
[root@node2 ~]#
[root@node2 ~]# docker container inspect mysql
[root@node2 ~]# docker container inspect nginx
[root@node2 ~]# docker container stats
CONTAINER ID        NAME                CPU %               MEM USAGE / LIMIT     MEM %               NET I/O             BLOCK I/O           PIDS
488be6106b2c        mysql               0.64%               369.7MiB / 992.4MiB   37.26%              648B / 0B           506MB / 966MB       38
58987bf1b3d3        nginx               0.00%               1.367MiB / 992.4MiB   0.14%               648B / 0B           0B / 0B             2
b1c486b813e1        mongo               0.27%               67.63MiB / 992.4MiB   6.81%               648B / 0B           34.9MB / 839kB      32

[root@node2 ~]# docker container run -it --name proxy nginx bash
[root@node2 ~]# docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
488be6106b2c        mysql               "docker-entrypoint.s…"   7 minutes ago       Up 7 minutes        3306/tcp, 33060/tcp   mysql
58987bf1b3d3        nginx               "nginx -g 'daemon of…"   10 minutes ago      Up 10 minutes       80/tcp                nginx
b1c486b813e1        mongo               "docker-entrypoint.s…"   22 minutes ago      Up 20 minutes       27017/tcp             mongo
[root@node2 ~]# docker container ls -a
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                      PORTS                 NAMES
66636011299a        nginx               "bash"                   About a minute ago   Exited (0) 11 seconds ago                         proxy
488be6106b2c        mysql               "docker-entrypoint.s…"   7 minutes ago        Up 7 minutes                3306/tcp, 33060/tcp   mysql
58987bf1b3d3        nginx               "nginx -g 'daemon of…"   10 minutes ago       Up 10 minutes               80/tcp                nginx
b1c486b813e1        mongo               "docker-entrypoint.s…"   22 minutes ago       Up 20 minutes               27017/tcp             mongo
[root@node2 ~]#

[root@node2 ~]# docker container run -it --name ubuntu ubuntu
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
Digest: sha256:6e9f67fa63b0323e9a1e587fd71c561ba48a034504fb804fd26fd8800039835d
Status: Downloaded newer image for ubuntu:latest
root@44d60cf2443a:/#
root@44d60cf2443a:/# apt-get update
Get:1 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:3 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [795 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]     
Get:6 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1344 kB]
Get:7 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [761 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [6781 B]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [19.2 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [13.5 kB]
Get:11 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [11.3 MB]
Get:12 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [186 kB]           
Get:13 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [1322 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [10.5 kB]
Get:15 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [32.7 kB]
Get:16 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [1057 kB]
Get:17 http://archive.ubuntu.com/ubuntu bionic-backports/main amd64 Packages [2496 B]
Get:18 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [4244 B]
Fetched 17.4 MB in 5s (3761 kB/s)                         
Reading package lists... Done
root@44d60cf2443a:/#
root@44d60cf2443a:/# apt-get install curl -y
root@44d60cf2443a:/# curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
root@44d60cf2443a:/#

[root@node2 ~]# docker container start -ai ubuntu
root@44d60cf2443a:/# curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
root@44d60cf2443a:/#
[root@node2 ~]# docker container  exec -it mysql bash

[root@node2 ~]# docker container ls
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                 NAMES
488be6106b2c        mysql               "docker-entrypoint.s…"   19 minutes ago      Up 19 minutes       3306/tcp, 33060/tcp   mysql
58987bf1b3d3        nginx               "nginx -g 'daemon of…"   22 minutes ago      Up 22 minutes       80/tcp                nginx
b1c486b813e1        mongo               "docker-entrypoint.s…"   34 minutes ago      Up 32 minutes       27017/tcp             mongo
[root@node2 ~]#
[root@node2 ~]# docker container run -it alpine bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown.
[root@node2 ~]# docker container run -it alpine sh
/ #

[root@test test1]# echo $HOME /root [root@test test1]# echo $USER root [root@test test1]# [root@test test1]# cat sayH.sh echo ...

[root@test test1]# echo $HOME
/root
[root@test test1]# echo $USER
root
[root@test test1]#


[root@test test1]# cat sayH.sh
echo " Type your first name"
read fname
echo "MY first name is" $fname
[root@test test1]#



How to change a color in shell script

Black="\[\033[0;30m\]"        # Black
Red="\[\033[0;31m\]"          # Red
Green="\[\033[0;32m\]"        # Green
Yellow="\[\033[0;33m\]"       # Yellow
Blue="\[\033[0;34m\]"         # Blue
Purple="\[\033[0;35m\]"       # Purple
Cyan="\[\033[0;36m\]"         # Cyan
White="\[\033[0;37m\]"        # White

Red="\[\033[1;31m\]"          # Bold Red
Red="\[\033[4;31m\]"          # Underline in Red
echo -e "\n\n ${Red}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${Green}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${Yellow}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${Blue}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${Purple}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${Cyan}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"
echo -e "\n\n ${White}.................Copying user.sh to /etc/profile.d. This will set timestamp format for command history .....${NC}"


How to change line and output

[root@test test1]# echo -n "Do not output the trailing new line"
Do not output the trailing new line[root@test test1]#

[root@test test1]# echo -e "Do not output the trailing new line"
Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "\a Do not output the trailing new line"
 Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "\b Do not output the trailing new line"                                                                                                           Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "\c Do not output the trailing new line"
[root@test test1]#

[root@test test1]# echo -e "\n Do not output the trailing new line"

 Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "\r Do not output the trailing new line"
 Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "\t Do not output the trailing new line"
Do not output the trailing new line
[root@test test1]#

[root@test test1]# echo -e "An apple a day keeps away \a\t\tdoctor\n"
An apple a day keeps away doctor

How to exper use :-
==================================================================
[root@test test1]#

[root@test test1]# expr 1 + 3
4
[root@test test1]# expr 2 - 1
1
[root@test test1]# expr 10 / 2
5
[root@test test1]# expr 20 % 3
2
[root@test test1]# expr 10 \* 3
30
[root@test test1]# echo `expr 6 + 3`
9
[root@test test1]#

====================================================================

[root@test test1]# cat nestedif.sh
#osch=0

echo "1. Unix (Sun Os)"
echo "2. Linux (Red Hat)"
echo -n "Select your os choice [1 or 2]? "
read osch

if [ $osch -eq 1 ] ; then

     echo "You Pick up Unix (Sun Os)"

else #### nested if i.e. if within if ######
         
       if [ $osch -eq 2 ] ; then
             echo "You Pick up Linux (Red Hat)"
       else
             echo "What you don't like Unix/Linux OS."
       fi
fi
[root@test test1]#

======================================================================

[root@test test1]# cat elf.sh
#
#!/bin/sh
# Script to test if..elif...else
#
if [ $1 -gt 0 ]; then
  echo "$1 is positive"
elif [ $1 -lt 0 ]
then
  echo "$1 is negative"
elif [ $1 -eq 0 ]
then
  echo "$1 is zero"
else
  echo "Opps! $1 is not number, give number"
fi
[root@test test1]#

=======================================================================

[root@test test1]# cat mtable.sh
#!/bin/sh
#
#Script to test for loop
#
#
if [ $# -eq 0 ]
then
echo "Error - Number missing form command line argument"
echo "Syntax : $0 number"
echo "Use to print multiplication table for given number"
exit 1
fi
n=$1
for i in 1 2 3 4 5 6 7 8 9 10
do
echo "$n * $i = `expr $i \* $n`"
done
[root@test test1]#

========================================================================

Q:1 Why to use NFS ? Ans: A Network File System (NFS) allows remote machine to mount file systems over a network and interact with those ...

Q:1 Why to use NFS ?

Ans: A Network File System (NFS) allows remote machine to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources onto centralized servers over the network.

Q:2 What is the default port of NFS server ?

Ans: By default NFS uses 2049 TCP port.

Q:3 What are different versions of NFS Server ?

Ans: Currently, there are three versions of NFS. NFS version 2 (NFSv2) is older and widely supported. NFS version 3 (NFSv3) supports safe asynchronous writes and is more robust at error handling than NFSv2; it also supports 64-bit file sizes and offsets, allowing clients to access more than 2Gb of file data.

NFS version 4 (NFSv4) works through firewalls and on the Internet, no longer requires an rpcbind service, supports ACLs, and utilizes stateful operations. Red Hat Enterprise Linux 6.X & Centos 6.X supports NFSv2,NFSv3, and NFSv4 clients. When mounting a file system via NFS, Red Hat Enterprise Linux uses NFSv4 by default, if the server supports it.

Q:4 What are configuration files of NFS server ?

Ans: ‘/etc/exports’ is the main configuration file that controls which file systems are exported to remote hosts and specifies options.
‘/etc/sysconfig/nfs‘ is the file through which we can fix ports for RQUOTAD_PORT, MOUNTD_PORT, LOCKD_TCPPORT, LOCKD_UDPPORT and STATD_PORT

Q:5 What are different options used in /etc/exports file ?

Ans: Below are list of options used in /etc/exports file :

ro: The directory is shared read only; the client machine will not be able to write to it. This is the default.
rw: The client machine will have read and write access to the directory.
root_squash: By default, any file request made by user root on the client machine is treated as if it is made by user nobody on the server. (Exactly which UID the request is mapped to depends on the UID of user “nobody” on the server, not the client.)
no_root_squash : if this option is used , then root on the client machine will have the same level of access to the files on the system as root on the server. This can have serious security implications, although it may be necessary if you want to perform any administrative work on the client machine that involves the exported directories. You should not specify this option without a good reason.
no_subtree_check : If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers.
sync : Replies to the NFS request only after all data has been written to disk. This is much safer than async, and is the default in all nfs-utils versions after 1.0.0.
async : Replies to requests before the data is written to disk. This improves performance, but results in lost data if the server goes down.
no_wdelay : NFS has an optimization algorithm that delays disk writes if NFS deduces a likelihood of a related write request soon arriving. This saves disk writes and can speed performance
wdelay : Negation of no_wdelay , this is default
nohide : Normally, if a server exports two filesystems one of which is mounted on the other, then the client will have to mount both filesystems explicitly to get access to them. If it just mounts the parent, it will see an empty directory at the place where the other filesystem is mounted. That filesystem is “hidden”. Setting the nohide option on a filesystem causes it not to be hidden, and an appropriately authorised client will be able to move from the parent to that filesystem without noticing the change.
hide : Negation of nohide This is the default
Q:6 How to list available nfs share on local machine & remote machine ?

Ans: ‘showmount -e localhost’ : Shows the available shares on your local machine
‘showmount -e <Remote-server-ip or hostname>‘: Lists the available shares at the remote server

Q:7 What is pNFS ?

Ans: Parallel NFS (pNFS) as part of the NFS v4.1 standard is available as of Red Hat Enterprise Linux 6.4. The pNFS architecture improves the scalability of NFS, with possible improvements to performance. That is, when a server implements pNFS as well, a client is able to access data through multiple servers concurrently. It supports three storage protocols or layouts: files, objects, and blocks.

Q:8 What is the difference between Hard mount & Soft mount in nfs ?

Ans:  Difference between soft mount and hard mount is listed below :

 Soft Mount : Consider we have mounted a NFS share using ‘soft mount’ . When a program or application requests a file from the NFS filesystem, NFS client daemons will try to retrieve the data from the NFS server. But, if it doesn’t get any response from the NFS server (due to any crash or failure of NFS server), the NFS client will report an error to the process on the client machine requesting the file access. The advantage of this mechanism is “fast responsiveness” as it doesn’t wait for the NFS server to respond. But, the main disadvantage of this method is data corruption or loss of data. So, this is not a recommended option to use.
Hard Mount : Suppose we have mounted the NFS share using hard mount, it will repeatedly retry to contact the server. Once the server is back online the program will continue to execute undisturbed from the state where it was during server crash. We can use the mount option “intr” which allows NFS requests to be interrupted if the server goes down or cannot be reached. Hence the recommended settings are hard and intr options.
Q:9 How to check iostat of nfs mount points ?

Ans: Using command ‘nfsiostat‘ we can list iostat of nfs mount points. Use the below command :
# nfsiostat <interval> <count> <mount_point>

<interval> : specifies the amount of time in seconds between each report. The first report contains statistics for the time since each file system was mounted. Each subsequent report contains statistics collected during the interval since the previ-ous report.

<count> : If the <count> parameter is specified, the value of <count> determines the number of reports generated at seconds apart. if the interval parameter is specified without the <count> parameter, the command generates reports continuously.

<mount_point> : If one or more <mount point> names are specified, statistics for only these mount points will be displayed. Otherwise, all NFS mount points on the client are listed.

Q:10 How to check nfs server version ?

Ans: ‘nfsstat -o all’ command shows all information about active versions of NFS.

Q:11 What is portmap?

Ans: The portmapper keeps a list of what services are running on what ports. This list is used by a connecting machine to see what ports it wants to talk to access certain services.

Q:12 How to reexport all the directories of ‘/etc/exports’ file ?

Ans: Using the command ‘ exportfs -r ‘ , we can reexport or refresh entries of ‘/etc/exports’ file without restarting nfs service

User Management Interview Questions: 1. How to create a user ? Brief with full syntax.. /usr/sbin/useradd -u uid -g gid -c " User De...

User Management Interview Questions:
1. How to create a user ? Brief with full syntax..
/usr/sbin/useradd -u uid -g gid -c " User Descriptions" -m -d "Home Directory Path" -s "Shell" username
Example :
#useradd -u 535 -g unix -c "Unixrock blog" -m -d /export/home/unixrock -s /usr/bin/bash unixrock

–u UID ( From 0 to 65535 ) , 0 is reserved for root
-g Primary Group
-m Force to Create Home Directory Specified by –d and copy default skeleton files in /etc/skel folder
-d User Home Directory Path
-c User Descriptions
-s Shell Path
2. What are the important files for User Management task?
/etc/passwd
/etc/shadow
/etc/group
/etc/default/passwd
/etc/default/login

3. Describe the /etc/passwd fields ?
/etc/passwd file is having 7 fields
username:password:uid:gid:comment:home-directory-path:login-shell
Example :
unixrock:x:535:121:Unixrock blog:/export/home/unixrock:/usr/bin/bash

4. Describe the /etc/shadow file fields ?
/etc/shadow file is having 9 fields
loginID:password:lastchg:min:max:warn:inactive:expire:reserved
Example:
unixrock:R1EbI61VDyM2I:15995:7:91:7:::

5. Describe the /etc/group file fields ?
/etc/group file is having 4 fields
groupname:group-pwd:GID:user-list
Example:
unixrock::121:unixrock, raj

6. What is the different between "su  UserID" and "su - UserID" ?
"su UserID"     -  Doesn't check the PATH and Current Working Directory
"su - UserID"   -  Load the User's Profiles  (PATH/Current Working Directory)

7. Default permission of Passwd/Shadow/Group files ?
/etc/passwd 644
/etc/shadow 644
/etc/group    400
bash-3.00# ls -ld /etc/passwd /etc/shadow /etc/group
-rw-r--r--   1 root     sys          459 Dec 10 16:32 /etc/group
-rw-r--r--   1 root     sys        18498 Dec 11 09:09 /etc/passwd
-r--------   1 root     sys        10334 Dec 11 09:35 /etc/shadow
bash-3.00#

8. Default permission of file and Directory ?
Default permission of file is 644  (666 - 022 (umask vaule))
Default permission of directory is 755  (777 -022 (umask vaule))

9. How to view the list of users who currently logged in the system ?
"who" command will show the users who logged in the current system.
The command refers /var/adm/utmpx to obtain the information.
bash-3.00# who
root       pts/2        Sep 10 22:11    (192.168.10.22)
root       pts/3        Dec 11 22:55    (192.168.10.22)
bash-3.00#
bash-3.00# ls -ld /var/adm/utmpx
-rw-r--r--   1 root     bin         2976 Dec 11 22:55 /var/adm/utmpx
bash-3.00# file /var/adm/utmpx
/var/adm/utmpx: data
bash-3.00#

10. How to view the User's login and logout details ?
"last " command will show the users login and logout details.
The command refers /var/adm/wtmpx to obtain the information.
bash-3.00# last
root      pts/3        192.168.10.22    Wed Dec 11 22:55   still logged in
root      sshd         192.168.10.22    Wed Dec 11 22:55   still logged in
root      pts/2        192.168.10.22    Tue Sep 10 22:11   still logged in
root      sshd         192.168.10.22    Tue Sep 10 22:11 - 22:55 (92+00:43)
reboot    system boot                   Tue Sep 10 22:03
reboot    system down                   Fri Sep  6 17:59
wtmp begins Tue Aug 13 01:32
bash-3.00#
bash-3.00# ls -ld /var/adm/wtmpx
-rw-r--r--   1 adm      adm        68820 Dec 11 22:55 /var/adm/wtmpx
bash-3.00# file /var/adm/wtmpx
/var/adm/wtmpx: data
bash-3.00#

11. How to view details information about the User?
"finger username" will show the details about the user.
bash-3.00# finger unixrock
Login name: unixrock
Directory: /home/unixrock               Shell: /bin/sh
Never logged in.
No unread mail
No Plan.
bash-3.00#

12. Describe about SETUID/SETGID/StickyBIT ?
SETUID/SETGID/StickyBIT

13. How to check Primary and Secondary Group of One User ?
"id -a username" will show the user's Primary and Secondary groups.
FYI, One User can be added in 15 no; of Secondary groups, But Only one Primary Group.
bash-3.00# id -a unixrock
uid=100(unixrock) gid=1(other) groups=1(other)
bash-3.00#
gid - Primary Group
groups - Secondary Group

14. How to rename the existing User ID ?
# usermod -l <newname> <oldname>
bash-3.00# usermod -l unixrock_new unixrock
UX: usermod: unixrock name too long.
bash-3.00# grep -i unixrock /etc/passwd
unixrock_new:x:100:1::/home/unixrock:/bin/sh
bash-3.00#

15. How to lock the User Account ?
# passwd -l UserID
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00# passwd -l unixrock
passwd: password information changed for unixrock
bash-3.00# passwd -s unixrock
unixrock  LK
bash-3.00#

16. How to unlock the User Account?
# passwd -u <UserID>
bash-3.00# passwd -s unixrock
unixrock  LK
bash-3.00# passwd -u unixrock
passwd: password information changed for unixrock
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00#

17. How to make the user account as non-expriry ?
# passwd -x -1 <userID>
bash-3.00# passwd -s unixrock
unixrock  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -x -1 unixrock
passwd: password information changed for unixrock
bash-3.00#
bash-3.00# passwd -s unixrock
unixrock  PS
bash-3.00#

18. How do we set force passwd change for User's first login ?
# passwd -f  <UserID>
bash-3.00# passwd -s unixrock
unixrock  PS    12/11/13     7    91     7
bash-3.00#
bash-3.00# passwd -f unixrock
passwd: password information changed for unixrock
bash-3.00#
bash-3.00# passwd -s unixrock
unixrock  PS    00/00/00     7    91     7
bash-3.00#

19. How to delete the User ID ?
# userdel <UserID> or # userdel -r <UserID>

-r option will delete the User's Home directory too.

20. Type of SHELLs ? What is initialization file for those SHELLS ?

/bin/bash  - Bourne Again shell
/bin/csh    - C shell
/bin/ksh   - Korn shell
/bin/tcsh   - TC shell
/bin/zsh    - Z shell

Bourne   /etc/profile    $HOME/.profile   /bin/sh     /etc/skel/local.profile
Korn      /etc/profile    $HOME/.profile   /bin/ksh   /etc/skel/local.profile
                                  $HOME/.kshrc
C           /etc/.login      $HOME/.cshrc    /bin/csh   /etc/skel/local.cshrc
                                  $HOME/.login                   /etc/skell/local.login

21. How to Check the User's Crontabs ? How to allow the User to access the Cron?
# crontab -l <username>
or
# ls -ltr /var/spool/cron/crontabs/

/etc/cron.d/cron.allow  : If the file exists, the users can use crontab whoever listed in that file.

22. How to check User's Present Working Directory Path? How to check the Obsolete Path of running process ?
Find the Present Working Directory Path
# pwd

Q: Which Users tare not allowed to login via ftp ? Ans: Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ft...

Q: Which Users tare not allowed to login via ftp ?
Ans: Users mentioned in the file ‘/etc/vsftpd/ftpusers’ are not allowed to login via ftp.
Q: What is default directory for ftp / Anonymous user ?
Ans : ‘/var/ftp’ is the default directory for ftp or Anonymous user

Q: How to change the default directory for ftp / Anonymous user ?
Ans: Edit the file ‘/etc/vsftpd/vsftpd.conf’ and change the below directive :

anon_root=/<Path-of-New-Directory>
After making above change either restart or reload vsftpd service.

Q: How to disable Anonymous user in vsftpd ?
Ans: Edit the conf file ‘/etc/vsftpd/vsftpd.conf’ and change below directive and restart the ftp service.

anonymous_enable=NO

Q: What is chroot environment in ftp server ?
Ans: chroot environment prevents the user from leaving its home directory means jail like environment where users are limited to their home directory only. It is the addon security of ftp server.

Q: How to enable chroot environment in vsftpd server ?
Ans : To enable chroot environment edit the file ‘/etc/vsftpd/vsftpd.conf’ and enable the below directives :

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
The chroot_list_file variable specifies the file which contains users that are chroot.

Q: How to enable only limited/allowed users are able to login via ftp ?
Ans: This can be done by editing the file ‘/etc/vsftpd/vsftpd.conf’ and add the below directives :

userlist_enable=YES
userlist_file=/etc/vsftpd.user_list
userlist_deny=NO

Q: How to set ftp banner in linux ?
Ans: Open the file ‘/etc/vsftpd/vsftpd.conf’ and set the below directive :

ftpd_banner= “Enter New Banner Here”

Q: How To limit the data transfer rate, number of clients & connections per IP for local users ?
Ans: Edit the ftp server’s config file(/etc/vsftpd/vsftpd.conf) and set the below directives :

local_max_rate=1000000 # Maximum data transfer rate in bytes per second
max_clients=50 # Maximum number of clients that may be connect

1. NFS is a protocol that allows a user to access files over a network; Samba is essentially a re-imaging of the Common Internet File Syste...

1. NFS is a protocol that allows a user to access files over a network; Samba is essentially a re-imaging of the Common Internet File System.

2. NFS has four versions, the newest of which includes a stateful protocol; Samba has multiple versions, the latest of which allows file and print sharing between multiple computers.


SMB (Server Message Block)
0:16 – Server Message Block or SMB was originally designed by IBM back in the 80’s. After its inception, Microsoft took the protocol and added some features to it. The additions included features such as LAN Manager. Services such as this allowed Windows systems to map shared drives and have this new share act as a local drive on the computer.  For simplicity’s sake, I will skip the 3rd and 4th point but we will get back to those in a minute. With the release of Windows Vista, Microsoft also released SMB 2.0. This was a major revision of SMB which, besides adding additional features, reduced the “chattiness” of the protocol. In other words, it reduced the bandwidth used or data amount transmitted, over the network. SMB 3.0 was released with Windows 8 and Server 2008 R2. With more improvements and added functionality, SMB 3.0 was aimed towards increasing effectiveness in Datacenters. When mapping a share, Windows will automatically perform the negotiation and sort out what version of SMB to use.

Now what were the points that we skipped? In the late 90’s Microsoft had attempted to rename SMB to CIFS or Common Internet File System. Unfortunately for Microsoft, this attempt was unsuccessful so they were skipped in order to avoid confusion. CIFS had additional features, but the name simply did not catch on and Microsoft simply went back to SMB in future versions. Due to this, CIFS is referred to as a dialect of SMB though you may hear CIFS and SMB used synonymously, but they are basically referring to Windows file sharing. Moving forward however, the term CIFS should really not be used as it is a relic of the past and it should only be considered SMB.

NFS (Network File System)
2:04 – The next file system we will be examining is Network File System, or NFS. Originally developed by Sun in the late 80’s, NFS version 1 was used internally within Sun Microsystems and never released publically. It was Version 2 that was released to the public however. This provided basic file sharing capabilities and was used extensively within Unix based systems. As they released Version 3 in 1995, it was enhanced to add 64bit support and was able to handle files larger than 2 gigabytes. In 2000, Sun released version 4 of NFS with added performance along with security improvements. This allowed for security methods to be applied and utilized to authenticate users, e.g. Kerberos. These security measures made NFS version 4 much more secure when compared to previous revisions.

In The Real World
2:56 - Now I want to ask you a question. In the real world, which protocol would you use? Windows shares support both SMB and NFS, or even both at the same time. It is merely a matter of configuring which one you need or configuring both if you need to utilize both. Ideally, you’ll want to use a native protocol when possible. For example, if you are connecting two Unix systems, it will be best to utilize NFS. If you are connecting two Windows systems, SMB would be the obvious choice. Even though both achieve the goal of file sharing, there are differences in the way Windows and Unix based systems handle file systems and the users that will be using the systems. Mixing the two can lead to compatibility problems. As NFS is good for host authentication, it makes connecting two servers together rather easy. This can be placed in the boot up configuration and the data would be available to the operating system without the need for a user to be logged in. You could even connect to another server based on the IP address alone. Conversely, Windows requires user authentication in order to connect to an SMB share and generally the user is required to be logged in. It is possible to circumvent this and you would do this for some services running on the local system, but it is, unfortunately, not as simple as NFS makes it. Windows is an excellent choice for using authentication. Until NFS version 4, this was something that NFS did not handle well and was prone to more security problems. If you are using a domain, then Windows handles user authentication very well. Ultimately, the decision will be made on what operating systems you are using and your software requirements. In future videos, we will discuss how Windows file sharing (SMB) works and also how to incorporate NFS using Windows Server.  

FTP means File Transfer Protocol while SFTP means Secured File Transfer Protocol. FTP uses Port 21 whereas SFTP uses Port 22. SFTP shares...

FTP means File Transfer Protocol while SFTP means Secured File Transfer Protocol.
FTP uses Port 21 whereas SFTP uses Port 22.
SFTP shares its files with full security whereas FTP uploads or downloads its data without any security.
Filezilla is best for FTP whereas winSCP is regarded best for SFTP.
FTP sends data in plain text while SFTP provides a little bit of privacy.
FTP is used by anyone whereas SFTP is used by server owner because 22 port is not open in case of shared hosting.
SFTP is fully secured and satisfactory whereas FTP is less secured.

OS BOOT TIME RHEL6: 40 sec RHEL7: 20 sec MAXIMUM SIZE OF SINGLE PARTITION RHEL6: 50TB(EXT4) RHEL7: 500TB(XFS) BOOT LOADER RHEL6:...

OS BOOT TIME
RHEL6: 40 sec

RHEL7: 20 sec

MAXIMUM SIZE OF SINGLE PARTITION
RHEL6: 50TB(EXT4)

RHEL7: 500TB(XFS)

BOOT LOADER
RHEL6:  /boot/grub/grub.conf

RHEL7: /boot/grupb2/grub.cfg

PROCESSOR ARCHITECTURE
RHEL6: It support 32bit & 64bit both

RHEL7: It only support 64bit

HOW TO FORMAT OR ASSIGN A FILE SYSTEM IN
RHEL6:      #mkfs.ext4   /dev/hda4

RHEL7:       #mkfs.xfs   /dev/hda3

HOW TO REPAIR A FILE SYSTEM IN
RHEL6:  #fsck -y /dev/hda3

RHEL7:  #xfs_repair /dev/hda3

COMMAND TO MANAGE NETWORK IN RHEL6 AND RHEL7
RHEL6:  #setup

RHEL7:  #nmtui

HOSTNAME CONFIGURATION FILE
RHEL6:    /etc/sysconfig/network

RHEL7:    /etc/hostname

DEFAULT ISO IMAGE MOUNT PATH
RHEL6: /media

RHEL7: /run/media/root

FILE SYSTEM CHECK
RHEL6:   e2fsck

RHEL7:   xfs_repair

RESIZE A FILE SYSTEM
RHEL6:   #resize2fs -p /dev/vg00/lv1

RHEL7:    #xfs_growfs  /dev/vg00/lv1

TUNE A FILE SYSTEM
RHEL6: tune2fs

RHEL7: xfs_admin

IPTABLES AND FIREWALL
RHEL6: iptables

RHEL7: firewalld

IPtables
To see firewall status in RHEL7

#firewall-cmd   –state

To see Firewall status in RHEL6

#service iptables status

To stop firewall in RHEL7

#systemctl stop firewalld.service

To stop firewall in RHEL6

#service iptables stop

COMMUNICATION BETWEEN TCP AND UDP IN BACK END
RHEL6: netcat

RHEL7: ncat

INTERFACE NAME
RHEL6: eth0

RHEL7: ens198(N)

COMBINING NIC
RHEL6: Network Bonding

RHEL7: Team Driver

NSF Server Version
RHEL6:  NFSv2

RHEL7:  NFSV4

DATABASE USED
RHEL6: Mysql

RHEL7: mariaDB

RHEL7 also support Mysql

MANAGING SERVICES
RHEL6:

#service sshd restart

#chkconfig sshd on

RHEL7:

#systemctl restart sshd

#systemctl enable shhd

File System.
RHEL6 default file system is ext4

xfs is RHEL7 default file system.

Kernel Version
RHEL6 default kernel version is 2.6 while RHEL7 is 3.10

UID Allocation
In RHEL6 default UID assigned to users would start from 500 while in RHEL7 it’s starting from 1000.
But this can be changed if required by editing /etc/login.defs file.

Maximum supported File Size.
In RHEL6 maximum file size of an individual file can be up to 16TB while in RHEL7 it can be up to 500TB which is very large in comparison to RHEL6.

Maximum Supported File System Size.
In RHEL6 maximum file system size=16TB (for 64bit Machine) and 8TB (for 32 bit machine). While in RHEL7 maximum file system size is 500TB.

Also keep in mind that RHEL does not support XFS on 32-bit machines.

Change in file system structure.
In rhel6 /bin,/sbin,/lib and /lib64 are usually under /

In rhel7, now /bin,/sbin,/lib and /lib64 are nested under /usr.

The /tmp directory can now be used as a temporary file storage system (tmpfs)

Space Required to Installing RHEL7?

Now if you want to install RHEL7 in your machine, RedHat recommends minimum 5 GB of disk space to install this release of RHEL series for all supported architectures.

.Hostname lookup and setup
In rhel5 and rhel6 versions, we can edit file /etc/sysconfig/network to set hostname but in rhel7 we can directly change the hostname using below commands.

hostnamectl
nmtui
nmcli
Example:

in RHEL6              #hostname

in RHEL7              #hostnamectl  status   and #hostname

Few More notable changes in RHEL 7.
Netstat and ifconfig commands also disappeared from RHEL7 but it can be used by installing net-tools.
The move from sysvinit to systemd is one of most important change that has been made and which is a matter of concerned.
Command tail -n is replaced by journalctl -n
Command tail -f is replaced by journalctl -f
For displaying kernel messages instead of dmesg now in RHEL7 we use journalctl –k

[root@ipaserver ~]# vmstat -s [root@ipaserver ~]# free -g [root@ipaserver ~]# free -h [root@ipaserver ~]# cat /proc/meminfo 

[root@ipaserver ~]# vmstat -s
[root@ipaserver ~]# free -g
[root@ipaserver ~]# free -h
[root@ipaserver ~]# cat /proc/meminfo 

Q. WHAT IS A PORT? A port is piece of software which is used as docking point in your machine, where remote application can communicate. T...

Q. WHAT IS A PORT?
A port is piece of software which is used as docking point in your machine, where remote application can communicate. This is analogy to the physical ports for entering in to a country from different sea ports.

Q. WHAT IS HARDWARE PORT?
This is a physical peripheral connecting point to a machine from a physical device.

Q. WHAT IS A SOCKET?
Socket is combination of software Port and IP address.

Q. WHAT IS THE RANGE OF PORTS OR HOW MANY PORTS ARE THERE?
Port numbers can vary from 0 to 65535, so total we can get 65536 ports

Q. WHY PORT NUMBERS ARE JUST 65536?
This is because limitation in TCP/IP stack where the port number field is just 16bit size. So we get only 2^16(2 to the power of 16) ports which are equal to 65536 available ports

Q. WHAT ARE THE WELL-KNOWN PORTS OR ASSIGNED PORTS OR DEFAULT PORTS?
Well known ports are from 0 to 1023(total 2^10=1024 ports)

Q. WHAT DO YOU MEAN BY DEFAULT PORT?
Default port is a designated port for particular well-known service such as web server, mail server, ftp server etc. By default FTP uses 21 port, DNS uses 53 and Apache uses 80 port.

Q. CAN WE CHANGE DEFAULT PORT FOR A SERVICE(EXAMPLE APACHE, SQUID)?
Yes, we can change. In Apache and DNS we can change this using listen configuration entry in httpd.conf and named.conf. Squid have port entry in it’s squid.conf file to mention port number.

Q. WHAT ARE THE PROTOCOL NUMBERS FOR TCP AND UDP?
Do not confuse this one with port numbers. TCP and UDP have their own numbers in TCP/IP stack.

TCP protocol number: 6

UDP protocol number: 17

Q. IS THERE ANY WAY I CAN SEE ALL THE PORT INFORMATION IN LINUX?
Yes, you can get that from /etc/services files.

Q. HOW CAN I SEE OPEN PORTS IN LINUX?
Use nmap command.

WELL KNOWN PORTS
20 – FTP Data (For transferring FTP data)

21 – FTP Control (For starting FTP connection)

22 – SSH (For secure remote administration which uses SSL to encrypt the transmission)

23 – Telnet (For insecure remote administration)

25 – SMTP (Mail Transfer Agent for e-mail server such as SEND mail)

53 – DNS (Special service which uses both TCP and UDP)

67 – Bootp

68 – DHCP

69 – TFTP (Trivial file transfer protocol uses udp protocol for connection less transmission of data)

80 – HTTP/WWW(Apache)

88 – Kerberos

110 – POP3 (Mail delivery Agent)

123 – NTP (Network time protocol used for time syncing uses UDP protocol)

137 – NetBIOS (nmbd)

139 – SMB-Samba (smbd)

143 – IMAP

161 – SNMP (For network monitoring)

389 – LDAP (For centralized administration)

443 – HTTPS (HTTP+SSL for secure web access)

514 – Syslogd (udp port)

636 – ldaps (both ctp and udp)

873 – rsync

989 – FTPS-data

990 – FTPS

993 – IMAPS

1194 – openVPN

1812 – RADIUS

995 – POP3s

2049 – NFS (nfsd, rpc.nfsd, rpc, portmap)

2401 – CVS server

3306 – MySql

3690 – SVN

* If you want to make allow request which is originated form the private instance should be able to reach internet you make use of NAT * ...

* If you want to make allow request which is originated form the private instance should be able to reach internet you make use of NAT

* The traffic which originated from the internet and for these private instance that's comes via ELB

* ELB work as a Reserve Proxy
* NAT Gateway work as a Forward proxy
* NAT Gateway should place in pulic subnet
* ELB should place in public or private subnet
* NAT and ELB  both are the managed services but NAT Gateway live in one subnet as a ELB if we choose correctly can spam in multiple subnet
* In NAT we have two options NAT instace and NAT Gateway
* NAT Gateway can live only one availability zone or we can choose only one subnet for one instance


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

Elastic Load Balancer

* ELB is mananged service by amazon
* ELB distribute the taffic to n number of instances which are registed to ELB
* ELB does check continious health check which are registred to ELB, in case any intance become unhealthy ELB will stop send traffic to that particular instance.
* Intenaly ELB launch the instance so it consomme the IP from your subnet hence keep some buffer in terms of private IP address
* You can move Web-server to private subnet and keep only ELB in public Subnet. Within a VPC all instances can talk to each other(irrespective of subnet)
* Traffic gets distributed between 2 AZs in roub-robin fashion, with in AZ there are n number of instances and request will go which have lease of connections
* ELB should be access by DNS not by IP address
* If we use check botton "Create an internal load balancer" then it will be private load balancer
* If we know the URL then we do choose httpd and URL path ohterwise we should choose TCP
* And you have to enable Cross-Zone Load Balancing and enable Connection Draining, it will distribute traffic in all instance of all AZ equaly

* And connection draining is a time which ELB  we give to that unhealthy instance has some open connections with in particular time instance can relese his connection

Appilcation Load Balancer

* If configured a clasic load balancer and register N number of ec2 instance then every instance would have same type of content or would have all the file similar
* Where as in case of application load balancer we can go head and create rules based on which any incoming request can go to specific target group

* On the physical host, ec2 is a VM, and EBS volume not their in physical host they are connected via a network to this particular host * ...

* On the physical host, ec2 is a VM, and EBS volume not their in physical host they are connected via a network to this particular host
* Where as Instance store is their on the physical host it self
* When we stop any ec2 instance the resoureces of that particular instace become free which means CPU RAM will be free but data which is available in EBS volume that is connect by network is remain their
* We stop and start the instance the underline hardware change but we reboot the ec2 instance only os whould reboot nothing will change
========================================================================================================================================
ec2 Auto Recovery:- Auto recovery is a process which helps you to recover your instance in case something went wrong at your H/W level or on the host level
Main two prars in auto recovery:-
(1) System status check:- There is some issue with the software of pysical host. We can not do any thing on system status check
(2) Instance status check:- Which are reletated to our ec2 instance level

Events:- If any actvity have planed by amazon side it will show in event, so we can plane to stop or any migration of our instance.
Limit:- Aws provide limit for luacnhing any service suppose any developer start a for infinity loop to lauch a instance and this loop lauch many instances, limit feature  stop these type of actvity. if we want to increase limit of any service have to request to AWS

Limits are two types:-
(1) Soft limit:- we can request to AWS to increase the limit of that particular service i.e. ec2, s3, vpc etc
(2) Hard limit:- We can not request to AWS to increase the limit of that service just like security group, rule in security grop etc.

Private IP:- Private IP address is associated with eithernet of ec2 instance, when we login any ec2 instance it shows, this ip address is not accessable from out side the world, and belogns to particular VPC, when we stop/satar/reboot the instance ip address does not change.

Public IP:- Public ip address is accessable from out side the world, but these are limited, so for any application internal communication we use only private IP, when we stop and start the ec2 instance public IP automatic relese and new public IP assign, if we reboot any instance then public IP does not change.

Elastic IP:- Elastic IP work as a public IP, we generate and elastic ip and accociate with any ec2 instance and if we stop and start that ec2 instance then public IP wil not change due to this elastic ip which is associated with particular instance.
 Suppose we want do migrated any appilcation and we create power full server configuration then as per elastic ip side we simple deattach elastic ip from older server and attach to new serve.

[root@docker ~]# aws ec2 describe-instances --instance-ids i-0734100aebc91b85c [root@docker ~]# aws ec2 stop-instances --instance-ids i-07...

[root@docker ~]# aws ec2 describe-instances --instance-ids i-0734100aebc91b85c
[root@docker ~]# aws ec2 stop-instances --instance-ids i-0734100aebc91b85c
[root@docker ~]# aws ec2 start-instances --instance-ids i-0734100aebc91b85c
[root@docker ~]# aws ec2 terminate-instances --instance-ids i-0734100aebc91b85c

Change hostname in AWS Linux server

[root@ip-172-31-20-169 ~]# rpm -qf /etc/cloud/cloud.cfg
[root@ip-172-31-20-169 ~]# rpm -qf /etc/cloud/cloud.cfg
[root@ip-172-31-20-169 ~]# vi /etc/cloud/cloud.cfg:- Add below parameter in mentioned file
preserve_hostname: true
[root@ip-172-31-20-169 ~]# vi /etc/hostname:- Give the hostname in mentioned file
awslabserver
[root@ip-172-31-20-169 ~]# vi /etc/hosts
172.31.20.169 awslabserver
[root@ip-172-31-20-169 ~]# init 6
[root@awslabserver ~]# uname -a
Linux awslabserver 4.14.138-114.102.amzn2.x86_64 #1 SMP Thu Aug 15 15:29:58 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

[root@docker ~]#  aws ec2 create-vpc --cidr-block 10.0.0.0/16            vpc-040630f59ce9188ea---VPCid [root@docker ~]# aws ec2 describe-v...

[root@docker ~]#  aws ec2 create-vpc --cidr-block 10.0.0.0/16            vpc-040630f59ce9188ea---VPCid
[root@docker ~]# aws ec2 describe-vpcs
[root@docker ~]# aws ec2 create-tags --resources vpc-040630f59ce9188ea --tags Key=Name,Value=CLI-VPC
[root@docker ~]# aws ec2 create-subnet --vpc-id vpc-040630f59ce9188ea --cidr-block 10.0.1.0/24
[root@docker ~]# aws ec2 create-tags --resources subnet-03b167b7e4e7fde24 --tags Key=Name,Value=Public-Subnet
[root@docker ~]# aws ec2 create-subnet --vpc-id vpc-040630f59ce9188ea --cidr-block 10.0.2.0/24
[root@docker ~]# aws ec2 create-tags --resources subnet-01f5fbf80d0bd44aa --tags Key=Name,Value=Private-Subnet
[root@docker ~]# aws ec2 describe-subnets
[root@docker ~]# aws ec2 create-internet-gateway
[root@docker ~]# aws ec2 create-tags --resources igw-04d67210fe8d1888f --tags Key=Name,Value=CLI-IGY
[root@docker ~]# aws ec2 attach-internet-gateway --internet-gateway-id igw-04d67210fe8d1888f --vpc-id vpc-040630f59ce9188ea
[root@docker ~]# aws ec2 allocate-address --domain vpc
[root@docker ~]# aws ec2 create-nat-gateway --subnet-id subnet-03b167b7e4e7fde24 --allocation-id eipalloc-0a804bd0125aeff3e
[root@docker ~]# aws ec2 create-tags --resources nat-0af1dfe5aa12ad301 --tags Key=Name,Value=CLI-Natgateway
[root@docker ~]# aws ec2 create-route-table --vpc-id vpc-040630f59ce9188ea
[root@docker ~]# aws ec2 create-tags --resources rtb-0828ddd487dfbb6cd --tags Key=Name,Value=CLI-PublicRouteTable
[root@docker ~]# aws ec2 create-route-table --vpc-id vpc-040630f59ce9188ea
[root@docker ~]# aws ec2 create-tags --resources rtb-03ddfa883bae4206f --tags Key=Name,Value=CLI-PrivateRouteTable
[root@docker ~]# aws ec2 create-route --route-table-id  rtb-0828ddd487dfbb6cd --destination-cidr-block 0.0.0.0/0 --gateway-id igw-04d67210fe8d1888f
[root@docker ~]# aws ec2 describe-route-tables
root@docker ~]# aws ec2 create-route --route-table-id rtb-03ddfa883bae4206f --destination-cidr-block 0.0.0.0/0 --nat-gateway nat-0af1dfe5aa12ad301
[root@docker ~]# aws ec2 associate-route-table --route-table-id rtb-0828ddd487dfbb6cd --subnet-id subnet-03b167b7e4e7fde24
[root@docker ~]# aws ec2 associate-route-table --route-table-id rtb-03ddfa883bae4206f --subnet-id subnet-01f5fbf80d0bd44aa
[root@docker ~]#  aws ec2 create-security-group --group-name CLI-WEB-Securitygroop --description "My Security Group" --vpc-id vpc-040630f59ce9188ea
[root@docker ~]# aws ec2 create-tags --resources sg-09b5d0442532e08d0 --tags Key=Name,Value=CLI-Security-SR
[root@docker ~]# aws ec2 authorize-security-group-ingress --group-id sg-09b5d0442532e08d0 --protocol tcp --port 22 --cidr 0.0.0.0/0
[root@docker ~]# aws ec2 authorize-security-group-ingress --group-id sg-09b5d0442532e08d0 --protocol tcp --port 80 --cidr 0.0.0.0/0
[root@docker ~]# aws ec2 create-key-pair --key-name Mykey123
[root@docker ~]# aws ec2 run-instances --image-id ami-04b762b4289fba92b  --count 1 --instance-type t2.micro --key-name Mykey123 --security-group-ids sg-09b5d0442532e08d0 --subnet-id subnet-03b167b7e4e7fde24