Chef

Delete a Node from Chef

knife node delete <nodename>
knife client delete <nodename>

Linux

Debugging Bash Scripts

#! /bin/bash -x
  • outputs everything from the script
  • set -x to enable debugging at a certain spot and set +x to the end

Clear ZSH history

  1. Open .zsh_history
  2. Delete the lines you want removed and save the file
  3. Restart your terminal

Useful Commands

Force a Password Change

chage -d 0 <user>

Redhat/CentOS/Oracle Linux Version

cat /etc/redhat-release
cat /etc/oracle-release

Get All Installed Linux Kernels

uname -a

Get VM Serial Number

sudo dmidecode -t system | grep Serial

Force Reboot Host

systemd hosts that aren't responding

sudo systemctl --force --force reboot

Run logrotate Manually

/usr/sbin/logrotate /etc/logrotate.conf

Check for RedHat Packages

rpm -qa --queryformat="%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH} - %{VENDOR}\n" | grep "Red Hat"

Swap

Disable Swap

swapoff

Enable Swap

swapon

Logical Volume Management

Creating a Filesystem (XFS)

lvcreate  -L <size> <LVname> <VG>
mkfs.xfs <path_to_LV>
mkdir -p <mount_point_location>
cp -p /etc/fstab /etc/fstab_<mount_point>
echo "<filesystem_path> <location_of_mount_point> xfs defaults,nofail 0 0" >> /etc/fstab
systemctl daemon-reload
mount <filesystem_mount_point>

Expanding a Filesystem

XFS

  1. Extend the logical volume
lvextend -L +<size_to_add> <logical_volume>
lvextend -L <expected_size> <logical_volume>
  1. Resize filesystem to fill logical volume
xfs_growfs <mount_point>

EXT

lvextend -L +<size_to_add> <logical_volume>
lvextend -L <expected_size> <logical_volume>

Repair XFS Filesystem

  1. Unmount Filesystem
umount <fs_mount_point>
  1. Run XFS_repair
xfs_repair <full_path_of_logical_volume>

Physical Volume

Create a volume

pvcreate <device_name>

Volume Groups

VGCreate

vgcreate -cn <vgname> <disk_path> <disk_path...>

VGExtend

vgextend <device_name_of_VG> <device_name_of_PV>

VGReduce

vgreduce <device_name_of_VG> <device_name_of_PV>

Logical Volumes

LVCreate

Option 1

lvcreate -L <size> -n <name_of_LV> <VG_name>

Option 2

lvcreate -l <number_of_extents> -n <name_of_LV> <VG_name>

LVExtend

lvextend -L +<size_to_add> <logical_volume>
lvextend -L <expected_size> <logical_volume>

LVRemove

lvremove <LS_path>

LDAP

Delete from ldap

ldapdelete -x -h <domain_controller> 'CN=<SERVER>,OU=<OU1>,OU=<OU2>,DC=example,DC=com' -D '<user_account> -w <user_password>

Net ADs Commands

Join

netads join -U 'user_account%password'

Leave

netads leave -U 'user_account%password'

Keytab Count

klist -t -k /etc/krb5.keytab | wc -l

Find Large files

find <dir> -xdev -type f -size 40000 -exec ls -hl {} \; | sort -n -k 5

New Relic

New Relic

Average duration nrql

SELECT average(duration) FROM Transaction WHERE <params> Since 1 week ago TIMESERIES 1 hour FACET <param>

99th Percentile

SELECT percentile(duration,99) FROM Transaction WHERE <params> Since 1 week ago TIMESERIES 1 hour FACET <param>

Traffic Levels

SELECT count(*) FROM Transaction WHERE <params> Since 1 week ago TIMESERIES 1 hour FACET <param>

Percent of Errors (eg 500s)

SELECT percentage(count(*), WHERE httpResponseCode LIKE '5%%') FROM Transaction  SINCE 1 hour ago TIMESERIES FACET name