Sudo password fails even though it is correct [Fedora]

Newer fedora distros keep track of authentication failure attempts.

This may prevent sudo from working even though the password is correct!

In this example, I verified my user ‘ben’ is in /etc/sudoers

# grep ben /etc/sudoers
ben     ALL=(ALL)       ALL


Yet when I performed a simple operation the password was not accepted

# su - ben
[ben@bedora37]$ 
[ben@bedora37]$ sudo bash -c ls
[sudo] password for ben:
Sorry, try again.
[sudo] password for ben:
Sorry, try again.

I could verify the password I am using is correct by performing an SSH to localhost

# ssh ben@localhost
password
#

The problem in this case was that I needed to reset the failure lock

# faillock
ben:
When                Type  Source                                           Valid
2023-04-15 16:33:01 TTY   /dev/pts/1                                           V
2023-04-15 16:33:10 TTY   /dev/pts/1                                           V
2023-04-15 16:33:20 TTY   /dev/pts/1                                           V
root:
When                Type  Source                                           Valid

I reset via

# faillock --user ben --reset
#

Now my simple ls works

# su - ben
[ben@bedora37]$ 
[ben@bedora37]$ sudo bash -c ls
[sudo] password for ben:
Desktop  Documents  Downloads  logs  Music  Pictures  Public  snap Videos
[ben@bedora37]$ 
Posted in Linux | Leave a comment

Obtain list of all physical hard drives (SSD, NVMe, VDA, HDD)

I came across an issue recently whereby I had a need to display all physical hard drives on a system whether it be HDD, VHD, or SSD (NVMe) drives that were above a certain size, excluding any USB or CD-ROM/DVD drives.

In the following example I needed to obtain the first drive that was larger than 50GB

#!/bin/bash
DIR=/sys/block
MINSIZE=50                  #Min size of drive in GB to look for
declare drive_type
drive_type=( "nvme" "sd" "hd" "vd" )
for t in ${drive_type[@]}; do
        if [ $(ls $DIR/|grep -q "^$t";echo $?) == 0 ]; then
                for d in $DIR/${t}*; do
                  DEV=`basename "$d"`
                  if [[ (  -d $DIR/$DEV  ||  -L $DIR/$DEV )  &&   ( $(cat $DIR/$DEV/removable) == 0 ) ]]; then
                    if [ -f $DIR/$DEV/size ]; then
                        GB=$((`cat $DIR/$DEV/size`/2**21))
                        if [ $GB -gt $MINSIZE ]; then
                                echo "Disk device $DEV has size $GB GB"
                                break 2
                        fi
                    fi
                  fi
                done
        fi
done

Example

$ bash drivesize.sh
Disk device nvme0n1 has size 1788 GB

Another variation is if I wanted to list all physical drives and their sizes I can modify the above to simplify:

#!/bin/bash
DIR=/sys/block
declare drive_type
drive_type=( "nvme" "sd" "hd" "vd" )
for t in ${drive_type[@]}; do
        if [ $(ls $DIR/|grep -q "^$t";echo $?) == 0 ]; then
                for d in $DIR/${t}*; do
                  DEV=`basename "$d"`
                  if [[ (  -d $DIR/$DEV  ||  -L $DIR/$DEV )  &&   ( $(cat $DIR/$DEV/removable) == 0 ) ]]; then
                    if [ -f $DIR/$DEV/size ]; then
                        GB=$((`cat $DIR/$DEV/size`/2**21))
                        echo "Disk device $DEV has size $GB GB"
                    fi
                  fi
                done
        fi
done

Example

$ bash drivesize_all.sh
Disk device nvme0n1 has size 1788 GB
Disk device nvme10n1 has size 1788 GB
Disk device nvme11n1 has size 1788 GB
Disk device nvme12n1 has size 1788 GB
Disk device nvme13n1 has size 1788 GB
Disk device nvme14n1 has size 1788 GB
Disk device nvme15n1 has size 1788 GB
Disk device nvme16n1 has size 1788 GB
Disk device nvme17n1 has size 1788 GB
Disk device nvme18n1 has size 1788 GB
Disk device nvme19n1 has size 1788 GB
Disk device nvme1n1 has size 1788 GB
Disk device nvme20n1 has size 1788 GB
Disk device nvme21n1 has size 1788 GB
Disk device nvme22n1 has size 1788 GB
Disk device nvme23n1 has size 1788 GB
Disk device nvme2n1 has size 1788 GB
Disk device nvme3n1 has size 1788 GB
Disk device nvme4n1 has size 1788 GB
Disk device nvme5n1 has size 1788 GB
Disk device nvme6n1 has size 1788 GB
Disk device nvme7n1 has size 1788 GB
Disk device nvme8n1 has size 1788 GB
Disk device nvme9n1 has size 1788 GB
Disk device sda has size 894 GB
Disk device sdb has size 894 GB

Posted in Linux | Leave a comment

iterm2 adds line break when copying text

I had an issue that drove me crazy for weeks.

When I would highlight text in iterm2 to copy it, upon pasting it would always add a carriage return (line-break) at the end of the line. Thus the line that I copied would not be contiguous.

This is extremely annoying when attempting to copy log file contents.

The solution was simpler and somewhat counter intuitive.

In iterm2 there is an option under Preferences –> General –> Selection

Check “Copied text includes trailing newline”

Posted in MAC-OSX | Tagged , , , , , | Leave a comment

Double click select entire word in terminal (iterm2) on MAC OSX

I have had issues when using Remote Desktop Manager Free (RDM) for MAC OSX.

Firstly ensure that you have iterm2 selected as the terminal

Next you want to be sure you are using the Legacy Engine set to NO under

Preferences > Types > Terminal:

I filed a bug with Devolutions and here is the reference link: https://forum.devolutions.net/topics/35957/doubleclick-select-in-terminal

Posted in MAC-OSX | Tagged , , , , , , , | Leave a comment

Determine the Active Network Interface and IP address from Terminal on a MAC

On a MAC (OSX) Using the command line (Terminal) often you want a quick way to determine the Active Network Interfaces along with the IP address.

Here is a quick ‘alias’ you can make to get the IP(s)

# scutil --nwi|awk 'BEGIN {s=0} $0 ~ /^IPv4/ {s=1;next} s==1 && $0 ~ /flags/ {intf=$1;next} s==1 && $1 ~ /address/ {ip=$NF; print intf,ip} $1 ~ /REACH/{exit}'

Example Output

# scutil --nwi|awk 'BEGIN {s=0} $0 ~ /^IPv4/ {s=1;next} s==1 && $0 ~ /flags/ {intf=$1;next} s==1 && $1 ~ /address/ {ip=$NF; print intf,ip} $1 ~ /REACH/{exit}'
en9 192.168.1.88

Creating a small bash script in /usr/local/bin/ so you can reference it anytime.

#!/bin/bash
# scutil --nwi|awk 'BEGIN {s=0} $0 ~ /^IPv4/ {s=1;next} s==1 && $0 ~ /flags/ {intf=$1;next} s==1 && $1 ~ /address/ {ip=$NF; print intf,ip} $1 ~ /REACH/{exit}'

If you wish to only view the active interfaces on MAC OS you can do the following and create an alias for it

#ifconfig | pcregrep -M -o '^[^\t:]+(?=:([^\n]|\n\t)*status: active)'

Example Output

# ifconfig | pcregrep -M -o '^[^\t:]+(?=:([^\n]|\n\t)*status: active)'
en9
en6
Posted in MAC-OSX | Leave a comment

Chrome: Your connection is not private. NT::ERR_CERT_INVALID

PROBLEM

Unable to view or access website because Chrome Shows

(Your connection is not private. NT::ERR_CERT_INVALID)

SOLUTION

  1. Go to URL
  2. Wait until you see the ERR_CERT_INVALID message appears
  3. Click anywhere on the page
  4. type the word “thisisunsafe”

Boom Baby!

Posted in Google Chrome | Tagged , , , | Leave a comment

Intel SP2600TP Board Boots at Bios Screen to error 26 in lower right corner

PROBLEM

It was seen recently on a T7000 whereby an Intel S2600TP system that boots and the only thing on the screen is the following with the number 26 in the lower right corner.

Text on the screen reads as:

Board Name S2600TP
Chipset initialization complete. No errors found.
26 (lower right hand corner).

CAUSE

I filed case 00556496 with Intel and the results were as follows:

POST code 26 indicates it may hang on to the Memory Reference Phrase (MRC) phase as MRC training is a failure. In this scenario, we recommend changing other DIMMs or boards.

SOLUTION

Replace the Memory, or since if Memory is not FRU, replace the controller.

ADDITIONAL INFORMATION

For additional information on other codes, see: S2600TP Intel Troubleshooting Guide

Posted in Data Storage, Network Attached Storage (NAS) | Leave a comment

Obtain and setting the BMC date and time using ipmitool

There are times when viewing the ipmi logs via the following command, the date and time is incorrect.

# ipmitool sel elist last 20
 2b7 | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2b8 | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2b9 | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2ba | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2bb | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2bc | 07/26/2022 | 13:53:16 | Critical Interrupt | Bus Correctable error | Asserted
 2bd | 07/26/2022 | 13:53:16 | Power Supply PSU1_STATUS | Power Supply AC lost | Asserted
 2be | 07/26/2022 | 13:53:16 | Power Supply PSU1_STATUS |  | Deasserted
 2bf | 07/26/2022 | 22:19:23 | System ACPI Power State ACPI_PWR_STATE | Legacy ON state | Asserted
 2c0 | 07/26/2022 | 22:19:23 | Processor CPU0_PRESENT | Presence detected | Asserted
 2c1 | 07/26/2022 | 22:19:23 | Processor CPU1_PRESENT | Presence detected | Asserted
 2c2 | 07/26/2022 | 22:19:58 | Power Supply PSU0_STATUS | Presence detected | Asserted
 2c3 | 07/26/2022 | 22:19:58 | Power Supply PSU0_STATUS |  | Asserted
 2c4 | 07/26/2022 | 22:19:58 | Power Supply PSU1_STATUS | Presence detected | Asserted
 2c5 | 07/26/2022 | 22:19:58 | Power Supply PSU1_STATUS |  | Asserted
 2c6 | 07/26/2022 | 22:19:59 | System ACPI Power State ACPI_PWR_STATE | Legacy ON state | Asserted
 2c7 | 07/26/2022 | 22:19:59 | Processor CPU0_PRESENT | Presence detected | Asserted
 2c8 | 07/26/2022 | 22:19:59 | Processor CPU1_PRESENT | Presence detected | Asserted

To obtain current BMC time according to the BMC

# ipmitool sel time get
08/16/2022 00:25:06

Dynamically change the BMC time

# ipmitool sel time set "$(date '+%m/%d/%Y %H:%M:%S')"
08/15/2022 18:27:41

Verify the new settings:

# ipmitool sel time get
08/15/2022 18:28:04
Posted in Data Storage, IPMI | Tagged , | Leave a comment

Mapping MAC Numeric Keyboard on VMware Console using Karabiner Elements

I regular problem of mine was launching the VMware remote console on my MAC, and being unable to use the Numeric Keypad.

I used Karabiner Elements to create my own custom rules that allow me to do this.

First step is to install Karabiner Elements

Next, I prefer to use terminal, and navigate to ~/.config/karabiner/assets/complex_modifications

Inside that folder I vi filename ben-vmware-keyboard-mapping

*note, I only prefix my name on the filename so that I know it is my custom rule in Karabiner. It is completely optional!

Next, I paste the following into the file.

{
  "title": "Map Keypad when using VMWare Console",
  "rules": [
      {
      "description": "BEN: VMware Console Use Keypad 0 key as 0",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_0"
           },
          "to": [
            {
            "key_code": "0"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 1 key as 1",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_1"
           },
          "to": [
            {
            "key_code": "1"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 2 key as 2",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_2"
           },
          "to": [
            {
            "key_code": "2"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 3 key as 3",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_3"
           },
          "to": [
            {
            "key_code": "3"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 4 key as 4",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_4"
           },
          "to": [
            {
            "key_code": "4"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 5 key as 5",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_5"
           },
          "to": [
            {
            "key_code": "5"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 6 key as 6",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_6"
           },
          "to": [
            {
            "key_code": "6"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 7 key as 7",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_7"
           },
          "to": [
            {
            "key_code": "7"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 8 key as 8",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_8"
           },
          "to": [
            {
            "key_code": "8"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad 9 key as 9",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_9"
           },
          "to": [
            {
            "key_code": "9"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad = key as =",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_equal_sign"
           },
          "to": [
            {
            "key_code": "equal_sign"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad / key as /",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_slash"
           },
          "to": [
            {
            "key_code": "slash"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad * key as *",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_asterisk"
           },
          "to": [
            {
            "key_code": "asterisk"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad - key as -",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_hyphen"
           },
          "to": [
            {
            "key_code": "hyphen"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad + key as +",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_plus"
           },
          "to": [
            {
            "key_code": "plus"
            }
           ],
           "type": "basic"
        }
       ]
    },
    {
      "description": "BEN: VMware Console Use Keypad ENTER key as ENTER",
      "manipulators": [
        {
          "conditions": [
            {
              "bundle_identifiers": [
                "^com\\.vmware\\.vmrc$",
                "^com\\.apple\\.Terminal$",
                "^com\\.googlecode\\.iterm2$"
              ],
              "type": "frontmost_application_if"
            }
           ],
          "from": {
              "key_code": "keypad_return_or_enter"
           },
          "to": [
            {
            "key_code": "return_or_enter"
            }
           ],
           "type": "basic"
        }
       ]
    }

  ]
}

Next I open Karabiner Elements.

Next I click on Complex Modifications and click on Add Rule

Scroll down and look for the “Map Keypad when using VMWare Console” Section.

To add them all, scroll down and you will see an Enable All button!

Now you will see them enabled on the next screen

Now when I open the Remote Console I am able to use the numeric keypad !!

Posted in Remote Console, VMWare | Leave a comment

Using AWK to print N lines up until the FIRST MATCH of a string and then exit

Often you are looking for a keyword within a log file but you need to print out X lines BEFORE the first match of a string, THEN exit the search.

There are many ways to skin a cat, and here are a few ways.

EXAMPLE 1:

In the following I am looking for 7 lines BEFORE the keyword phrase ‘Rolling back’

# cat logfile  | awk   'BEGIN{stopline=7} NR==1,/Rolling back/ {n=NR;l[n]=$0}END{last=n-stopline;for (i=last;i<=n;i++) {print l[i]}}'

Output:

2022-06-11 16:56:26 [pid 39154] LOG-THRIFTCLIENT-0002: [1] [tid 39154] Thrift transport exception type #1 (socket open() error: No route to host); failed to establish connection [addr=tt-peer-controller./port=9090].
Command killed: (signal 14) /usr/tintri/bin/fscmd -a 60 -h 'tt-peer-controller.' get-tuning-variable 'stasisDegradedModeTruncationTimeout'
Can't get 'stasisDegradedModeTruncationTimeout', error 142
Can't get timeouts, error 142
Upgrade completed; exit code 109
2022-06-11T16:57:22.166513-07:00 la-tintri01#b upgrade_pkg[30360]: Script /etc/sysconfig/tintri/post_upd/90-upgrade_fs exit code: 109
2022-06-11T16:57:22.167052-07:00 la-tintri01#b upgrade_pkg[30360]: Can not perform application upgrade, error 109
2022-06-11T16:57:22.167467-07:00 la-tintri01#b upgrade_pkg[30360]: Rolling back, state 9

EXAMPLE 2:

An easier way is to chain with tail; but who in the Linux world wants to do things the easy way right!?!?

#zcat logfile |awk 'NR==1,/Rolling back/' |tail -7

OUTPUT

2022-06-11 16:56:26 [pid 39154] LOG-THRIFTCLIENT-0002: [1] [tid 39154] Thrift transport exception type #1 (socket open() error: No route to host); failed to establish connection [addr=tt-peer-controller./port=9090].
Command killed: (signal 14) /usr/tintri/bin/fscmd -a 60 -h 'tt-peer-controller.' get-tuning-variable 'stasisDegradedModeTruncationTimeout'
Can't get 'stasisDegradedModeTruncationTimeout', error 142
Can't get timeouts, error 142
Upgrade completed; exit code 109
2022-06-11T16:57:22.166513-07:00 la-tintri01#b upgrade_pkg[30360]: Script /etc/sysconfig/tintri/post_upd/90-upgrade_fs exit code: 109
2022-06-11T16:57:22.167052-07:00 la-tintri01#b upgrade_pkg[30360]: Can not perform application upgrade, error 109
2022-06-11T16:57:22.167467-07:00 la-tintri01#b upgrade_pkg[30360]: Rolling back, state 9

EXAMPLE 3

Sometimes we need to search multiple files:

# awk   'NR==1,/Rolling back/' *.log |grep -H -B20 Rolling 

Or for GZ files

# zcat logfile*.gz|awk 'NR==1,/Rolling back/'

OR

# awk 'NR==1,/Rolling back/' <(gzip -dc logfile*.gz)
Posted in Command Line FU | Leave a comment