Monday, March 22, 2021

thumbnail

Printf Usage - Sample example for printf command in bash



Sample example for printf command in bash 

#!/bin/bash
report_header_div=" ---------------------------------------------------------------------"
report_header_formater="\n %5s %15s %11s %15s %15s %15s\n"
report_item_formater="%6d %10s %15s %16.2f %15.2f\n"
printf "$report_header_formater" "ID" "COURSE NAME" "LEVEL" "ACTUAL PRICE" "DISC. PRICE"
echo $report_header_div
printf "$report_item_formater" \
10 "Bash" L100 99.00 12.00 \
105 "Linux" L200 1599.00 15.00 \
====================================================================
Output of the above script:
    ID     COURSE_NAME       LEVEL     ACTUAL_RICE      DISC.PRICE 
---------------------------------------------------------------------------------
    10       Bash            L100            99.00           12.00
   105      Linux            L200          1599.00           15.00
===================================================================

Thursday, March 4, 2021

thumbnail

Kernel Pani Error

Kernel Panic - not syncing: Attempted to kill init! 

Issue Scenario:

       Server is reachable over the network however SSH and console login fails with the following error message.



Resolution:

  • Boot the system into rescue mode:
    • To boot the system into rescue mode please use following steps:

  • You will be prompted for your keyboard and language requirements. Enter these values as you would during the installation of Red Hat Enterprise Linux.

  • Next, a screen will appear telling you that the program will now attempt to find a Red Hat Enterprise Linux installation to rescue. Select "Continue" on this screen.

  • At the "sh-3.1" prompt check df command output to see if the dev, sys, proc filesystems are mounted under the existing installation environment /mnt/sysimage or not. If these directories are not by default mounted, then please try to mount it manually as shown below:

  • mount -o bind /dev /mnt/sysimage/dev
    mount -o bind /sys /mnt/sysimage/sys
    mount -t proc /proc /mnt/sysimage/proc
    mount -o bind /dev/shm /mnt/sysimage/dev/shm

    Change root to the already installed root fs:

  •    $ chroot /mnt/sysimage

* Check the missed library is exist and also check whether its symlink

 # cd /lib64

 # ls -l | grep libc.so

lrwxrwxrwx 1 root root 12 Jan 19 2016 libc.so.6 -> libc-2.12.so


# ls -l libc-2.12.so
-rwxr-xr-x 1 root root 1926480 May 20 2015
libc-2.12.so

* If its not exist then create symlink as below and reboot the system

# ln -s /lib64/libc-2.12.so /lib64/libc.so.6

Monday, March 1, 2021

thumbnail

Installing and Configuring Samba server on RHEL 7/CentOS 7 and integrate with MS Active Directory


1. Install the following packages


 yum install samba*
yum install krb5-libs krb5-workstation

2. Configuration Kerberos /etc/krb5.conf

    

[logging]
 default = FILE:/var/log/krb5libs.log
 kdc = FILE:/var/log/krb5kdc.log
 admin_server = FILE:/var/log/kadmind.log

[libdefaults]
 default_realm = YOURDOMAIN
 dns_lookup_realm = false
 dns_lookup_kdc = false
 ticket_lifetime = 24h
 renew_lifetime = 7d
 forwardable = true

[realms]
 YOURDOMAIN = {
  kdc = dns-name-your-domain-controller
}

[domain_realm]
 .yourdomain = YOURDOMAIN
 yourdomain = YOURDOMAIN

   3. Configuration samba /etc/samba/smb.conf

  


    [global]
    workgroup = DOMAIN
    password server = dns-name-your-domain-controller
    realm = YOURDOMAIN
    preferred master = no
    security = ads
    dns proxy = yes
    idmap config * : range = 16777216-33554431
    template shell = /bin/bash
    kerberos method = secrets only
    winbind use default domain = true
    winbind offline logon = true

    server string =  Samba Server
    passdb backend = tdbsam  
 
    load printers = no
    show add printer wizard = no
    printcap name = /dev/null
    log file = /var/log/samba/%m.log
    loglevel = 3
    max log size = 1000

    map to guest = Never
    encrypt passwords = yes
    guest account = nobody
    restrict anonymous = 1
    server signing = mandatory
    local master = no
    domain master = no
    wins support = no

    keepalive = 30
    dead time = 5
    preserve case = yes
    default case = lower
    case sensitive = no
    short preserve case = yes

    host msdfs = no
    unix extensions = no
    wide links = yes
    follow symlinks = yes
    posix locking = no

[homes]

   comment = Home Directories
   browseable = no
   create mask = 0755
   writable = yes
4. Add Server to Domain

net ads join -S dns-name-your-domain-controlle -U account-admin-for-active-director
5. Edit file /etc/nsswitch.conf and restart samba and winbind and test it.
 
passwd:     files winbind
shadow:     files winbind
group:      files winbind
Powered by Blogger.