Anda di halaman 1dari 6

###Linux Commands###

All
===

>stat -c 'major: %t minor: %T' <device> -> Lists device major and
minor numebres {ex: stat -c 'major: %t minor: %T' /dev/sda}
>who �b -> last reboot time
>dmsetup -> device mapper setup utility
>wget <http_link> -> download some file from web (ex:
http://build-squid.eng.vmware.com/build/VMware-VSAClusterService-5.5.1.0-1568942-
linux.zip)
>ldd <program_name> -> print shared library
dependencies (ex: ldd /bin/bash)
>pkg-config --libs --cflags <lib_name> -> Checking the lib
configurations ex: pkg-config --libs --cflags vix-disklib
>file <file_name> -> shows ifnormation about a binary
>cat ~/.bashrc -> append permanent environment
variables exports in last line... ex{ echo 'export $TEST=$TEST:/usr/test' >>
~/.bashrc }
>ulimit -a -> Check core file size (core file size)
>ulimit -c unlimited -> to set core file size to
unlimited
>gdb <executable> <core_file_name) -> to analyze core file in linux
(ex: gdb sample core.31728)
>find <dir> -executable -type f -> find all executable files
in linux
>strings <file_name> -> To check detaisl about librrary
and etc... <ex: strings libssl.so >
>wall <message> -> send a message to everybody�s
terminal

>nfs share export sample command


>echo '/testdir *(rw,sync,no_root_squash)' >> /etc/exports
> service rpcbind start; service nfs start

>sync -> Synchronizing I/O - A call to this


function will not return as long as there is data which has not been written to the
device.
>cscope -R -> search a function/variable in code
>mkfs -t ext4 -E lazy_itable_init=1 /dev/sdb1 -> quick format in linux
>rm /etc/udev/rules.d/70-persistent-net.rules -> remove 70-persistent-
net.rules file makse cloned VM to get IP whiel booting and create eth1 aswell
>hostnamectl -> Get hostname in REHL7

Pipe
----

>ls | grep -v 201710 | xargs rm -rf -> Delete all files which
does not ahve string "201710"

Regular Expression
------------------

>du -sh results/* | grep -E "^[5-9][0-9](M|\.[0-9]M)" -> list only files


greater than 50M & less than 100M
awk/sed
-------

>grep datacenter servers.txt | awk '$3 > 20 {print ;}' | more (ex: this will
check for 3rd value in each line "b_datacenter, servers 21")
>ls -l | grep -Eo "h[0-9].*[0-9]+\.vmdk" | awk '{system("vmkfstools -U "$1)}'
=> list all vmdk files and delete it

>cat results.log | grep RESULT | grep SKIP | grep -Eo "vmfs.*.test" | sed
's/.test/.log/g' |awk 'print $1;system("grep -A 1 ERROR " $1);print "\n"}' -> Grep
ERROR in eacg test NG testcase log file

>sed -i 's/thiru/arasu/g' test.txt => Replace string in a file inplace

btrfs
------

>mkfs.btrfs /dev/sdb1
>mount /dev/sdb1 /testdir
>cd /testdir
>touch bigfile1
>truncate -s 3T bigfile1
>btrfs filesystem show

IO Generation:
==============

Below will increase CPU load


>for i in `seq 64`; do perl -e '$z=time()+(10*60); while (time()<$z) { $j++; $sqrt
= sqrt($j) for (1..9999); }' & done

>memhog -r100 4g -> simulates memory consumption by 4GB and run for
100 iterations

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

Block/SCSI
==========

Target side
------------

>tgtadm -> Linux SCSI Target Administration Utility

Initiator sie
-------------

>lsscsi -> Lists all scsi devices (lsscsi -h -> for more info)
>lsblk -> Lists all block devices (lsblk -h -> for more info)
>iscsiadm -> open-iscsi administration utility
>echo 1 > /sys/bus/scsi/devices/H:B:T:L/delete -> make a SCSI disk disappear
with a 2.6 kernel
>cat /sys/bus/scsi/devices/H:B:T:L/timeout -> see disk timeout
>find /sys/class/scsi_generic/*/device/timeout -exec grep -H . '{}' \;
--> cmd to find guest OS disk timeout
>rescan-scsi-bus.sh -> rescan scsi bus
Linux Rescan - adding a new disc

First find your host bus number -> grep mpt


/sys/class/scsi_host/host?/proc_name

Which should return a line like


"/sys/class/scsi_host/host0/proc_name:mptspi", use this to rescan the bus with the
following command

>echo "- - -" > /sys/class/scsi_host/host0/scan

Linux Rescan - when expanding an existing disc

>echo 1 > /sys/class/scsi_device/device/rescan

>dd if=/dev/sda bs=512 count=63 | hexdump -C -> Display disk contents


using dd
>cat /sys/block/sda/queue/scheduler -> Displays the list of
schedulers and default disk scheduler with []
>sg_inq -e -p 0xb0 /dev/sdb -> Issue SCSI INQUIRY for Page
"B0"
>sg_inq -e -p 0x00 /dev/sdb -> List all the VPD pages supported
by the device
>sg_readcap -l /dev/sdb -> Issues SCSI Read Capacity (16)
(Output attributes lbpme=0, lbprz=0 represents Thin is supported and default read
value)
>sg_vpd -p 0xb2 /dev/sdb -> Thin provisioning related information

[root@vm-rhel7u1-x64 ~]# sg_readcap -l /dev/sda


Read Capacity results:
Protection: prot_en=0, p_type=0, p_i_exponent=0
Logical block provisioning: lbpme=0, lbprz=0
Last logical block address=33554431 (0x1ffffff), Number of logical
blocks=33554432
Logical block length=512 bytes
Logical blocks per physical block exponent=0
Lowest aligned logical block address=0

[root@vm-rhel7u1-x64 ~]# sg_inq -e -p 0xb0 /dev/sda


VPD INQUIRY: Block limits page (SBC)

Maximum compare and write length: 0 blocks


Optimal transfer length granularity: 0 blocks
Maximum transfer length: 0 blocks
Optimal transfer length: 0 blocks
Maximum prefetch, xdread, xdwrite transfer length: 0 blocks
Maximum unmap LBA count: 65536
Maximum unmap block descriptor count: 64
Optimal unmap granularity: 2048
Unmap granularity alignment valid: 1
Unmap granularity alignment: 0

[root@vm-rhel7u1-x64 ~]# sg_vpd -p 0xb2 /dev/sdb


Logical block provisioning VPD page (SBC):
Unmap command supported (LBPU): 1
Write same (16) with unmap bit supported (LBWS): 1
Write same (10) with unmap bit supported (LBWS10): 0
Logical block provisioning read zeros (LBPRZ): 0
Anchored LBAs supported (ANC_SUP): 0
Threshold exponent: 0
Descriptor present (DP): 0
Provisioning type: 0

RHEL iSCSI Target Configuration (targetcli):


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

Ref: https://www.certdepot.net/rhel7-configure-iscsi-target-initiator-persistently/

1) yum install -y targetcli


2) systemctl enable target
3) Run cmd "targetcli" if fails with python Error "ImportError: cannot import name
range" than upgarde python-six pakgae
> yum update -y python-six

5) Open targetcli command prompt

4) Map some raw device (/dev/sdb or lvm volume)

/> backstores/block/ create block1 /dev/sdb

5) Create iSCSI Target name like below

/>iscsi/ create iqn.2014-08.com.example:t1

6) Perform "ls" command to check created LUn and target properties

7) cd to created target "/iscsi/iqn.20...ample:t1/tpg1" and create LUN


/> cd iscsi/iqn.2014-08.com.example:t1/tpg1/
/>luns/ create /backstores/block/block1

8) Provide permission to initiatores (ex: 'iqn.1998-01.com.vmware:w2-stio-dc-esx-


58-swiscsi' ) using ACL.

/iscsi/iqn.20...ample:t1/tpg1> acls/ create iqn.1998-01.com.vmware:w2-stio-dc-esx-


58-swiscsi

9) exit and stop firewall if it is running

10) From initiator, connect to this iscsi target IP. LUNs will be visible

To Change any backing device specific params

a) First delete LUN

>targetcli /iscsi/iqn.20...:t1/tpg1/luns> delete 0

b) Change backing device attributes


>targetcli /backstores/block/block1 set attribute fabric_max_sectors=64
>targetcli /backstores/block/block1 set attribute optimal_sectors=64

c) Create LUN
>targetcli /iscsi/iqn.20...:t1/tpg1/luns> create /backstores/block/block1

d) Check Params

>targetcli /backstores/block/block1 get attribute fabric_max_sectors

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

Kernel
======

>cat /proc/cmdline -> Reports the parameters passed to the kernel at boot.

NFS
---
>exportfs -o rw,no_root_squash 10.112.71.0/255.255.252.0:/testdir1 exporting a
dir using command

YUM Local Repo


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

1. mount CD to /mnt
2. create file /etc/yum.repos.d/rhel-local.repo and add below contents
----

[rhel6.3-local]
name=RHEL 6.1 local repository
baseurl=file:///mnt/
gpgcheck=0
enabled=1

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

SLES specific
-------------

>/etc/init.d/SuSEfirewall2_setup <start/stop> -> Enable/Disable


firewall in SLES
>/sbin/SuSEfirewall2 off -> Disable firewall
permanently

Anda mungkin juga menyukai