Monday, October 17, 2016

Samba Server


1.            What is Samba  and  explain it?
                (i)            An open source implementation of the SMB file sharing protocolthat provides file and print services to                                             SMB/CIFS clients. Samba allows a non-Windows server to communicate with the same networking protocol                    as the Windows products.
                (ii)           Samba allows Linux computers to share files and printers across a network connection by using  SMB                                               protocol. Samba will support  DFS, NFS,  ufs  file systems to share files and directories. That's why  Samba  is                   used to share files and directories between different platforms.
                (iii) Samba will support printer sharing and it requires authentication.
2.            What are the differences between  Samba   and  NFS?
                (i)            Samba supports to all O/S  platforms,  whereas  NFS will support the same platforms only.
                (ii)           There is a security in Samba because  Samba requires authentication,  whereas  in  NFS  there is no security if                 there is no kerberos because  NFS does not requires authentication.
                (iii)          Samba will support printer sharing,  whereas  NFS  will not support printer sharing.
3.            What are the different file systems for sharing different  O/S?
                (i)            Windows    ---   Windows   ----->   Distributed  File system  (DFS)
                (ii)           Linux      ---  Linux   ----->   Network File system  (NFS)
                (iii)          Unix        ---  Unix   ----->   Network File system  (NFS)
                (iv)          Apple  MAC    ---   Apple  MACs   ----->  Apple  File sharing  Protocol  (AFP)
                (v)           Windows    ---   Linux   ----->   Common  Internet  File  system  (CIFS)
4.            What are the requirements  or  what is the profile of  Samba?
                (i)            Packages               :               samba*  for  samba server  and  samba-client*  for  samba client
                (ii)           Deamons               :               smbd  and  nmbd   for  RHEL - 6  where as  smbd  is for Samba server deamon  and                                                                                                                                                                          nmbd  is for Netbios  service  deamon.
                                                                                                smb  and  nmb  for  RHEL - 7  where as  smb  is for Samba server deamon  and  nmb                                                                                                                                                                               is for Netbios  service deamon.
                (iii)          Scripting  files        :               /etc/init.d/smb     and   /etc/init.d/nmb
                (iv) Port  number  :               137  --->  to verify the share name,   138  --->  to data transfer,  
                                                                                                139  --->  to connection establish  and   445  --->  for  authentication
                (v)           Log file                   :               /var/log/samba
                (vi) Configuration                 :               /etc/samba/smb.conf
                (vii) File systems    :               CIFS  (Common  Internet  File system)
5.            How to configure the  Samba  server?
                (i)            Install  the  samba package by   # yum  install  samba*   -y    command.
                (ii)           Create  a  samba shared directory by   # mkdir    /samba    command.
                (iii) Modify the permissions of the above samba shared directory.
                                                # chmod    777   /samba
                (iv) Modify the SELinux  context  of the samba directory if  SELinux is enabled.
                                                # chcon    -t    samba_share_t    /samba
                (v) Create the samba user  and  assign the password for the samba user.
                                                # useradd     raju                                                                                                                  (to create the samba user)
                                                # smbpasswd    -a    raju                                                         (to assign the samba password for the user raju)
                (vi)          Assign the  ACL  permissions  (like  read,  write  and  execute)  to the above shared directory if it is necessary.
                                                # setfacl    -m   u : : rwx  
                                                Example# setfacl     -m   u:raju:rwx    /samba
                (vii) Open the samba configuration file  and  put an entries of the Samba configuration.
                                                # vim   /etc/samba/smb.conf
                                                Go to last  line and copy the last  7 lines  and  paste them at last. And then modify as below.
                                                [samba]                                                                                                                 (this is the samba shared name)
                                                comment = public stuff                                                                                                        (this is a comment for samba)
                                                path = /samba                                                                                                                      (share directory name with full path)                       public  =  yes                                                                                                                         (means  no authentication)
                                                =  no                                                                                                                       (means requires authentication)
                                                writable = yes                                                                                                                        (in read-write mode)
                                                                = no                                                                                                                        (in read only mode)
                                                printable = no                                                                                                                       (printing is not available)
                                                                   = yes                                                                                                                    (printing is available)
                                                write list = raju                                                                                                      (to give the write permission to user raju)
                                                                  = +                                                                              (to give the write permission to the group)
                                                valid users = raju, u2 or  @group 1, @group 2                               (to give the authentication to the users or  groups)
                                                hosts allow = IP 1  or  IP 2  or  host 1  or  host2  or    or            (to share                                                                                                                                      the directory to IP 1  or  IP 2  or  host 1  or  host2)
                                                work group =                  (to share the directory to the windows work group)
                                                create mask = 644                                                                       (the files created by samba users with  644 permission)
                                                directory mask = 744  or  755                    (the directories created by samba users with  744  or  755 permissions)
                                                (save  and  exit  the  configuration  file)
                (viii) Verify  the configuration file  for  syntax  errors  by   # testparm    command.
                (ix) Restart the samba deamons in RHEL - 6  and  RHEL - 7.
                                                # service  smbd  nmbd  restart                                                                          (to restart the samba services  in  RHEL - 6)
                                                # chkconfig  smbd  nmbd  on                                                   (to enable the samba services at next boot  in  RHEL - 6)
                                                # systemctl  restart  smb  nmb                                                                          (to restart the samba services  in  RHEL - 7)
                                                # systemctl  enable  smb  nmb                                                 (to enable the samba services at next boot  in  RHEL - 7)
                (x) Add the samba service to  IP tables  and  Firewall.
                                                # setup               (then select Firewall configuration option to add the service to IP tables  in  RHEL - 6)
                                                # service  iptables  restart                                                                             (to restart the  IP tables  in  RHEL - 6)
                                                # firewall-cmd   --permanent   --add-service=samba      (to add the samba service to firewall  in  RHEL - 7)                                  # firewall-cmd    --complete-reload                                                                (to reload the firewall  in RHEL - 7)
6.            How to access the samba share directory at client side?
                (i)            Install  client side  samba packages  by   # yum  install  samba-client*   cifs-utils     -y    command.
                (ii)           Check the samba shared directory names from client side.
                                                # smbclient    -L   //   (then it will ask password, here don't enter                                                                                                                                      any password because it does not require any password)
                                                Example :# smbclient    -L   //server9.example.com   or  172.25.9.11
                                (iii) connect the samba server with user credentials and access the samba shared directory.
                                                # smbclient     ///    -U    (Where  U  is Capital  Letter  and  we have to enter the user's  samba password)
                                                Example :    # smbclient    //server9.example.com/samba   -U   raju     (then   smb :/>   prompt  appears)
                                                smb:/>   ls                                                                                             (to see the contents of the samba shared directory)
                                                smb:/>   pwd                                                                                        (to see the present working directory)
                                                smb:/>   ! ls                                                                                           (to see the client's  local directory contents)
                                                smb:/> get                                                                        (to download the specified file from samba server)
                                                smb:/>   mget   ...            (to download multiple  files from samba server)
                                                smb:/>   put                                                     (to upload the specified file to the samba server)
                                                smb:/>   put   ...              (to upload multiple files to the samba server)
                                                smb:/>   exit                                                                                          (to exit from the samba server)
7.            How to mount the samba shared directory permanently?
                (i)            Create the mount point for the samba shared directory.
                                                # mkdir   /mnt/samba
                (ii)           Put an entry of the mount point details in  /etc/fstab   file.
                                                # vim   /etc/fstab
                                                   ///   cifs   defaults ,                                                                                              username=, password=    0    0
                                                Example :   //server9.example.com/samba      /mnt/samba     cifs   defaults, username=raju,                                                                                                                                                password=     0    0                  (save  and  exit  this  file)
                (iii) Mount all the mount points which are having entries in  /etc/fstab    file.
                                                # mount    -a
                (iv) Check all the mount points  by   # df   -hT    command.
8.            How to mount the samba shared directory using credential file?
                (i)            Create  one file and put an entries of the user name and password details.
                                                # vim   /root/smbuser
                                                  username=raju
                                                  password=                                                                                                 (save  and  exit  the  file)
                (ii)           Open  /etc/fstab   file  and  put an entries of the above credential details of user.
                                                # vim  /etc/fstab
                                                 //server9.example.com/samba     /mnt/samba     cifs     credentials=/root/smbuser,  multiuser,  sec=ntlmssp                                                                                                                                                                                                                                       0    0
                                                (save  and  exit  this  file)
9.            How to access the samba share directory if it already mounted?
                (i)            Go to Client system and switch to samba user.
                                                # su   -  raju
                                                $ cd   /mnt/samba
                                                $ ls                                                                                                          (permission denied message will be displayed)
                                                $ cifscreds   add   (to add  cifs  credentials to the server)
                                                $ ls                                                                                                          (to see the contents of the samba shared directory)
10.          How to access the samba server from  windows system?
                (i) Goto Windows system,  click on  START  button,  click on  Run  and  type  as  \\172.25.9.11\samba command.
                (ii) Then  provide  samba user name  and  password  if it prompts us.
                (iii) Then see the contents of the samba shared directory.
                Other  useful  commands :
                # smbpasswd     -a                                                        (to add the samba password to the samba user)
                # smbpasswd     -d                                                                        (to disable the samba user's  password)
                # smbpasswd     -e                                                                         (to enable the samba user's  password)
                # smbpasswd     -r                                                                         (to remove the samba user's  password)
                # smbpasswd     -x                                                                         (to delete the samba user's  password)
                # smbpasswd     -n                                                                        (to set the samba user's  password as  null)
                # findsmb                                                                                     (to check how many samba servers are running in our network)
                # pdbedit                                                                                    (to check the available samba users who are accessing currently)
                # smbstatus                                                        (to check how many smb clients are connected to the samba server)
                # mount   -t   cifs   ///    -o    
            user=                            (to mount the samba share directory on local mount point temporarily)
                Example :   # mount   -t   cifs   //172.25.9.11/samba    /mnt/samba    -o   user=raju
                                               































17.  NTP (Network Time Protocol)  or  Chrony
1.            What is  NTP  and  Chrony?
                NTP stands for Network Time Protocol in  RHEL - 6  and  Chrony is also a Network Time Protocol in  RHEL - 7.   These are used to synchronize the time on your Linux system with a centralized NTP  or  Chrony server.A local            NTP  or  Chrony server on the network can be synchronized with an external timing source to keep all the             servers in your organization in-sync with an accurate time.
2.            What are the differences between  NTP  and  Chrony?              
NTP
Chrony
This is used in  RHEL - 6.
This is used in  RHEL - 7.
Package is  ntp  or  system-config-date.
Package is  chrony.
It's  deamon is  ntpd  and  Port number is  123.
It's  deamon is  chronyd  and  Port number is  123.
We have to install the package manually.
By  default  this package is installed.
# ntpq   -p    (to check  ntp  is configured  or  not).
# chronyc  sources   -v   (to check  chrony  is
configured  or  not).
Configuration  file  is  /etc/ntp.conf
Configuration  file  is  /etc/chrony.conf
Log  file  is  /var/log/ntpstat
Log  file  is  /var/log/chrony

3.            How to configure the  NTP  and  Chrony  client?
                NTP :
                (i)            Install the  ntp  package by  # yum  install  ntp*  -y   or   # yum  install  system-config-date*    -y   command.
                (ii)           open the configuration file  by   # system-config-date    or   # vim   /etc/ntp.conf    command.
                                (# system-config-date   command is used to configure the  NTP  in graphical mode)
                                *   Make a comment on  line numbers  21,  22  and  23. Then  go to line number  24 and  type as below.
                                server                                                                                         (save  and  exit  this  file)
                                Example :    server    classroom.example.com
                (iii)          Restart the  ntpd  service by   # service  ntpd  restart    command.
                (iv) Enable the  ntp  service at next boot by   # chkconfig  ntpd  on   command.
                (v) Check whether the  NTP  is configured  or  not  by   # ntpq   -p    command.
                Chrony :
                (i)            Chrony  package is not installed because  by default  it is installed. If it not installed then  install the package                 by   # yum  install  chrony*   -y    command.
                (ii)           Open the chrony configuration file by   # vim   /etc/chrony.conf   command.
                                *   Make a comment on line numbers   3, 4  and  5. Then go to line number  6  and  type as below.
                                server          iburst                                                                    (save  and  exit  this  file)
                                Example :   server     classroom.example.com     iburst
                (iii)          Restart the   chrony   service by   # systemctl  restart  chronyd    command.
                (iv) Enable the   chrony   service at next boot by   # systemctl  enable  chronyd    command.
                (v)           Check whether the  Chrony  is configured  or  not by   # chronyc  sources   -v    command.
                # timedatectl                                        (to check whether the client's  time is synchronized to the server's  time)
                # timedatectl    list-timezones                 (to list the different time zones)
                # timedatectl    set-time                           (to set the time)
                # timedatectl    set-timezone    Asia/Kolkata (to set the time zone in  RHEL - 7)

                # tzselect    Asia/Kolkata                                                    (to set the time zone in  RHEL - 6)

No comments:

Linux, CCNA and MCSE Questions: User Managment

Linux, CCNA and MCSE Questions: User Managment