Pages

Monday, July 24, 2017

Quick Reference

1) How to find WWN number of HBA

# cat /sys/class/fc_host/host*/node_name
# cat /sys/class/scsi_host/host*/device/fc_host/host*/node_name
# systool -c scsi_host -v

2) How to scan LUN in the server

For FC Host

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

Above command performs a Loop Initialization Protocol (LIP) and then scans the interconnect and causes the SCSI layer to be updated to reflect the devices currently on the bus. A LIP is, essentially, a bus reset,  and will cause device addition and removal. This procedure is necessary to configure a new SCSI target on a Fibre Channel interconnect. Bear in mind that issue_lip is an asynchronous operation.

The command may complete before the entire scan has completed. You must monitor /var/log/messages to determine when it is done. 

For SCSI Host

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

It means that you are echoing a wildcard value of "Channel, Target and Lun" (CTL), and the operating system will rescan the device path.

3) How to check the correct swapiness value

To check the swappiness value

# cat /proc/sys/vm/swappiness

swappiness=0 tells the kernel to avoid swapping processes out of physical memory for as long as possible


swappiness=100 tells the kernel to aggressively swap processes out of physical memory and move them to swap cache

Default = 60




4) How to check which services use TCP Wrappers


TCP wrappers is used by the services which use libwrap.so module.

To check whether the program is using libwrap or not use below command.


# ldd /usr/sbin/rpc.mountd | grep -i libwrap.so
        libwrap.so.0 => /lib64/libwrap.so.0 (0x00007f6b7c731000) 



5) How to check check NFS version from client

a) From Client : nfsstat -m


b) From server we can use: mount -v &  nfsstat -m


6) How to enable SFTP


subsystem sftp /usr/lib/openssh/sftpserver


7) cp and mv


cp - new inode number will be created. So source and destination will have difference INODE number.


mv - Only file name will get change there won't be any change in the inode number.number.


8) How to enable disable arp

To supress ARP on interface eth0 run the following command as root:
# ip link set dev eth0 arp off

To turn it back on again:
# ip link set dev eth0 arp on

9) How to check the I/O statistics of block devices



Below two file displays the I/O statistics of block devices.

# /proc/diskstats 

# cat /sys/block/<dev>/stat

10) Dirname & Basename command's


dirname <Comple path of file> - Will display the complete folder path without filename. 
dirname <Comple path of file> - Will display the file name only without folder path.

11) What are the components responsible in Linux for Hot plugging device detection.



Hotplugging is achieved in Linux by a combination of three components: Udev, HAL, and Dbus

12) Run multiple commands with Sudo



sudo sh -c 'command1 && command2'
sudo -- sh -c 'command1 && command2'
sudo -u userNameHere -- sh -c 'command1; command2'
sudo -- sh -c 'command1; command2'
sudo -- bash -c 'command1; command2'
sudo -i -- 'command1; command2; command3'
sudo -i -- sh -c 'command1 && command2 && command3'

13) What are by-uuid, by-id and by-path folders

by-UUID

UUID is a mechanism to give each filesystem a unique identifier. These identifiers are generated by filesystem utilities (e.g. mkfs.*) When the partition gets formatted and are designed so that collisions are unlikely. FAT and NTFS filesystems (fat and windows labels above) do not support UUID, but are still listed in /dev/disk/by-uuid with a shorter UID 


by-id and by-path


by-id creates a unique name depending on the hardware serial number, 
by-path depending on the shortest physical path (according to sysfs).

14) How to Assign IP in dhcp based on MAC



host blah {
    hardware ethernet <mac address>;
    fixed-address <ip address>;

}

15) Rename Ethernet device name in Linux


Linux Rename Eth0 Network Interface Card Name [ Udev ]


Step #1: Find out the MAC address of the Ethernet device


Note down the MAC address.


Step #2: Rename eth0 as wan0


To rename eth0 as wan0, edit a file called 70-persistent-net.rules in /etc/udev/rules.d/ directory, enter:


# vi /etc/udev/rules.d/70-persistent-net.rules



The names of the Ethernet devices are listed in this file as follows:

16) To Get list of file names in FTP to Local



ftp> dir -Rl <filename>  - Will transfer the list of files recursively to <filename> to local folder

No comments:

Post a Comment