Wednesday, May 18, 2016

lsblk - best tool for auditing LVM (make graph of VG/PV)

# lsblk

NAME                            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda                               8:0    1 819,7G  0 disk
|-sda1                            8:1    1   243M  0 part /boot
|-sda2                            8:2    1     1K  0 part
`-sda5                            8:5    1 819,5G  0 part
  |-server--vg-root             252:0    0   8,4G  0 lvm  /
  |-server--vg-swap_1           252:1    0    10G  0 lvm
  |-server--vg-var              252:2    0   2,8G  0 lvm  /var

Command to make sudo not to ask for password (bash one-liner)

By default Ubuntu users forced to type password every time when they perform root operations.
You can use this snippet to avoid it:

sed -i "/^%admin/ {/NOPASSWD/! s/ALL$/NOPASSWD:ALL/}" /etc/sudoers
sed -i "/^%sudo/ {/NOPASSWD/! s/ALL$/NOPASSWD:ALL/}" /etc/sudoers


Here is how to read it:
* find only strings that start with %admin
* skip them if they already contain NOPASSWD
(so you can safely run this script many times)
* substitute last(on the line) matching of word "ALL" with NOPASSWD:ALL