[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