List particular USER or GROUP owned files: How to ?




List particular USER or GROUP owned files: How to ?



some time we need to find out what are all the files owned by particular user id or Group .That time we can use "FIND" command to get that list.

There is switches "-user or -group" can we used for this.


List out particular Group owned files:

#find directory-location -group {group-name} -name {file-name}


Ex : ## find /home -group ftpusers


List out particualr USER owned files

#find directory-location -user {username} -name {file-name}

Ex : # find /var -user john


Multipath in Linux : Quick view


The Below post will help you on how to check the multipath information on a linux server. 


Multipath Package Version

#rpm -qa | grep multipath


Multipath Service Status


#chkconfig --list multipathd


Multipath Devices Basic Information


#/sbin/multipath -v2 -d -ll


Multipath Devices Detailed Information


#/sbin/multipath -v3 -d -ll

#grep -vE '^#|^ *$' /etc/multipath.conf

Device Mapper Files
 

#for MultiPath in $(/sbin/multipath -v1 -d -l); do ls -l /dev/mapper/${MultiPath}; done


Multipath Bindings


#cat /var/lib/multipath/bindings



LINUX Interview Questions : PART 3

 

Click Here for : PART 1: LINUX Interview Questions 

Click Here for : PART 2: LINUX Interview Questions


PART 3: LINUX Interview Questions

In part 3 we are going to see the below questions and answers.


13. What is swap ? Why we need swap partition?

14. How to Create / extend / remove swap partition?

15. Why does kernel need IO scheduler?

16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?

17: How to restore the default system permission on  Linux ?



13. What is swap ? Why we need swap partition?


Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full,
inactive pages in memory are moved to the swap space.

Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.

Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.


14. How to Create / extend / remove swap partition?


A.Create a SWAP Partition:

1. Create a file system on disk

#fdisk /dev/cciss/c?d?

Note : Make the new partition as swap. Change toggle id to 82 (for swap).


2. Make the FS as Swap partition

#mkswap /dev/cciss/c?d?p?


3. Run swapon commad to enable swap space

#swapon /dev/cciss/c?d?p?


4.Verify the new swap partition

    #cat /proc/swap

    or

    #swapon -s

5. Add this new swap partion entry to /etc/fstab

vi /etc/fstab

/dev/cciss/c?d?p? swap swap defaults 0 0



B.How to increase / extend SWAP partition ?

Follow the below steps to increase the Swap for LVM

    # swapoff -v /dev/rootvg/swapvol
    # lvm lvresize /dev/rootvg/swapvol -L +8G  or lvextend -L +8G /dev/rootvg/swapvol
    # mkswap /dev/rootvg/swapvol
    # swapon -va


C.How to remove the swap partition ?

1.swapoff -v /dev/VolGroup00/swap_vol

2.lvremove /dev/VolGroup00/swap_vol

3. Remove the entry from /etc/fstab


15. Why does kernel need IO scheduler?



Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk
thrashing: if one process was reading from one part of the disk, and one writing to another, the heads would have to seek back and forth across the disk for
every operation. The scheduler’s main goal is to optimise disk access times.

16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?


Assuming that we have a disk name /dev/sda, type :

# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler



How to set I/O Scheduler For A Hard Disk ?

To set a specific scheduler, simply type the command as follows:

# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler

OR

Edit /boot/grub/grub.conf and enter in kernel line "elevator=noop" or any other scheduler available.

There are currently 4 available IO schedulers :

* No-op Scheduler
* Anticipatory IO Scheduler (AS)
* Deadline Scheduler
* Complete Fair Queueing Scheduler (CFQ)


Changing Scheduler:

The most reliable way to change schedulers is to set the kernel option “elevator” at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.

elevator=cfq

17. How to restore the default system permission on  Linux ?


We can recover or restore the defualt file / folder permission and ownership using rpm command with the options -setperms and --setugids. 
This is very usefull option which i found in RPM command.

1) To reset uids and gids on files and directories :

 # for i in $(rpm -qa); do rpm --setugids $i; done


2) To permissions on files and directories

 #for i in $(rpm -qa); do rpm --setperms $i; done



Click Here for LINUX Interview Questions : PART 1

Click Here for LINUX Interview Questions : PART 2


 

LINUX Interview Questions : PART 2

Linux Interview Questions : PART 1 : Click Here



in PART 2 - we are going to see the below Questions and answers:


7. What is hard link and soft link? How to create symbolic link?

8. What is INODE ? How to reduce inode utilization?

9. What is HARD and SOFT mount in NFS ?

10. Explain NFS mount options ?

11. CPU states in TOP or Explain o/p of TOP command

12. How to check architecture of Linux server OS


 

Question 7:  What is hard link and soft link? How to create symbolic link?

    

A.  Hard links cannot link directories.
    Cannot cross file system boundaries.

B.  Soft or symbolic links are just like hard links. It allows to associate multiple filenames with a single file. However, symbolic links allows:

    To create links between directories.
    Can cross file system boundaries.



How do I create symbolic link?

You can create symbolic link with ln command:

#ln -s /path/to/file1.txt /path/to/file2.txt

(inode number will be same for hard linked file )

#ln /mades/file1 /mades/file2 - ( create hard link)


Question 8: What is INODE ? How to reduce inode utilization?


An inode is a data structure on a traditional Unix-style file system such as UFS or ext3.
An inode stores basic information about a regular file, directory, or other file system object.

=> File type (executable, block special etc)
=> Permissions (read, write etc)
=> Owner
=> Group
=> File Size
=> File access, change and modification time

(remember UNIX or Linux never stores file creation time, this is favorite question asked in UNIX/Linux sys admin job interview)


How to reduce inode usage in File system?


For examble /opt filesystem's inode usage is high means we have to do below steps

# bdf -i /opt : check the FS usage

Create a test directory on your filesystem;

# mkdir /opt/test

Create a script that will create 10000 null files.

# cd /opt/test
# i=1
# while [ $i -lt 10000 ]
> do
> touch $i
> i=`expr $i + 1`
> done

Else you will be watching the terminal for years to get you the prompt or else CTRL + C will do :-D

once files are created do

#bdf -i /opt


Question 9 : What is HARD and SOFT mount in NFS ?



In HARD mount ...

If the NFS file system is hard mounted, the NFS daemons will try repeatedly to contact the server. The NFS daemon retries will not time out, will affect system performance, and you cannot interrupt them

If you just mount a file system without specifying hard or soft, the default is a hard mount. Hard mounts are preferable because of the stateless nature of NFS.

If a client sends an I/O request to the server (such as an ls -la), and the server gets rebooted, in client machine the process will keep on running.
This preserves data transfers in the event of a server failure

IN SOFT Mount :

A soft mount allows the client to stop trying an operation after a period of time. If the NFS server goes down at the time of data transfer , it will alert and the process will do down.Thsi may cause the data corruption.
A soft link will return with an error and fail.

you should only use soft mounts in the cases where client responsiveness is more important than data integrity.

In another word ..soft mount will allow automatic unmount if the filesystem is idle for a specified time period

Question 10 : Explain NFS mount options ?


Syntax to mount NFS FS:

#mount -t vfstype [-o options] NFS Servername:/exporteddirectory /mount point

or

#mount -t nfs -o options host:/remote/export /local/directory



Mount options explained below :

1. -0 initr

This option is used in non reliable network, or network having more network congestion. NFS request will be interrupted when server is not reachable.

2. -o hard

If hard option is specified during nfs mount, user cannot terminate the process waiting for NFS communication to resume. For ex ..if u ran ls -a command on ur NFS mounted directory but that time ur NFS server went down means .
The process wont get killed or stopped ..it will wait until the NFS server and mount poit become available.

3. -o soft

If soft option is specified during nfs mount, user will get error alert when NFS server is not reachable. This is just inverse of hard mount option. It wont wait for reply if the NFS server went down , it will alert us and the process will go down.

4. -o Nfsvers=value

If this option is specified during nfs mount NFS client uses particular NFS protocol version to communicate.

For example - TCP

# mount -t nfs -o tcp 192.168.1.4:/mnt/array1/RHEL5 /data/
# mount | grep -i tcp
 192.168.1.4:/mnt/array1/RHEL5 on /data type nfs (rw,tcp,addr=192.168.1.4)

The Difference between HARD and SOFT mount option explained in another POST. 




Question 11:  Explain TOP command output / Various states of CPU


# us -> User CPU time: The time the CPU has spent running users’ processes that are not niced.
# sy -> System CPU time: The time the CPU has spent running the kernel and its processes.
# ni -> Nice CPU time: The time the CPU has spent running users’ process that have been niced.
# wa -> iowait: Amount of time the CPU has been waiting for I/O to complete.
# hi -> Hardware IRQ: The amount of time the CPU has been servicing hardware interrupts.
# si -> Software Interrupts.: The amount of time the CPU has been servicing software interrupts




Question 12: How to check architecture of Linux OS


We can use below commands to check the architecture of server OS,


1. #getconf LONG_BIT

2.#uname -a

3.#grep flags /proc/cpuinfo

4.#arch

5.#file /bin or file bc







SWAP Partition in Linux: How to?



What is SWAP ? Why we need SWAP Partition ?


Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the physical memory is full, inactive pages in memory are moved to the swap space.

Swap space is located on hard drives, which have a slower access time than physical memory.

 


How to create SWAP Partition ?
1. Create a file system on disk

#fdisk /dev/cciss/c?d?

Note : Make the new partition as swap. Change toggle id to 82 (for swap).


2. Make the FS as Swap partition

#mkswap /dev/cciss/c?d?p?


3. Run swapon commad to enable swap space

#swapon /dev/cciss/c?d?p?


4.Verify the new swap partition

    #cat /proc/swap

    or

    #swapon -s

5. Add this new swap partion entry to /etc/fstab

vi /etc/fstab

/dev/cciss/c?d?p? swap swap defaults 0 0

How to remove the swap partion ?

1.swapoff -v /dev/VolGroup00/swap_vol

2.lvremove /dev/VolGroup00/swap_vol

3. Remove the entry from /etc/fstab



 


How to increase / extend SWAP partion ?

Follow the below steps to increase the Swap for LVM

    # swapoff -v /dev/rootvg/swapvol
    # lvextend -L +8G /dev/rootvg/swapvol
    # mkswap /dev/rootvg/swapvol
    # swapon -va

LINUX Interview Questions : PART 1


 

LINUX Interview Questions : PART 1



Hi Friends...i planned to update interview questions and answers for LINUX admins. Hope this will help you to refresh your knowledge at the time of interview perparation.


Few points before start,

1.Be Clear and Frank while prepare resume. Since mostly question wil be asked based on ur resume.
2.Try to focus more about ur day to day job in resume.
3.Make sure you are clear in basic Linux such as booting, LVM, Architecture, servermodel which you worked.
4.Before give interview write down your day to day work , server model information ,your current environment details and review your self.
5.Dont prepare upto last minute it will spoil your mood and confidence.
6.Once interview over note down the Question which they asked. It will help for next interview.

For L1 & L2 Admin Interview:


Maximum the Question will be on below area

1.Booting procedure of linux server
2.user administration
3.LVM -FS creation/ extend / FS issues & recover
4.Software install / remove / update - RPM or YUM
5.Basic services config /troubleshoot - E.G : NFS ,FTP , SAMBA , DNS , DHCP
6.Utilization issues - CPU , MEMORY , DISK
7.Hardware errors and troubleshoot
8.PAtch installation / roll back


Ok Now we can start look into questions and answers

QUESTIONS :


1.Explain Booting Procedure?
2.What is stage 1.5 Bootloader ?
3.How will you reinstall GRUB?
4.How to resolve booting issues in linux?
5.How to reset root password or recover root password

6.What is Super Block? How will you recover it? 
 


Question 1: Explain Booting procedure or steps in Linux?



1. Once System powered on, it automatically invokes BIOS

2. BIOS will start the processor and perform a POST [power on self test] to check the connected device are ready to use and are working properly.

3. After POST ,  BIOS will check for the booting device. The boot sector is always the first sector of the hard disk and BIOS will load the MBR into the memory.
   MBR holds the boot loader of the OS.

4. Then boot loader takes the control of the booting process.

5. GRUB is the boot loader for Linux.

6. Depending on the boot option selected the kernel is loaded first.

7. After kernel is loaded the kernel will take the control of the booting process

8. Initrd will be loaded which contains drivers to detect hardware (its called Initialization of RAM Disk)

9. Then it will initialize all the hardware including I/O processors etc.

10. Kernel will mounts the root partition as read-only

11. INIT is loaded as the first process.

12. INIT will mount the root partition and other partitions as read/write and checks for file system errors.

13. Sets the System Clock, hostname etc..

14. Based on the Runlevel, it will load the services and runs the startup scripts which are located in /etc/rcX.d/ (Network, nfs, SSH etc.)

15. Finally it runs the rc.local script & Now the login prompt will appear.


Question 2: What is stage 1.5 boot loaded in linux?


The great thing about GRUB is that it includes knowledge of Linux file systems. Instead of using raw sectors on the disk, as LILO does,
GRUB can load a Linux kernel from an ext2 or ext3 file system. It does this by making the two-stage boot loader into a three-stage boot loader.

A. Stage 1.5 boot loader , it contains extra coe to allow cylinders above 1024, or LBA type drives, to be read.
B. It will be stored on MBR or Boot partition .
C. Stage 1 (MBR) boots a stage 1.5 boot loader that understands the particular file system containing the Linux kernel image.
D. Basically this module will load the knowledge of Filesystem to Grub to read the kernel

so ,

Stage 1 Boot loaded is : MBR
Stage 1.5 Boo loader : e2fs_stage1_5
Stage 2 Boot loader is  : GRUB

  


Question 3:  How to reinstall GRUB?


A.Boot up using RHEL4 disk.

B.Enter into rescue mode

 #linux rescue  (hit ok)

C. Then follow below commands

 # chroot /mnt/sysimage

 # grub
 
 # find /boot/grub/stage1 or find /grub/stage1

    root(hd0,0) //example o/p

Now install the GRUB

 # setup (hd0)

 # EXIT

Another Method

 #linux rescue

 # chroot /mnt/sysimage

 # /sbin/grub-install /dev/hda  


Question 4:  Linux Booting Issues : How to solve ??


Option 1: init not found error
Option 2: Run fsck on all FS in rescue mode
Option 3: Reinstall GRUB
Option 4: Recover grub.conf / grub configuration

Option 1: For normal panic and "init not found" error.

Error : "init not found" displayed

1) Launch the system to Bash shell prompt

Reboot the server and interrupt to edit the GRUB.

Edit grub and enter the below in last

init=/bin/bash

Then save and exit and boot the server. This will launch you straight into a Bash shell prompt.Then you can remount “/” file system and check /var/log/messages for any error.

Note :  init=/bin/bash (Grub boot loader) or linux init=/bin/bash (if Lilo boot loader).

2) Once server booted and if it is in Bash shell prompt

 #mount -o remount,rw /

3) Now  you can check the log messages and try to find the reason for server pacnic or error.

#more /var/log/messages


Option 2:  If the above option not helped then follow the next

1) Boot from the Linux First CD (boot CD).

2) Type “boot rescue” at Linux boot prompt.

3) After the bash shell prompt show up, type the below command

   # chroot /mnt/sysimage

a) Run fsck and Check for any disk error

  #fdisk -l /dev/sda  //check how many partion you have

   then run fsck on each partition
    
  #fsck -y /dev/sda2'

Option 3: If the above also not helped then reinstall grub and retry.

 In rescue mode.

   #  chroot /mnt/sysimage

   # /sbin/grub-install /dev/hda





Option 4: If a system has issues with the GRUB configuration


(possibly caused by incorrect changes to the the GRUB configuration file, installation of another OS, changes to device ordering due to hardware or BIOS changes, etc.)

   # grub> find /boot/grub/grub.conf (or) grub>find /grub/grub.conf  (or) find /boot/grub/stage1
    (hd0,1)
    (hd1,2)

    >> This tells us that we have two /boot partitions. Then we have to reinstall the GRUB config on disk (one by one) and try.

   #grub> root (hd0,1)    //Write the GRUB bootloader on the MBR of the first disk
    grub> setup (hd0)
    grub>quit

  If you have doubt as to where the root partition is located then try to find a file in /etc.
 
    #grub> find /etc/fstab
      (hd0,1)


Note: You must pay attention to your devices, for me "hd0" is the root disk and (hd0,1) is /boot partition , and (hd0,1) is my ROOT (/) partition. mostly / "root" partion will be on LVM.
       You might not even have "hd0" mapped out. Review your "/boot/grub/device.map" file

      #cat /boot/grub/device.map



Question 5 :  How to recover or rest Root password in LINUX?


While booting
   

   1. Select the kernel
   2. Press the "e" key to edit the entry
   3. Select second line (the line starting with the word kernel)
   4. Press the "e" key to edit kernel entry so that you can append single user mode
   5. Append the letter "S" (or word Single) to the end of the (kernel) line
   6. Press ENTER key
   7. Now press the b key to boot the Linux kernel into single user mode
   8. At prompt type passwd command to reset password:

You need to mount at least / and other partitions:
# mount -t proc proc /proc
# mount -o remount,rw /

Change the root password,

# passwd

thenreboot system:
# sync
# reboot




Question 6: What is super Block and how will u recover it ?


The blocks used for two different purpose:

   1. Most blocks stores user data aka files (user data).
   2. Some blocks in every file system store the file system's metadata. 


So what the hell is a metadata?

    File system type
    Size
    Status
    Information about other metadata structures


To find super block

#dumpe2fs /dev/sda3|grep -i superblock

or

# mke2fs -n /dev/sda3



To repair file system by alternative-superblock use command as follows:

# e2fsck -f -b 8193 /dev/sda3




Click Here for : LINUX Interview Questions : PART2





Add New Lun / SAN disk on Linux server

How to rescan and add new Luns to server?

Step 1: Get the list of HBA and exisiting disk details.

#ls /sys/class/fc_host

#fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l

Step 2: Scan the HBA ports (Need to scan all HBA port)

#echo "1" > /sys/class/fc_host/host??/issue_lip

# echo "- - -" > /sys/class/scsi_host/host??/scan
 

Do this above steps for all HBA cards

Step3 : Check the newly added Lun    

# cat /proc/scsi/scsi | egrep -i 'Host:' | wc -l

# fdisk -l 2>/dev/null | egrep '^Disk' | egrep -v 'dm-' | wc -l





Add / Remove single disk device in Linux

How to Delete a Single Device ?

In addition to re-scanning the entire bus, a specific device can be added or existing device deleted using the following command:

# echo 1 > /sys/block/devName/device/delete

E.G

# echo 1 > /sys/block/sdc/device/delete


or

# echo "scsi remove-single-device  " > /proc/scsi/scsi
# fdisk -l

How to Add a Single Device ?

Some time if you know your device path which your are going to add then you can use below method to add it in server.

To add a single device explicitly, use the following syntax:

# echo "scsi add-single-device " > /proc/scsi/scsi

Where,

    : Host
    : Bus (Channel)
    : Target (Id)
    : LUN numbers


For e.g. add /dev/sdb with host # 0, bus # 0, target # 1, and LUN # 0,

 enter:

# echo "scsi add-single-device 0 0 1 0">/proc/scsi/scsi
# fdisk -l
# cat /proc/scsi/scsi




Network Configuration in Linux : PART 2

Network config in Linux: PART 1 - Click Here


In This part 2 we are going to see the below points ,


5.Configuring IP address for interface?
6.How to define the routing ?
7.How to activate / deactivate network interfaces ?
8.How to enable IP Forward in Linux?
9.Speed and Duplex setting for interface?
10.Usefull commands in Linux for network troubleshoot.


  5. Configuring IP address for interface:

A.Command Line using ifconfig   //Temperary

  # ifconfig eth0   XXX.XXX.XXX.XXX netmask 255.255.255.0 broadcast XXX.XXX.XXX.255
B.Manually assign IP in config file - /etc/sysconfig/network-scripts/ifcfg-ethX  /permanent

  #vi /etc/sysconfig/network-scripts/ifcfg-eth0

For Alias IP

  #vi /etc/sysconfig/network-scripts/ifcfg-eth0:0

C.Using GUI Tool - /usr/sbin/system-config-network


6. How to define / add routing ?


A. Through 'route' command

   route add default gw XXX.XXX.XXX.XXX dev eth0
   route add  -net  XXX.XXX.XXX.0  netmask 255.255.255.0 gw XXX.XXX.XXX.XXX dev eth0

B. Modify  the config file -  /etc/sysconfig/static-routes   //only for static routes

C. Define the parameter in  config file - /etc/sysconfig/network-scripts/ifcfg-ethX




7. Activate deactivate Network interfaces:


A. Activate:

   # /sbin/ifup eth0  (or) #ifconfig eth0 up
B. De-Activate:

   # /sbin/ifdown eth0 (or) #ifconfig eth0 down
  

8 .Enable IP forward:

A. Turn on IP forwarding to allow Linux computer to act as a gateway or router.

#echo 1 > /proc/sys/net/ipv4/ip_forward

B. Modify the config file entry - /etc/sysctl.conf

  #vi /etc/sysctl.conf

  net.ipv4.ip_forward = 1


C. Verify ip forward

#cat /proc/sys/net/ipv4/ip_forward

1



9. Speed and Duplex setting in  Linux ?

A. Using the command : mii-tool  // view, manipulate media-independent interface status

 To view the speed - # mii-tool -v


 To set the speed  - #mii-tool -F option
                             #mii-tool -A option

B.Using the command : ethtool    // Display or change ethernet card settings

ethtool -g eth0     Queries ethernet device for rx/tx ring parameter information.
ethtool -a eth0     Queries ethernet device for pause parameter information.
ethtool -c eth0     Queries ethernet device for coalescing information.
ethtool -i eth0     Queries ethernet device for associated driver information.
ethtool -d eth0     Prints a register dump for the specified ethernet device.
ethtool -k eth0     Queries ethernet device for offload information.
ethtool -S eth0     Queries ethernet device for NIC and driver statistics.


10. Usefull commands and files in Linux for netowrk troubleshoot:

1. /etc/rc.d/init.d/network   start - command to start, restart or stop the network

2. /etc/inetd.conf  -  Network Socket Listener Daemons

   - The network listening daemons listen and respond to all network socket connections made on the TCP/IP ports assigned to it. The ports are defined by the file /etc/services
 
   - Entries in this file consist of a single line made up of the following fields:

        service socket-type protocol wait user server cmdline

Note : The inetd daemon must be restarted to pick up the changes made to the file:
      
        #/etc/rc.d/init.d/inetd restart

3.netstat - Display connections, routing tables, stats etc

    List all connected processes: #netstat -nap
    Show network statistics:      #netstat -s
    Display routing table info:   #netstat -rn
    Display interface statistics: #netstat -i

4.traceroute - print the route packets take to network host

5. socklist - Display list of open sockets, type, port, process id and the name of the process. Kill with fuser or kill

6. nslookup - Give a host name and the command will return IP address. Note that nslookup does not use the /etc/hosts file

7. Mii-tool - view, manipulate media-independent interface status

8. ethtool - Display or change ethernet card settings

9. tcpdump - Dump traffic on a network.





Network config in Linux: PART 1 - Click Here


1.Commands list hardwares in Linux?
2.How to List Network cards in Linux server?
3.Config Files for network in Linux?
4.Adding new network card on Linux server?


In part 1 - the above points discussed.  

Network configuration in Linux : PART 1

Network configuration in Linux : PART 1


In this post i just like to share how to configure netowrk card / IP address in Linux server. Hope this will help you.


The below Points are explained,

1.Commands list hardwares in Linux?
2.How to List Network cards in Linux server?
3.Config Files for network in Linux?
4.Adding new network card on Linux server?
5.Configuring IP address for interface?
6.How to define the routing ?
7.How to activate / deactivate network interfaces ?
8.How to enable IP Forward in Linux?
9.Speed and Duplex setting for interface?
10.Usefull commands in Linux for network troubleshoot.




1. List hardware devices in linux?

    lspci : List all PCI devices.
    lshw  : List all hardware.
    dmidecode  : List all hardware data from BIOS.
    ifconfig   : Outdated network config utility.
    ip  : Recommended new network config utility.


2. List of network cards??

1.# lspci | egrep -i --color 'network|ethernet'

2.# lshw -class network

3.# ifconfig -a

4.# ip link show 0r #ip addr show

5.# cat /proc/net/dev



3. Network config files:

A. /etc/resolve.conf   : List DNS servers for internet domain name resolution.

B. /etc/hosts          : Lists hosts to be resolved locally (not by DNS)

C. /etc/nsswitch.conf  : List order of host name search. Typically look at local files, then NIS server, then DNS server.

D. /etc/sysconfig/network: Specify network configuration. eg. Static IP, DHCP, NIS, etc

E. /etc/sysconfig/network-scripts/ifcfg-device : Specify TCP network information



A. /etc/resolv.conf:

E.g of host name resolver config file entries.

More /etc/resolv.conf

search name-of-domain.com  - Name of your domain or ISP's domain if using their name server
nameserver XXX.XXX.XXX.XXX - IP address of primary name server
nameserver XXX.XXX.XXX.XXX - IP address of secondary name server


B./etc/hosts

E.G of  locally resolve node names to IP addresses . This informs Linux of local systems on the network which are not handled by the DNS server.

127.0.0.1         your-node-name.your-domain.com  localhost.localdomain  localhost
XXX.XXX.XXX.XXX   node-name

C. /etc/sysconfig/network

- Red Hat network configuration file used by the system during the boot process.

D. /etc/sysconfig/network-scripts/ifcfg-XXX - config file for network card

E.g - /etc/sysconfig/network-scripts/ifcfg-eth0

root# more ifcfg-eth0
# Intel Corporation 82545EM Gigabit Ethernet Controller
DEVICE=eth0
BOOTPROTO=static
DHCPCLASS=
ONBOOT=yes
IPADDR=10.175.2.10
NETMASK=255.255.255.0
root #

E. /etc/sysconfig/network -scripts/ifcfg-ethXX

- Static IP address Configuration: (Configure gateway address)

- Entries in this files explianed below

---------------------------------------------------------
 For static IP the file should have below entries,

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname
FORWARD_IPV4=true         - True for NAT firewall gateways and linux routers.
                            False for everyone else - desktops and servers.
GATEWAY="XXX.XXX.XXX.YYY" - Used if your network is connected to another network or the internet. Static IP configuration. Gateway not defined here for DHCP client.
---------------------------------------------------------
For DHCP client config file should have below entries

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname

---------------------------------------------------------
 For NIS client config the file should have below entries.

NETWORKING=yes
HOSTNAME=my-hostname      - Hostname is defined here and by command hostname
NISDOMAIN=NISProject1     - NIS domain to attach

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


4. Adding network card to Linux server?

Login to server as root and then navigate to the directory /lib/modules/ . Here you will find the modules supported by your system.
Assuming that you have a 3Com ethernet card, in which case, the module name is 3c59x ,
you have to add this in the /etc/modules.conf or /etc/modprobe.conf  file to let the machine detect the card each time the machine boots.


Add driver for ur new card  manually in /etc/modprobe.conf  (Kernel 2.6)  or etc/modules.conf (kernel 2.4)

#vi  /etc/modprobe.conf 

alias eth1 e100
alias eth2 "Driver name"    //add this line for ur eth2 network card with driver info (3c59x)

Load the module to kernel

# /sbin/insmod -v "drivername"  // 3c59x

Check the loaded netowrk card in server using below commands

Then Reboot server and check the new card status.


#lspci |grep -i ethernet

# more /etc/modprobe.conf |grep -i eth

Modprobe command line options:

    -r : to unload the module.
    /sbin/modprobe -l \*   :list all modules.
    /sbin/modprobe -lt net \*  : List only network modules
    /sbin/modprobe -t net \*   : Try loading all network modules and see.
 


 For below Points please check the part 2 :

5.Configuring IP address for interface?
6.How to define the routing ?
7.How to activate / deactivate network interfaces ?
8.How to enable IP Forward in Linux?
9.Speed and Duplex setting for interface?
10.Usefull commands in Linux for network troubleshoot.


Click here for PART 2 : Network config in Linux ?



 

Install Network card in Linux : How to ??

Login to server as root and then navigate to the directory /lib/modules/ . Here you will find the modules supported by your system.
Assuming that you have a 3Com ethernet card, in which case, the module name is 3c59x ,
you have to add this in the /etc/modules.conf or /etc/modprobe.conf  file to let the machine detect the card each time the machine boots.


Add driver for ur new card  manually in /etc/modprobe.conf  (Kernel 2.6)  or etc/modules.conf (kernel 2.4)

#vi  /etc/modprobe.conf  

alias eth1 e100
alias eth2 "Driver name"    //add this line for ur eth2 network card with driver info (3c59x)

Load the module to kernel

# /sbin/insmod -v "drivername"  // 3c59x 

Check the loaded netowrk card in server using below commands

Then Reboot server and check the new card status.


#lspci |grep -i ethernet

# more /etc/modprobe.conf |grep -i eth

Modprobe command line options:

    -r : to unload the module.
    /sbin/modprobe -l \*   :list all modules.
    /sbin/modprobe -lt net \*  : List only network modules
    /sbin/modprobe -t net \*   : Try loading all network modules and see.



Find architecture of Linux server OS

We can use below commands to check the architecture of server OS,


1. #getconf LONG_BIT

2.#uname -a

3.#grep flags /proc/cpuinfo

4.#arch

5.#file /bin or file bc




Blogger Tips and TricksLatest Tips And TricksBlogger Tricks