April 8

Linux: Using grep

Word count
grep -o ‘word’ filename | wc -l

One liner to find a running process and kill it
kill $(ps aux |grep -i ‘[/]usr/bin/puppet’ | awk ‘{print $2}’)

Find duplicate words in a file
grep -wo ‘[[:alnum:][:punct:]]+’ filename.txt | sort | uniq -cd

  • You may need to vary the “bracket expressions”, to fit the characters you are tryin go match.
    The above worked well when looking to find more than one server that is using the FQDN.

Search filesystem for a word:
find / -xdev -type f -print0 | xargs -0 grep -H “wordtosearchfor”

Category: Linux | Comments Off on Linux: Using grep
July 17

Linux: Fedora – Enterprise login user cannot obtain sudo or root

This happened specifically with Fedora 28, but may apply to other versions.

Summary:
Open a shell in initrd, mount /sysroot as read-write and edit /sysroot/etc/group

Steps:
1. Reboot
2. In grub press “e” to edit the menu entry
3. Search for a line that starts either with linux16 or linuxefi and append the string ” rd.break”
4. Press ctrl+x
5. Mount the /sysroot as read-write: mount -oremount,rw /sysroot
6. Open /sysroot/etc/group in a text editor
7. search for the line “wheel:x:10:” and append your user
8. You may run into selinux issues, so either set it to permissive (edit /sysroot/etc/selinux/config) or touch /sysroot/.autorelabel
9. reboot again
10. If in step 8 you set selinux to permissive, restorecon /etc/group and reset selinux back to enforcing and reboot again.

Category: Linux | Comments Off on Linux: Fedora – Enterprise login user cannot obtain sudo or root
July 17

Linux: NIC Bonding Examples

The following example creates to Bonds.
Bond0 is Active-Backup
Bond1 uses VLAN tagging and LACP

Kernel setup:
modprobe kernel configuration
/etc/modprobe.d/bonding1.conf
alias netdev-bond1 bonding
options bond1 miimon=100 mode=4 lacp_rate=1

Bond0:

ifcfg-bond0

DEVICE=bond0
IPADDR=172.16.0.3
NETMASK=255.255.255.0
NETWORK=172.16.0.0
BROADCAST=172.16.0.255
ONBOOT=yes
BOOTPROTO=none
TYPE=Bond
BONDING_MASTER=yes
PREFIX=24
DEFROUTE=yes
NAME=”Bond bond0″
BONDING_OPTS=”mode=active-backup miimon=0 arp_ip_target=172.16.0.1 arp_interval=1000″
LAST_CONNECT=1530826407
NM_CONTROLLED=no

ifcfg-bond0_slave_1

DEVICE=em1
TYPE=Ethernet
NAME=”System em1″
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

ifcfg-bond0_slave_2

DEVICE=em2
TYPE=Ethernet
NAME=”System em2″
ONBOOT=yes
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no

Bond1:

ifcfg-bond1

DEVICE=bond1
TYPE=Bond
BONDING_MASTER=yes
NAME=bond1
ONBOOT=yes
BONDING_OPTS=”mode=4 miimon=100″
NM_CONTROLLED=no

ifcfg-bond1.15

VLAN=yes
TYPE=Vlan
DEVICE=bond1.15
VLAN_ID=15
BOOTPROTO=none
IPADDR=10.254.15.44
NETMASK=255.255.255.0
GATEWAY=10.254.15.1
DNS1=10.254.5.11
DNS2=10.254.5.12
DEFROUTE=yes
NAME=bond1.15
ONPARENT=yes
LAST_CONNECT=1530810269
NM_CONTROLLED=no

ifcfg-bond1_slave_1

DEVICE=p2p2
TYPE=Ethernet
NAME=bond1_slave_1
ONBOOT=yes
MASTER=bond1
SLAVE=yes
NM_CONTROLLED=no

ifcfg-bond1_slave_2

DEVICE=p3p2
TYPE=Ethernet
NAME=bond1_slave_2
ONBOOT=yes
MASTER=bond1
SLAVE=yes
NM_CONTROLLED=no

Category: Linux | Comments Off on Linux: NIC Bonding Examples
July 17

Linux: Finding HBAs driver version and wwpn

Pull Driver Version:
# modinfo qla2xxx | grep version
version: 9.00.00.00.40.0-k1
srcversion: 67989F13670BACC60C8CA47
vermagic: 4.1.12-124.17.1.el6uek.x86_64 SMP mod_unload modversions

Pull WWPN:
# more /sys/class/fc_host/host?/port_name
::::::::::::::
/sys/class/fc_host/host1/port_name
::::::::::::::
0x2001000e1e024d24
::::::::::::::
/sys/class/fc_host/host2/port_name
::::::::::::::
0x2001000e1e024d7d

Category: Linux | Comments Off on Linux: Finding HBAs driver version and wwpn
May 19

Linux: Raspberry PI – Chromium didn’t shut down correctly – How to fix

When using Chromium as a Kiosk it will not shutdown properly on reboot.  As a result it throws an error every time it restarts.

Here is my fix(This assumes you are using pi as your auto login user):
1. mkdir /home/pi/scripts
2. nano /home/pi/scripts/chromiumcleanup
3. Add the following:
#!/bin/bash
/bin/sed -i ‘s/”exit_type”:”Crashed”/”exit_type”:”Normal”/’ ~/.config/chromium/Default/Preferences
4. ctrl X and Y
5. chmod 755  /home/pi/scripts/chromiumcleanup
6. crontab -e
7. Add the following: @reboot /home/pi/scripts/chromiumcleaner
Make certain to put a new line after the above.  crontab requires an empty line for an EOF.

Reboot and everything should work.

By: Timothy Jay Conrad  (sed command taken from S. Kemp)

Category: Linux | Comments Off on Linux: Raspberry PI – Chromium didn’t shut down correctly – How to fix