Saturday, May 16, 2020

Root Password reset in RHEL Linux


How to reset password in Redhat Linux?



If You forget root user password of Linux machine. Then you can reset your root account password by using below easy steps. But you have to take down time first then you can process.


Reboot and edit grub2 :-
1. First of all, reboot your server and press any key to stop auto-boot from the kernel. Then press after scroll down to kernel line (Rescue Mode).



2. When you are in edit mode, go to the line starting with linux16 and edit rd.break like shown in below picture.


Note - You can edit also enforcing=0 options enables omitting the time consuming SELinux relabeling process.


3. Then press Ctrl +X  and  this will reboot the system into rescue mode with changed parameters.



Note - Now the file system is mounted in read-only  on /sysroot/.

4.So now you have to remount /sysroot file system in read-write mode and then use chroot to get in chroot jail.

# mount -o remount,rw /sysroot
# chroot /sysroot

5. Now you can change your root account password by using passwd command.

#passwd

6.After that all unlabeled files ( including shadow file ) gets relabeled during booting. Touching the hidden file autorelabel instructs SElinux to relabel the files changed outside of its regular context, like the file /etc/shadow.

# touch /.autorelabel

7. To flush all cache to disk.
# sync

 After that type exit command two times for reboot the system. Then you can login with updated password.







Friday, May 15, 2020

Samba configuration in Redhat Linux

Samba configuration in Redhat Linux



Today, I want to tell you about Samba configuration in Red Hat Linux. Which is very helpful to understand about sharing a directory from Linux to windows operating system environment.Because in daily routine tasks we have spends more time to login winscp or filezilla to access a file.So Here these are easy steps to configure samba server in linux :-




1. First of all, we have to install samba server utility by using below command :-


[root@rhelnode1 /]# yum -y install samba

2. Then create a directory which you want to share with your windows environment :-

[root@rhelnode1 /]# mkdir -p /home/Amiteshjsk/test

3. Create a group and change group of above created directory :-

[root@rhelnode1 /]# groupadd samba

[root@rhelnode1 /]# chgrp -R samba /home/Amiteshjsk/test
[root@rhelnode1 /]# chmod -R 755 /home/Amiteshjsk/test

4. Add a samba user and set password :-

[root@rhelnode1 /]# useradd Amiteshjsk
[root@rhelnode1 /]# usermod -G samba Amiteshjsk
[root@rhelnode1 /]# smbpasswd -a Amiteshjsk
New SMB password:
Retype new SMB password:
Added user Amiteshjsk.

5.Edit configuration file, by using below lines :-

 [root@rhelnode1 /]# vi /etc/samba/smb.conf

[test]       

path = /home/Amiteshjsk/test
writeable = yes
browseable = yes
valid users = Amiteshjsk
workgroup = workgroup

6. Edit /etc/services and add local loopback address :-


7. After that, Restart services

 [root@rhelnode1 /]# systemctl restart smb.service
[root@rhelnode1 /]# systemctl restart nmb.service

8. Now you can put files in below directory

[root@rhelnode1 /]# cd /home/Amiteshjsk
[root@rhelnode1 test]# mkdir kisna
[root@rhelnode1 test]# touch kisna.txt

9. now you can access from window machine by using ip of host in run command as like you access ftp :-





Tuesday, May 12, 2020

Linux Booting Process



Process of booting linux operating system

In Linux, There are 6 high level stages of booting operating system after pressing power button. Its take in first step as POST(power on self test) which is common in all operating systems. Then:-
1. BIOS
§  BIOS stands for Basic Input/Output System
§  Performs some system integrity checks.
§  Searches, loads, and executes the boot loader program.
§  It looks for boot loader in floppy, cd-rom, or hard drive. Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
§  So, in simple terms BIOS loads and executes the MBR boot loader.
2. MBR
§  MBR stands for Master Boot Record.
§  It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
§  MBR is less than 512 bytes in size. This has three components 1) primary boot loader info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
§  It contains information about GRUB (or LILO in old systems).
§  So, in simple terms MBR loads and executes the GRUB boot loader.
3. GRUB (Boot loader)
§  GRUB stands for Grand Unified Bootloader.
§  If you have multiple kernel images installed on your system, you can choose which one to be executed.
§  GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
§  GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
§  Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to this). The following is sample grub.conf of CentOS.
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
          initrd /boot/initrd-2.6.18-194.el5PAE.img
§  As you notice from the above info, it contains kernel and initrd image.
§  So, in simple terms GRUB just loads and executes Kernel and initrd images.
4. Kernel
§  Mounts the root file system as specified in the “root=” in grub.conf
§  Kernel executes the /sbin/init program
§  Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
§  initrd stands for Initial RAM Disk.
§  initrd is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware.
5. Init
§  Looks at the /etc/inittab file to decide the Linux run level.
§  Following are the available run levels
§  0 – halt                                              (init 0 to shut down the server)
§  1 – Single user mode
§  2 – Multiuser, without NFS
§  3 – Full multiuser mode
§  4 – unused
§  5 – X11
§  6 – reboot                                         (init 6 to reboot the server)

§  Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
§  Execute ‘grep initdefault /etc/inittab’ on your system to identify the default run level
§  If you want to get into trouble, you can set the default run level to 0 or 6. Since you know what 0 and 6 means, probably you might not do that.
§  Typically you would set the default run level to either 3 or 5.
6. Runlevel programs
§  When the Linux system is booting up, you might see various services getting started. For example, it might say “starting sendmail …. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.
§  Depending on your default init level setting, the system will execute the programs from one of the following directories.
§  Run level 0 – /etc/rc.d/rc0.d/
§  Run level 1 – /etc/rc.d/rc1.d/
§  Run level 2 – /etc/rc.d/rc2.d/
§  Run level 3 – /etc/rc.d/rc3.d/
§  Run level 4 – /etc/rc.d/rc4.d/
§  Run level 5 – /etc/rc.d/rc5.d/
§  Run level 6 – /etc/rc.d/rc6.d/
§  Please note that there are also symbolic links available for these directory under /etc directly. So, /etc/rc0.d is linked to /etc/rc.d/rc0.d.
§  Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
§  Programs starts with S are used during startup. S for startup.
§  Programs starts with K are used during shutdown. K for kill.
§  There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
§  For example, S12syslog is to start the syslog deamon, which has the sequence number of 12. S80sendmail is to start the sendmail daemon, which has the sequence number of 80. So, syslog program will be started before sendmail.


After that, you will be able to login your server using credentials.



Friday, May 1, 2020

Import/Export volume group map in HP UNIX cluster


When you have two node(Host A & Host B) cluster server and you want to  present same disk on both node. Then allocate disk on both hosts from SAN Storage. After that on host A you can create a simple volume group by using below commands: -


#ioscan -fnCdisk     (To check newly created disk)

#pvcreate /dev/rdisk/disk22     (creating a physical volume)

#vgcreate -s 32 -e 12800 /dev/dbvg /dev/disk/disk22  (volume group creating name dbvg)

#vgdisplay -v   /dev/dbvg    (To see volume group details)

#lvcreate -L 204768 -n lvol1 /dev/dbvg  (creating logical volume)

#newfs -F vxfs -o largefiles /dev/dbvg/rlvol1  

           After That export map file in below path by using below command: -

#vgexport -p -v -s -m /tmp/map/evavg.map /dev/dbvg

           Now copy it to Host B and import volume group map: -

#rcp -rp /tmp/map/evavg.map 10.241.16.76:/tmp/map/

#vgimport -v -s -m /tmp/map/evavg.map -N /dev/dbvg

#vgdisplay -v /dev/dbvg

             Then change volume group status on both nodes : -

#vgchange -a n /dev/dbvg

              After that add volume group in cluster mode and run command in both nodes :-

#vgchange -c y /dev/dbvg

              Now you can mount your logical volume on both nodes by creating a directory : -

#mkdir backup

#mount -F vxfs /dev/dbvg/lvol1 /backup













Saturday, April 4, 2020

HP Unix Booting Process


HP-UX boot guide

 Normal Boot

The bootstrap process involves the execution of three software components:
  • pdc (Processor-dependent code)
  • isl (Initial System loader)
  • hpux (Secondary Boot loader)
  • vmunix

Processor-dependent code

Automatic boot processes on various HP-UX systems follow similar general sequences. When power is applied to the HP-UX system processor, or the system Reset button is pressed, the firmware processor-dependent code (pdc) is executed to verify hardware and general system integrity. After checking the hardware, pdc gives the user the option to override the autoboot sequence by pressing the Esc key. A message resembling the following usually appears on the console.

     (c) Copyright. Hewlett-Packard Company. 1994.
     All rights reserved.
     PDC ROM rev. 130.0
     32 MB of memory configured and tested.
     Selecting a system to boot.
     To stop selection process, press and hold the ESCAPE key...
 
If no keyboard activity is detected, pdc commences the autoboot sequence by loading isl and transferring control to it.

Initial system loader

The initial system loader (isl) implements the operating-system-independent portion of the bootstrap process. It is loaded and executed after self-test and initialization have completed successfully. Typically, when control is transferred to isl, an autoboot sequence takes place. An autoboot sequence allows a complete bootstrap operation to occur with no intervention from an operator. While an autoboot sequence occurs, isl finds and executes the autoexecute file which requests that hpux be run with appropriate arguments. Messages similar to the following are displayed by isl on the console:
     Booting from: scsi.6  HP 2213A
     Hard booted.
     ISL Revision A.00.09  March 27, 1990
     ISL booting  hpux boot disk(;0)/stand/vmunix
 
 

hpux (Seconday boot loader)

hpux, the secondary system loader, then announces the operation it is performing, in this case the boot operation, the device file from which the load image comes, and the TEXT size, DATA size, BSS size, and start address of the load image, as shown below, before control is passed to the image.
    Booting disk(scsi.6;0)/stand/vmunix
    966616+397312+409688 start 0x6c50
 
Finally, the loaded image displays numerous configuration and status messages, and passes control to the init process.

vmunix
After kernel vmunix gets loaded-


  • Swapper daemon starts with PID 0
  • Kernel runs /sbin/pre_init_rc
  • Kernel calls /sbin/init
  • /sbin/init reads /etc/inittab and calls –
  1. /sbin/ioinit – to scan hardware and build kernel io tree
  2. /sbin/bcheckrc – to check FS listed in /etc/fstab
  3. /sbin/rc – to start additional services like lp, cron, cde
  4. /usr/sbin/getty – to start n show login prompt to the user.
Please note that this is not the exact hpux boot process. There are alterations depends on the system being referred to is PA-RISC or Itanium.

Single-user Boot

A single-user boot in HP-UX is sometimes referred to as an interactive boot or attended mode boot. Pressing the Escape key at the boot banner on an older Series 700 workstation halts the automatic boot sequence, puts you into attended mode, and displays the Boot Console User Interface main menu, a sample of which is below.
   Selecting a system to boot.
   To stop selection process, press and hold the ESCAPE key.
   Selection process stopped.
   Searching for Potential Boot Devices.
   To terminate search, press and hold the ESCAPE key.
   Device Selection    Device Path             Device Type
   -------------------------------------------------------------
   P0                  scsi.6.0                QUANTUM PD210S
   P1                  scsi.1.0                HP      2213A
   P2                  lan.ffffff-ffffff.f.f   hpfoobar
 
   b) Boot from specified device
   s) Search for bootable devices
   a) Enter Boot Administration mode
   x) Exit and continue boot sequence
 
      Select from menu:
 
In this case the system automatically searches the SCSI, LAN, and EISA interfaces for all potential boot devices-devices for which boot I/O code (IODC) exists. The key to booting to single-user mode is first to boot to ISL using the b) option. The ISL is the program that actually controls the loading of the operating system. To do this using the above as an example, you would type the following at the Select from menu: prompt:
Select from menu: b p0 isl
 
This tells the system to boot to the ISL using the SCSI drive at address 6 (since the device path of P0 is scsi.6.0). After displaying a few messages, the system then produces the ISL> prompt.
Pressing the Escape key at the boot banner on newer Series 700 machines produces the Boot Administration Utility, as shown below.
   Command                            Description
   -------                            -----------
   Auto [boot|search] [on|off]        Display or set auto flag
   Boot [pri|alt|scsi.addr][isl]      Boot from primary, alt or SCSI
   Boot lan[.lan_addr][install][isl]  Boot from LAN
   Chassis [on|off]                   Enable chassis code
   Diagnostic [on|off]                Enable/disable diag boot mode
   Fastboot [on|off]                  Display or set fast boot flag
   Help                               Display the command menu
   Information                        Display system information
   LanAddress                         Display LAN station addresses
   Monitor [type]                     Select monitor type
   Path [pri|alt] [lan.id|SCSI.addr]  Change boot path
   Pim [hpmc|toc|lpmc]                Display PIM info
   Search [ipl] [scsi|lan [install]]  Display potential boot devices
   Secure [on|off]                    Display or set security mode
   -----------------------------------------------------------------
   BOOT_ADMIN>
 
 
To display bootable devices with this menu you have to execute the Search command at the BOOT_ADMIN> prompt:
BOOT_ADMIN> search
Searching for potential boot device.
This may take several minutes.
 
To discontinue, press ESCAPE.
 
   Device Path      Device Type
   --------------   ---------------
   scsi.6.0         HP C2247
   scsi.3.0         HP HP35450A
   scsi.2.0         Toshiba CD-ROM
 
BOOT_ADMIN>
 
To boot to ISL from the disk at device path scsi.6.0 type the following:
BOOT_ADMIN>boot scsi.6.0 isl
 
Once you get the ISL prompt you can run the hpux utility to boot the kernel to single-user mode:
ISL>hpux -is
 
This essentially tells hpux to load the kernel (/stand/vmunix) into single-user mode (-is) off the SCSI disk drive containing the kernel. The -is option says to pass the string s to the init process (i), and the command init s puts the system in single-user mode. In fact, you will see something similar to the following after typing the above command:
Boot
: disk(scsi.6;0)/stand/vmunix
966616+397312+409688 start 0x6c50
 
   Kernel Startup Messages Omitted
INIT: Overriding default level with level 's'
INIT: SINGLE USER MODE
WARNING:  YOU ARE SUPERUSER!!
#

 Startup

Beginning with HP­UX 10 /etc/inittab calls /sbin/rc, which in turn calls execution scripts to start subsystems. This approach follows the OSF/1 industry standard and has been adopted by Sun, SGI, and other vendors. There are four components to this method of startup and shutdown: /sbin/rc, execution scripts, configuration variable scripts, and link files.

/sbin/rc

This script invokes execution scripts based on run levels. It is also known as the startup and shutdown sequencer script.

Execution scripts

These scripts start up and shut down various subsystems and are found in the /sbin/init.d directory. /sbin/rc invokes each execution script with one of four arguments, indicating the "mode":
start
Bring the subsystem up
start_msg
Report what the start action will do
stop
Bring the subsystem down
stop_msg
Report what the stop action will do
These scripts are designed never to be modified. Instead, they are customized by sourcing in configuration files found in the /etc/rc.config.d directory. These configuration files contain variables that you can set. For example, in the configuration file /etc/rc.config.d/netconf you can specify routing tables by setting variables like these:
ROUTE_DESTINATION[0]="default"
ROUTE_GATEWAY[0]="gateway_address"
ROUTE_COUNT[0]="1"
 
The execution script /sbin/init.d/net sources these and other network-related variables when it runs upon system startup. More on configuration files is described below.
Upon startup a checklist similar to the one below will appear based upon the exit value of each of the execution scripts.
HP-UX Startup in progress
-----------------------------------
Mount file systems.............................. [ OK ]
Setting hostname................................ [ OK ]
Set privilege group............................. [ OK ]
Display date................................... [FAIL]*
Enable auxiliary swap space.................... [ N/A ]
Start syncer daemon............................. [ OK ]
Configure LAN interfaces........................ [ OK ]
Start Software Distributor agent daemo.......... [ OK ]
 
The execution scripts have the following exit values:
0
Script exited without error. This causes the status OK to appear in the checklist.
1
Script encountered errors. This causes the status FAIL to appear in the checklist.
2
Script was skipped due to overriding control variables from /etc/rc.config.d files or for other reasons, and did not actually do anything. This causes the status N/A to appear in the checklist.
3
Script executed normally and requires an immediate system reboot for the changes to take effect. (NOTE: Reserved for key system components).

Wednesday, March 4, 2020

Small but thick knowledge.....


To create a super user in UNIX/LINUX      

                Or

To change a Normal user to super user in UNIX/LINUX


  1. Create a new user  (Or select a exists user)
  2. Set id 0 in selected user attributes through /etc/passwd file like-
(Before Edit )     asharma:*:128:20::/home/asharma:/sbin/sh
(After Edit)         asharma:*:0:20::/home/asharma:/sbin/sh
    3. Save file and exit.
 Now your selected user works as root user.
----------------------------------------------------------------------------------------------------------

How to create directories or text files in sequence or numberwise 


How to Zip files in Linux

Suppose we have below mentioned files have to zip in a file named mohan.zip


Now you can check zip  file is there


For unzip a file run below command 


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

For "command not found" error in HP UNIX-


PATH=$PATH:/usr/sbin:/usr/bin;export PATH

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

To check active user in web server-

ps -ef| grep httpd| wc -l


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


Defaults Ports: 

  • (Simple Mail Transfer Protocol) SMTP = 25
  • (Domain Naming System ) DNS = 53
  • (File Transfer Protocol) FTP = 20 and 21
  • (Dynamic Host configuration Protocol) DHCP = 67 and 68
  • (Secure Shell) SSH = 22
  • TELNET = 23
  • (Internet Message access Protocol) IMAP = 143
  • (Post office Protocol) POP3=110
  • (Remote Desktop protocol) RDP =3389
  • (Hyper Text Transfer protocol) HTTP = 80
  • (Secure connection for Hyper text transfer protocol) HTTPS = 443
  • (Network Time Protocol) NTP = 123
  • (Simple Network Mail Protocol) SNMP = 161
--------------------------------------------------------------------------------------------------------------------------
How to check WWN number in HP UNIX Server: -

# ioscan -fnC fc
Class     I  H/W Path     Driver S/W State   H/W Type     Description
===================================================================
fc        0  0/2/0/0/0/0  fcd   CLAIMED     INTERFACE    HP AD300A 4Gb Dual Port PCIe Fibre Channel Adapter (FC Port 1)
                         /dev/fcd0
fc        1  0/2/0/0/0/1  fcd   CLAIMED     INTERFACE    HP AD300A 4Gb Dual Port PCIe Fibre Channel Adapter (FC Port 2)
                         /dev/fcd1

#

There are HBA cards please select one by one: -

# fcmsutil /dev/fcd0
                           Vendor ID is = 0x1077
                           Device ID is = 0x2432
            PCI Sub-system Vendor ID is = 0x103C
                   PCI Sub-system ID is = 0x7041
                               PCI Mode = PCI Express x4
                       ISP Code version = 5.6.5
                       ISP Chip version = 3
                               Topology = PTTOPT_FABRIC
                             Link Speed = 4Gb
                     Local N_Port_id is = 0x010200
                  Previous N_Port_id is = None
            N_Port Node World Wide Name = 0x500143800635d77d
            N_Port Port World Wide Name = 0x500143800635d77c
            Switch Port World Wide Name = 0x200200051eef68bb
            Switch Node World Wide Name = 0x100000051eef68bb
              N_Port Symbolic Port Name = IGNITEBA_fcd0
              N_Port Symbolic Node Name = IGNITEBA_HP-UX_B.11.31
                           Driver state = ONLINE
                       Hardware Path is = 0/2/0/0/0/0
                     Maximum Frame Size = 2048
         Driver-Firmware Dump Available = NO
         Driver-Firmware Dump Timestamp = N/A
                                   TYPE = PFC
                         NPIV Supported = YES
                         Driver Version = @(#) fcd B.11.31.1503 Dec  3 2014
#

For checking LUN number

#insf
#ioscan -m lun

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

To check all configuration like memory, hardware in HP-UX


# machinfo
CPU info:
   Intel(R) Itanium 2 9100 series processor (1.67 GHz, 18 MB)
   2 cores, 4 logical processors per socket
   666 MT/s bus, CPU version A1
          Active processor count:
          1 socket
          2 cores (2 per socket)
          2 logical processors (2 per socket)
          LCPU attribute is disabled

Memory: 16361 MB (15.98 GB)

Firmware info:
   Firmware revision:  04.11
   FP SWA driver revision: 1.18
   IPMI is supported on this system.
   BMC firmware revision: 5.25

Platform info:
   Model:                  "ia64 hp server rx2660"
   Machine ID number:      41485a06-aeb8-11df-b3f0-2d0c9141f936
   Machine serial number:  SGH50290JN

OS info:
   Nodename:  IGNITEBA
   Release:   HP-UX B.11.31
   Version:   U (unlimited-user license)
   Machine:   ia64
   ID Number: 1095260678
   vmunix _release_version:
@(#) $Revision: vmunix:    B.11.31_LR FLAVOR=perf
#



Introduction to Linux Part 1

Introduction to Linux Part 1

Introduction to Linux Linux is an operating system that works just like Windows and Mac OS X. As an operating system, Linux is a very h...