Wednesday, August 3, 2016

Linux Interview Question - Part 1

1. what is backup utility?

Backup software are computer programs used to perform backup; they create supplementary exact copies of files, databases or entire computers. These programs may later use the supplementary copies to restore the original contents in the event of data loss.

2. How do I know if I'm working on a Virtual Machine or not?

On Windows, from CMD:
Systeminfo | findstr /i model

Returns something like:
System Model: VMware Virtual Platform
[01]: Intel64 Family 6 Model 26 Stepping 5 GenuineInt

On Linux, run this:
$ dmesg |grep -i hypervisor
Hypervisor detected: KVM

3. what is boot loader?

Boot loader a program that loads an operating system when a computer is turned on.
"Linux's GRUB bootloader can be used to select which operating system you'd like to boot into"

For Linux, the two most common boot loaders are known as LILO (LInux LOader) and LOADLIN (LOAD LINux). An alternative boot loader, called GRUB (GRand Unified Bootloader), is used with Red Hat Linux. LILO is the most popular boot loader among computer users that employ Linux as the main, or only, operating system. The primary advantage of LILO is the fact that it allows for fast boot-up. LOADLIN is preferred by some users whose computers have multiple operating systems, and who spend relatively little time in Linux. LOADLIN is sometimes used as a backup boot loader for Linux in case LILO fails. GRUB is preferred by many users of Red Hat Linux, because it is the default boot loader for that distribution.

4. how to extend lvm?

To extend a logical volume you simply tell the lvextend command how much you want to increase the size. You can specify how much to grow the volume, or how large you want it to grow to:


5. what is mx record?

A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient's domain, and a preference value used to prioritize mail delivery if multiple mail servers are available

6. 
what command should you use to check the number of files and disk space used and each user's defined quotas?

repquota


7. how to extract tar file?

tar -xvf file.tar
tar -xzvf file.tar.gz
tar -xjvf file.tar.bz2


8. how to check newly attached disk?
fdisk -l

9. what is the port number of apache?

Port : 80

10. port number of https?

Port : 80

11. how to check number of disk available in linux system?

fdisk -l

12. what is ssh port number?

port : 22

13. Users are not able to login using ssh tell me the reasons.

1) port hardening
2) check user shell
3) ssh block
4) check user permission 
5) check user created or not

14. samba service installed on linux sytem with all permission still user is not able to login from windows machine what will be the reason?



15. what is dns service name linux and what is the configuration file?

BIND stands for Berkley Internet Naming Daemon. BIND is the most common program used for maintaining a name server on Linux

main configuration file for dns server is named.conf. By default this file is not created in /var/named/chroot/etc/ directory. Instead of named.conf a sample file /var/named/chroot/etc/named.caching-nameserver.conf is created. This file is use to make a caching only name server. You can also do editing in this file after changing its name to named.conf to configure master dns server or you can manually create a new named.conf file.

16. 
what is 'inode'?

All UNIX files have its description stored in a structure called 'inode'. The inode contains info about the file-size, its location, time of last access, time of last modification, permission and so on. Directories are also represented as files and have an associated inode.

17. 
what are the process states in UNIX?

As a process executes it changes state according to its circumstances. Unix processes have the following states:

Running: The process is either running or it is ready to run .
Waiting: The process is waiting for an event or for a resource.
Stopped: The process has been stopped, usually by receiving a signal.
Zombie: The processes are dead but have not been removed from the process table


18. How to unlock user?

[root@localhost ~]# passwd -u sharad 
Unlocking password for user sharad.
 passwd: Success 
[root@localhost ~]#

19. what command is used to remove the password assigned to a group?

gpasswd –r


20. what can you type at a command line to determine which shell you are using?

echo $SHELL


21. write a command to find all of the files which have been accessed within the last 30 days.

find / -type f -atime -30 > filename.txt


22. what is a zombie?

Zombie is a process state when the child dies before the parent process. In this case the structural information of the process is still in the process table.


23. what daemon is responsible for tracking events on your system?

The udev demon used to create and remove all these device nodes or files in /dev/ directory


24. what kind of files or nodes /dev/ directory contains and how do I access or see device files?

Block Device Files:-
Block device files talks to devices block by block [1 block at a time (1 block = 512 bytes to 32KB)].
Examples: - USB disk, CDROM, Hard Disk

# ls /dev/sd*
brw-rw----
1 root    
root      
8,
0 Mar 15  2009 sda
brw-rw----   
1 root    
root      
8,  
1 Mar 15  2009 sda1
brw-rw----   
1 root    
root      
8,  
2 Mar 15  2009 sda2
brw-rw----   
1 root    
root      
8,  
3 Mar 15  2009 sda3
brw-rw----   
1 root    
root      
8,  
4 Mar 15  2009 sda4
brw-rw----   
1 root    
root      
8,  
16 Mar 15  2009 sdb
Character Device Files:-
Character device files talk to devices character by character.
Examples: - Virtual terminals, terminals, serial modems, random numbers

#ls /dev/tty*
crw-rw----   
1 root    
root      
4,
64 Mar 15  2009 ttyS0
crw-rw----   
1 root    
root      
4,
65 Mar 15  2009 ttyS1
crw-rw----   
1 root    
root      
4,
66 Mar 15  2009 ttyS2
crw-rw----   
1 root    
root      
4,
67 Mar 15  2009 ttyS3


25. tell me the name of device file for PS/2 mouse connection.

/dev/psaux


26.tell me the name of device file for parallel port (Printers).

/dev/lp0

Tuesday, August 2, 2016

SSH

how to increase ssh time (putty)

create config file under .ssh
[root@localhost ~]# vim .ssh/config 
add below entry under config file

Host *
ServerAliveInterval 60
wq!

reload or restart sshd service



[root@Localhost Desktop]# rpm -qa | grep ssh  - package check not found

[root@Localhost Desktop]# yum install *ssh*   or    yum install openssh*

[root@Localhost Desktop]# rpm -qa | grep ssh  - package check after installation
libssh2-docs-1.4.2-1.el6_6.1.x86_64
trilead-ssh2-213-6.2.el6.noarch
libssh2-devel-1.4.2-1.el6_6.1.x86_64
openssh-askpass-5.3p1-112.el6_7.x86_64
pam_ssh_agent_auth-0.9.3-112.el6_7.x86_64
openssh-5.3p1-112.el6_7.x86_64
openssh-clients-5.3p1-112.el6_7.x86_64
ksshaskpass-0.5.1-4.1.el6.x86_64
openssh-ldap-5.3p1-112.el6_7.x86_64
openssh-server-5.3p1-112.el6_7.x86_64
trilead-ssh2-javadoc-213-6.2.el6.noarch
libssh2-1.4.2-1.el6_6.1.x86_64
---------------------------------------------------------------------------------------------------------------------
[root@Localhost Desktop]# /etc/init.d/sshd restart   ---------start or restart ssh server
Stopping sshd:                                             [  OK  ]
Starting sshd:                                             [  OK  ]
---------------------------------------------------------------------------------------------------------------------
[root@Localhost Desktop]# telnet 127.0.0.1 22   ----check port status

[root@Localhost Desktop]# nc localhost 22

[root@Localhost Desktop]# netstat -tulnp | grep -i 22
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      10291/sshd         
tcp        0      0 :::22                       :::*                        LISTEN      10291/sshd         
---------------------------------------------------------------------------------------------------------------------
[root@Localhost Desktop]# /etc/init.d/sshd status   ----- check SSH status
openssh-daemon (pid  10291) is running...
---------------------------------------------------------------------------------------------------------------------
[root@Localhost Desktop]# ps -ef | grep -i sshd   ----- check server & port
root     10291     1  0 07:11 ?        00:00:00 /usr/sbin/sshd
root     10332  7657  0 07:19 pts/0    00:00:00 grep -i sshd
---------------------------------------------------------------------------------------------------------------------
[root@Localhost Desktop]# vi /etc/sshd/ --root path of SSH
---------------------------------------------------------------------------------------------------------------------
[root@Localhost ~]# vim /etc/ssh/sshd_config   --------------SSH configuration fil e
#Port 22 -----------------------port settings, we can manage

# Authentication:
PermitRootLogin no   -----------uncomment and type no for disable ssh root login 
---------------------------------------------------------------------------------------------------------------------
[root@Localhost ~]# /etc/init.d/sshd reload   ---- reload service
Reloading sshd:                                            [  OK  ]
---------------------------------------------------------------------------------------------------------------------
  


SERVER


CLIENT
rpm –qa | grep –i ssh
no need to installed ssh service
yum install *ssh*
ssh – client / command / utitlity
Ssh-*  ---not work
( usr/bin/ssh ) – just a command
used *ssh* - package name is – openssh
ssh 192.168.1.14 – (server ip )
Yum install openssh*
If stop sshd service but ssh cmd is working
/etc/init.d/sshd used tab tab restart
Port - 22
/etc/init.d/sshd restart
When used for connect server to used
random port
ssh port - 22
telnet localhost 22
ssh < server ip >
nc localhost 22
ssh 192.168.1.14
netstat – tulnp | grep –i 22
its refers /etc.service file for port  to connect server side
/etc/init.d/sshd status
ps –ef | grep –i sshd – check server & port
1 ) # ssh champu@192.168.1.14
we can login through user also
2 ) #ssh 192.168.1.14 –l champu
Always disable root login for ssh
OS Harening  -- 1 step
vi /etc/sshd/ --root path
Copy files on server
vi /etc/sshd/sshd_config  –configuration file of
sshd
PermitRootLogin no – uncommnet (# ) & type no for disable root login
scp /mnt/* champu@192.168.1.14:/opt/
rsync /mnt/* champu@192.168.1.14:/opt/


/etc/init.d/sshd reload  - reload service

we can change sshd port
example : 22
change poer : 222

After change port – access ssh

ssh 192.168.1.14 –p 222

Change in /etc/service file
HOW TO SSH WORK

1) – client request to server
2) server send public key  --- public key travel on network
3) client send public key   --- public key travel on network
4) Server send privet key ( give access to client )



Encrymtion type

1 - MD5
2 - SNA
3 - RSA -- Rivert Shamim Adelmen -- name of persons
4 - DSA

Ssh generate two keys on server
1) ---    public key
2) ---    private key

SSH used RSA encryption  ----- Rivert Shamim Adelmen



SERVER


CLIENT
#cd /etc/ssh
Public key store in below path
#ls

/root/.ssh/know_hosts – public key
Public_key and private_key

/champu/.ssh/know_hosts – public key

KERNEL TUNING

KERNEL TUNING
Kernel Tuning – change the Kernel Values / Parameters / Limitation is call kernel tuning
---------------------------------------------------------------------------------------------------------------------
TASK
Error – too may open files (comman issue) – file loaded in memory (open files)

Its menas Kernel have limitations of open files.

How many files open in memory?
[root@centoshost ~]# lsof   ------------------check list open files

[root@centoshost ~]# lsof | wc –l  ----------check count of open files in ram
7478
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# cat /proc/sys/    -------------------we want to change fs parameters
abi/    crypto/ debug/  dev/    fs/     kernel/ net/    vm/    

[root@centoshost ~]# cat /proc/sys/fs/file-max -----check open flles limitation
186668   -------------------------------we want to change these parameters to “600000”
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# vi /proc/sys/fs/file-max   -----we can’t go and write this file .
186668 -----change this value
“600000”
---------------------------------------------------------------------------------------------------------------------
1) [root@centoshost ~]# echo 600000 > /proc/sys/fs/file-max---change parameters of open file

[root@centoshost ~]# cat /proc/sys/fs/file-max  --- check open file limit  
600000   ---------Parameters will be change but this a temporary after reboot parameters
                           are as defailts menas “186668”
---------------------------------------------------------------------------------------------------------------------
How many parameters / value / tuning we can change

sysctl ----------system control tool used for kernel tuning

[root@centoshost ~]# sysctl –a  --- all the list of tuning parameters

[root@centoshost ~]# sysctl -a | wc –l   ----count of parameters we can change
764 ---we can 764 parameters will change

 [root@centoshost ~]# sysctl -a | grep –i file   ----check search specific parameters name
fs.file-max = 600000   ------------
---------------------------------------------------------------------------------------------------------------------
OR
2)  [root@centoshost ~]# sysctl -w fs.file-max=700000--- change parameters of open file
fs.file-max = 700000  -------------------change value

  
[root@centoshost ~]# sysctl -a | grep -i file   -------check file max value change or not
fs.file-nr = 5120                       0         700000
fs.file-max = 700000  -------change value    ----this is only temporary
---------------------------------------------------------------------------------------------------------------------
Advanstage of sysctl command ------without given path we will change parameters
---------------------------------------------------------------------------------------------------------------------
echo 600000 > /proc/sys/fs/file-max  ------Tune with Path
sysctl -w fs.file-max=700000      ------------Tune without Path
---------------------------------------------------------------------------------------------------------------------
How to change swap value

[root@centoshost ~]# sysctl -a | grep -i swap  ---first check parameters name and value
vm.swappiness = 60
OR
[root@centoshost ~]# cat /proc/sys/vm/swappiness ---check parameters value with path
60
---------------------------------------------------------------------------------------------------------------------
Swappiness   has tree value  ( 0 ) ,  ( 60 ) , ( 100 )
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# sysctl -w vm.swappiness=100  ---change the value

[root@centoshost ~]# sysctl -a | grep -i swap   -----check value
vm.swappiness = 100
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# echo 60 > /proc/sys/vm/swappiness ---- change the value

[root@centoshost ~]# sysctl -a | grep -i swap  -- -check value
vm.swappiness = 60
---------------------------------------------------------------------------------------------------------------------
How to persistent the tuning command

[root@centoshost ~]# vi /etc/rc.local ----add sysctl -w vm.swappiness=100 or
echo 60 > /proc/sys/vm/swappiness   for persistent but don’t used this file because kernel have separate file for tuning -----sysctl.conf file  (no need add commands in rc.local file )
---------------------------------------------------------------------------------------------------------------------
(rc.local-Its file execute before login and all the mention command are execute –Run before login)
---------------------------------------------------------------------------------------------------------------------
How to persistent the tuning command
[root@centoshost ~]# vi /etc/sysctl.conf  - This file for persistent kernel tuning  & copy TAG

#### swap memory #######

vm.swappiness = 100 ---------------------------Tags

###### Open File ######

fs.file-max = 800000 -------------------------Tag

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

[root@centoshost ~]# sysctl –p  ----After add tuning commands in sysctl.conf file,

sysctl –p  command re-read the file and execute without reboot

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

[root@centoshost ~]# sysctl -a | grep -i swap   -----check value

vm.swappiness = 100

[root@centoshost ~]# sysctl -a | grep -i file  -----check value

fs.file-nr = 5088          0          800000

fs.file-max = 800000

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

What is swappiness 

Swappiness is a Linux kernel parameter that controls the relative weight given to swapping out runtime memory, as opposed to dropping pages from the system page cache. Swappiness can be set to values between 0 and 100 inclusive. A low value causes the kernel to avoid swapping, a higher value causes the kernel to try to use swap space. The default value is 60, and for most desktop systems, setting it to 100 may affect the overall performance, whereas setting it lower (even 0) may decrease response latency.


Value
Strategy
vm.swappiness = 0
The kernel will swap only to avoid an out of memory condition. See the "VM Sysctl documentation".
vm.swappiness = 1
Kernel version 3.5 and over, as well as kernel version 2.6.32-303 and over: Minimum amount of swapping without disabling it entirely.
vm.swappiness = 10
This value is sometimes recommended to improve performance when sufficient memory exists in a system.
vm.swappiness = 60
The default value.
vm.swappiness = 100
The kernel will swap aggressively.

With kernel version 3.5 and over, as well as kernel version 2.6.32-303 and over, it is likely better to use 1 for cases where 0 used to be optimal.[2] To temporarily set the swappiness in Linux, write the desired value (e.g. 10) to /proc/sys/vm/swappiness using the following command, running as root user:

---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# echo 3 > /proc/sys/vm/drop_caches  ----clear memory

1 ---Dirty Inode Clean
2 ---Dirty Block Clean
3 –- Both Inode + Block Clean
---------------------------------------------------------------------------------------------------------------------
I want to check ORACLE Tuning Parameters -3 to 4 Tuning Parameters

---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# sysctl -a | grep -i shm   -----oracle parameters
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096
kernel.shm_rmid_forced = 0
x
[root@Tusharjahdav ~]# sysctl -a | grep -i sem   -----oracle parameters
kernel.shmmax = 68719476736
kernel.sem = 250        32000   32      128
---------------------------------------------------------------------------------------------------------------------
How to persistent the tuning command
---------------------------------------------------------------------------------------------------------------------
[root@centoshost ~]# vi /etc/sysctl.conf  -- this file for persistent kernel tuning
#### swap memory ####
vm.swappiness = 100

##### file max limit #####
fs.file-max = 900000

####### Oracle #####
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
kernel.shmmni = 4096

wq!
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# sysctl –p   ------Re-read & Executed without reboot the system

vm.swappiness = 100  ------------------------swap value
fs.file-max = 900000  ------------------------File system value
kernel.shmmax = 68719476736 ---------------------oracle value
kernel.shmall = 4294967296 ---------------------oracle value
kernel.shmmni = 4096   ---------------------oracle value
---------------------------------------------------------------------------------------------------------------------

 Make node - Point / Location

Node - means device driver identity of major and minor numbers
---------------------------------------------------------------------------------------------------------------------
Kernel Identify the driver by Major number and Minor number
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# ls -l /dev/sda  ------to check hdd devices
sda   sda1  sda2  sda3 ||  sdb   sdb1  ||  sdc   sdc1 ||  sdd   sdd1  -----4 HDD connected

[root@Tusharjahdav ~]# ls -l /dev/sda1
brw-rw----. 1 root disk 8, 1 Jan  7 05:15 /dev/sda1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# df –h  ----check hdd mount point
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda2               18G  2.9G   14G  17% /
tmpfs                  497M   72K  497M   1% /dev/shm
/dev/sda1              291M   35M  242M  13% /boot
/dev/mapper/myvol-lv1  3.2G   12M  3.1G   1% /Dell
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# ls -l /dev/sdc   -----check hdd partition
brw-rw----. 1 root disk 8, 32 Jan  7 05:15 /dev/sdc
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# df –h  -----check hdd partition
Filesystem             Size  Used Avail Use% Mounted on
/dev/sda2               18G  2.9G   14G  17% /
tmpfs                    497M   72K  497M   1% /dev/shm
/dev/sda1              291M   35M  242M  13% /boot
/dev/mapper/myvol-lv1  3.2G   12M  3.1G   1% /Dell ---------/dev/sda3
---------------------------------------------------------------------------------------------------------------------
Are the major, minor number Unique?
Do we have any citations and reference to it?
NAME   MAJ:MIN RM   SIZE RO MOUNTPOINT
sda      8:0    0 465.8G  0
├─sda1   8:1    0 298.2M  0
├─sda2   8:2    0     3G  0
├─sda3   8:3    0 458.7G  0 /
├─sda4   8:4    0     1K  0
└─sda5   8:5    0   3.8G  0
sr0     11:0    1  1024M  0

[root@Tusharjahdav ~]# ls -l /dev/sda  --- to check major and minor number
brw-rw----. 1 root disk 8, 0 Jan  7 05:15 /dev/sda
                                  
[root@Tusharjahdav ~]# ls -l /dev/sdb  --- to check major and minor number
brw-rw----. 1 root disk 8, 16 Jan  7 05:15 /dev/sdb

[root@Tusharjahdav ~]# ls -l /dev/sdc  --- to check major and minor number
brw-rw----. 1 root disk 8, 32 Jan  7 05:15 /dev/sdc

[root@Tusharjahdav ~]# ls -l /dev/sdd   --- to check major and minor number
brw-rw----. 1 root disk 8, 48 Jan  7 05:15 /dev/sdd


---------------------------------------------------------------------------------------------------------------------
                 Major number is – 8   |     minor number is --- 0 to 48
---------------------------------------------------------------------------------------------------------------------
Task -Corrupt my device driver link /dev/sda3
---------------------------------------------------------------------------------------------------------------------
/dev/mapper/myvol-lv1 3.2G   12M 3.1G   1% /Dell ---------/dev/sda3
---------------------------------------------------------------------------------------------------------------------
Example:
[root@Tusharjahdav ~]# mknod    /opt/kartina   b    8    3  ----- ( b =block size )

[root@Tusharjahdav ~]# mount /opt/kartina /common  -------mount /common DIR

[root@Tusharjahdav ~]# df –h ----check created nodes
---------------------------------------------------------------------------------------------------------------------
Example:
 [root@Tusharjahdav ~]# mknod    /dev/sda3       b    8     3   ----- ( b =block size )

[root@Tusharjahdav ~]# mount /dev/sda9 /common  -------mount on new created node

[root@Tusharjahdav ~]# df –h ----check created nodes

[root@Tusharjahdav ~]# vi /etc/fstab  ----add entry for persistence

/dev/sd3             /comman                   ext3    defaults        0 0
---------------------------------------------------------------------------------------------------------------------
DEV Runs insides the Drives – dsa1 / sdb1 /sdc1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# ls /dev/sdb*  -----check HDD partitions
/dev/sdb     /dev/sdb1

[root@Tusharjahdav ~]# ls /dev/sdc*   -----check HDD partitions
/dev/sdc      /dev/sdc1
---------------------------------------------------------------------------------------------------------------------
[root@Tusharjahdav ~]# MAKEDEV /dev/sdd

[root@Tusharjahdav ~]# MAKEDEV /dev/sdb

[root@Tusharjahdav ~]# MAKEDEV /dev/sda

[root@Tusharjahdav ~]# MAKEDEV /dev/sde  --------to create sda driver

[root@Tusharjahdav ~]# ls /dev/sde*
/dev/sde     /dev/sdeb10  /dev/sded12  /dev/sdef14  /dev/sdeh2   /dev/sdej4   /dev/sdel6   /dev/sden8   /dev/sdeq    /dev/sdes10  /dev/sdeu12  /dev/sdew14  /dev/sdey2
/dev/sde1    /dev/sdeb11  /dev/sded13  /dev/sdef15  /dev/sdeh3   /dev/sdej5   /dev/sdel7   /dev/sden9   /dev/sdeq1   /dev/sdes11  /dev/sdeu13  /dev/sdew15  /dev/sdey3
/dev/sde10   /dev/sdeb12  /dev/sded14  /dev/sdef2   /dev/sdeh4   /dev/sdej6   /dev/sdel8   /dev/sdeo    /dev/sdeq10  /dev/sdes12  /dev/sdeu14  /dev/sdew2   /dev/sdey4
/dev/sde11   /dev/sdeb13  /dev/sded15  /dev/sdef3   /dev/sdeh5   /dev/sdej7   /dev/sdel9   /dev/sdeo1   /dev/sdeq11  /dev/sdes13  /dev/sdeu15  /dev/sdew3   /dev/sdey5
/dev/sde12   /dev/sdeb14  /dev/sded2   /dev/sdef4   /dev/sdeh6   /dev/sdej8   /dev/sdem    /dev/sdeo10  /dev/sdeq12  /dev/sdes14  /dev/sdeu2   /dev/sdew4   /dev/sdey6


Device names, device nodes, and major/minor numbers

The Linux kernel represents character and block devices as pairs of numbers <major>:<minor>.
Some major numbers are reserved for particular device drivers. Other major numbers are dynamically assigned to a device driver whenLinux boots. For example, major number 94 is always the major number for DASD devices while the device driver for channel-attached tape devices has no fixed major number. A major number can also be shared by multiple device drivers. See /proc/devices to find out how major numbers are assigned on a running Linux instance.
The device driver uses the minor number <minor> to distinguish individual physical or logical devices. For example, the DASD device driver assigns four minor numbers to each DASD: one to the DASD as a whole and the other three for up to three partitions.
Device drivers assign device names to their devices, according to a device driver-specific naming scheme. Each device name is associated with a minor number.
Figure 1. Minor numbers and device names
User space programs access character and block devices through device nodes also referred to as device special files. When a device node is created, it is associated with a major and minor number.
Figure 2. Device nodes


Red Hat Enterprise Linux 7.2 uses udev to create device nodes for you. There is always a device node that matches the device name that is used by the kernel, and additional nodes might be created by special udev rules. See the udev man page for more details.

 [root@Tusharjahdav ~]# less /proc/devices   -----check mojor number of devices

                         Character devices:                                                 Block devices:
 1 mem
1 ramdisk
  4 /dev/vc/0
259 blkext
  4 tty
  7 loop
  4 ttyS
  8 sd
  5 /dev/tty
  9 md
  5 /dev/console
 11 sr
  5 /dev/ptmx
 65 sd
  7 vcs
 66 sd
 10 misc
 67 sd
 13 input
 68 sd
 14 sound
 69 sd
 21 sg
 70 sd
 29 fb
 71 sd
 99 ppdev
128 sd
116 alsa
129 sd
128 ptm
130 sd
136 pts
131 sd
162 raw
132 sd
180 usb
133 sd
189 usb_device
134 sd
202 cpu/msr
135 sd
203 cpu/cpuid
253 device-mapper
249 hidraw
254 mdp
250 usbmon

251 bsg

252 pcmcia

253 watchdog

254 rtc