MACOS – Clicking on webpage automatically jumps to top of the page

I recently encountered yet another MAC Madness issue!

I changed out my wired MacBook extended keyboard for a used Apple ‘Magic’ Keyboard.

Well the ‘magic’ was that it introduced an unwanted ‘feature’ whereby when I switch between external monitors, and the webpage in view is scrolled downward, the page would automagically jump to the top of the page. I am at Geek Level 4 in that I have 3 external monitors. So switching between them would move any object on that page automatically to the top; text box, text editor, webpage/etc.

After trolling the Google Verse I didn’t find anything useful.

So after hacking at the Settings on MacOS Ventura I figured it out.

I went to Settings –> Accessibility –> Keyboard

Then uncheck Full Keyboard Access

After that I was back in business.

Posted in MAC-OSX | Leave a comment

Cscope search results are invisible

Part of my ‘day job’ is trolling thru source code when looking for answers. My preferred mechanism, other than a recursive grep, is to use cscope

Cscope is a useful tool for searching a source code tree after you build a list of files to search

The Problem

However, in this conundrum, when I would use any of the search options within cscope the File list (or list of source files) was empty, blank, envisible… basically, I could not SEE any of the results!

Example

Recreating the issue

In the following example, I built a list of files so that I could populate cscope

# cd /export/hg/default/pstoolkit
# find PstkCore/ -type f -not -path "*__In*" -not -path "*__Out*" -not -path "*ThirdPart*" -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" -o -name "*.cs*" > cscope.files

Then I read the results into cscope

# ls -al cscope.files
-rw-rw-r-- 1 bpatridge bpatridge 77196 Feb 13 12:46 cscope.files
# cscope -q -R -b -i cscope.files
# 

Now I attempt to open cscope

# cscope -d

Now I see the window:

However,

When I search for string “TimeOfDay” the search results are invisible?

I even attempted to change the colors but the results were the same

Oddly enough, when I scroll down and press enter I CAN still view one of the source files?

However when I return it is still empty.

The Solution

The solution in this case was surprising.

I trolled the internet for weeks until I finally found a nugget on old ye faithful – stackoverflow which mentioned that cscope has problems with control characters!

I noted when viewing the contents of several files there was a ^M appended to each line.

Therefore I ran dos2unix on all of the files in cscope.files

# cat cscope.files |xargs -n1 -I{}  dos2unix  {}
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/SraPeerArray.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/SraPrepareReverseReplicationResponse.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RecommendationSpaceOutcome.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RemoteCopyInfo.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ReplLinkStat.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ReplicationStat.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestApi.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestApiPrivilege.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/RestoreInfo.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ServiceGroup.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/ServiceGroupOperationStatus.cs to Unix format ...
dos2unix: converting file PstkCore/dotnetSDK/src/SDK/Tintri.Types/Generated/Severity.cs to Unix format ...
....

After this was complete, I was able to run cscope normally and now I can see the search results!!!


Posted in Command Line FU, Linux | Leave a comment

What every Programmer *should* know about Memory

For my fellow Insomniacs out thereā€¦

If you are up scrolling your phone for things around the Google-verse to read to shut off your brain so you can possibly go to sleep.. I came across this article on LWN which provides a trough of information regarding Linux Memory Management.

The original document prints out at over 100 pages and is WAY more than I may ever digest in this lifetime.

Be sure to have a soft pillow for your head to fall down onto!!


Posted in Internals, Linux | Leave a comment

Obtain the grub boot parameters from /var/log/messages

There are times you may need to quickly confirm the grub boot parameters that were issued either at the console (or by default)

This information is logged to /var/log/messages when you grep with keywords “Kernel command”


# grep "Kernel command" messages
2023-09-19 2023-09-19T15:06:08.687 benvm1 NOT Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-1160.76.1.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet, transparent_hugepage=never LANG=en_US.UTF-8
Posted in Linux | Leave a comment

Data Storage Funny #1

Let this sink in!!

Posted in Uncategorized | Leave a comment

Display ethernet devices on a Fedora system using the Linux Pseudo Filesystem and create a static IP Address

Encountered a fun riddle recently whereby on a Fedora 34 system I needed to locate all ethernet interfaces on a system that are obtaining a DHCP address, then after the first reboot create a static IP address.

I am a big fan of looking thru the Linux pseudo filesystem in /sys

In this instance I wanted to exclude any Virtual, Bridge and Local Interfaces.

Therefore I do the following:

Listing all Interfaces in sysfs

# ls /sys/class/net|egrep -v "^vir|^lo|^wl|^br"

Example

# ls /sys/class/net|egrep -v "^vir|^lo|^wl|^br"
eno1

PART 1 – CHANGE FROM DHCP TO STATIC IP ADDRESS

To change from DHCP to a STATIC IP Address

First display the current interfaces

# nmcli con show
NAME    UUID                                  TYPE      DEVICE
enp1s0  46145016-ead7-4128-8d91-4b0b828162db  ethernet  enp1s0

and to set a STATIC IP with NAME “System-NIC-110” the format would be

# nmcli con add con-name "System-NIC-110" ifname enp1s0 type ethernet ip4 192.168.122.110/24 gw4 192.168.122.1

Then you would delete the original interface afterwards

# nmcli con del enp1s0

Then either reboot or restart networking

# nmcli networking off
# nmcli networking on

Now you will see the new interface name.

# nmcli con show
NAME            UUID                                  TYPE      DEVICE
System-NIC-110  fc1ca250-1481-4014-82bd-ad97d1c48ae4  ethernet  enp1s0

PART II – Script method to change all interfaces after first reboot

Here is a script example how to iterate thru all devices on the system and create static IP addresses:

#!/bin/bash
###################################################################
# SCRIPT BY The Data Storage Guy (https://datastorageguy.com)
# As an example how iterate thru all ethernet devices on a Fedora
# system and assign Static IP Addresses with a custom name
#
# location: /usr/local/bin/set-static-ip.sh
###################################################################
# The following will go thru all of the ethernet devices found
#
# It is used to on create static IP addresses with connection NAME
#
# $connection_prefix-$starting_octet
#
# with IP address using the format
#
# $ip_subnet.$starting_octet
#
# It will also increment should there be more
# than one ethernet device found
#
# the parameters are used within the following configuration file
###################################################################
connection_prefix="System-NIC"
ip_subnet="192.168.122"
starting_octet="110"
mask="24"
gateway="192.168.122.1"
###################################################################
PS4='${LINENO}: '
###################################################################
SCRIPT=$(basename ${BASH_SOURCE[0]})
###################################################################
export PATH=$PATH:/usr/bin/
log=/var/log/$(echo $SCRIPT|cut -d. -f1).log
line="-----------------------------------------------"
step=1
n=1
###################################################################
logm() {
        LOGDATE=`date '+%Y-%m-%dT%H:%M:%S'`
        echo $line |tee -a $log
        echo "[$LOGDATE] [$step]  $1" |tee -a $log |tee >(logger -t $SCRIPT)
        ((step++))
}
###################################################################
logm "Displaying Network General Status"
logm "Issuing command: nmcli general status"
nmcli general status  >>$log

logm "Displaying Network Interfaces"
logm "Issuing command: nmcli con show"
nmcli con show |tee -a $log | logger -t $SCRIPT

while read ethname; do
        ip="${ip_subnet}.${starting_octet}"
        UUID=$(nmcli conn show |awk -v iface=$ethname '$NF ~ iface {print $(NF-2)}')
        logm "Setting $ethname ip address to ${ip}/24 with name "${connection_prefix}-$ip" for ethernet $ethname UUID=$UUID"
        logm "Issuing Command:  nmcli con add con-name "${connection_prefix}-$starting_octet" ifname $ethname type ethernet ip4 ${ip}/$mask gw4 $gateway"
        nmcli con add con-name "${connection_prefix}-$starting_octet" ifname $ethname type ethernet ip4 ${ip}/$mask gw4 $gateway  |tee -a $log
        if [ $? == 0 ]; then
                logm "Successfully added con-name ${connection_prefix}-$starting_octet"
        else
                logm "ERROR: Problem adding con-name ${connection_prefix}-$starting_octet"
        fi
        sleep .2
        logm "Deleting $ethname: nmcli con del $ethname"
        logm "Issuing command: nmcli con del $ethname"
        nmcli con del $ethname |tee -a $log
        if [ $? == 0 ]; then
                logm "Successfully deleted $ethname: nmcli con del $ethname"
        else
                logm "ERROR: Unable to delete $ethname: nmcli con del $ethname"
        fi
        ((n++))
        ((starting_octet++))
done< <(ls /sys/class/net|egrep -v "^vir|^lo|^wl|^br")

logm "Displaying Network Interfaces"
logm "Issuing command: nmcli con show"
nmcli con show |tee -a $log |logger -t $SCRIPT

logm "Checking for the install cron job entry"
logm "Issuing command: crontab -l"
crontab -l |tee -a $log|logger -t $SCRIPT

logm "Restarting Network Services"
logm "Issuing command: nmcli networking off"
nmcli networking off |tee -a $log
sleep .2
logm "Issuing command: nmcli networking on"
nmcli networking on |tee -a $log
sleep 2
logm "Displaying Network Interfaces"
logm "Issuing command: ncmli con show"
nmcli con show |tee -a $log |logger -t $SCRIPT

if [ $(nmcli con show|grep -q $connection_prefix;echo $?) == 0 ]; then
        logm "GOOD: Found $connection_prefix Network Device"
        crontab -l |tee -a $log
        if [ $? == 0 ]; then
                logm "Sleeping for 15 seconds... then removing cron job"
                sleep 15
                logm "Removing cron jobs"
                logm "Issuing command: crontab -r"
                crontab -r &>/dev/null
        fi
else
        logm "ERROR: Unable to find $connection_prefix Network device"
fi


logm "Completed Network Setting Setup"
###################################################################

Now we create a cron entry to run only at reboot and log to /root/cron.log

@reboot  /usr/bin/bash /usr/local/bin/set-static-ip.sh >> /root/cron.log

Now when we reboot we see the new network settings.

# nmcli con show
NAME            UUID                                  TYPE      DEVICE
System-NIC-110  62a904ab-2be2-4223-bc13-0b7daba2409e  ethernet  enp1s0
System-NIC-111  350008d7-f075-4ca5-ad97-f5ba8e6f20d0  ethernet  enp7s0

The /var/log/set-static-ip.log shows the following script steps

# cat /var/log/set-static-ip.log
-----------------------------------------------
[2023-09-11T13:28:20] [1]  Displaying Network General Status
-----------------------------------------------
[2023-09-11T13:28:20] [2]  Issuing command: nmcli general status
STATE                  CONNECTIVITY  WIFI-HW  WIFI     WWAN-HW  WWAN
connected (site only)  limited       enabled  enabled  enabled  enabled
-----------------------------------------------
[2023-09-11T13:28:20] [3]  Displaying Network Interfaces
-----------------------------------------------
[2023-09-11T13:28:20] [4]  Issuing command: nmcli con show
NAME    UUID                                  TYPE      DEVICE
enp1s0  197a76a0-a28a-4db4-8e64-a90557e47c9f  ethernet  enp1s0
enp7s0  d0cf6083-8f35-4be1-8705-95ac804eecac  ethernet  enp7s0
-----------------------------------------------
[2023-09-11T13:28:20] [5]  Setting enp1s0 ip address to 192.168.122.110/24 with name System-NIC-192.168.122.110 for ethernet enp1s0 UUID=197a76a0-a28a-4db4-8e64-a90557e47c9f
-----------------------------------------------
[2023-09-11T13:28:20] [6]  Issuing Command:  nmcli con add con-name System-NIC-110 ifname enp1s0 type ethernet ip4 192.168.122.110/24 gw4 192.168.122.1
Connection 'System-NIC-110' (6bd11875-8971-41d0-9089-c3caebc02bb0) successfully added.
-----------------------------------------------
[2023-09-11T13:28:20] [7]  Successfully added con-name System-NIC-110
-----------------------------------------------
[2023-09-11T13:28:20] [8]  Deleting enp1s0: nmcli con del enp1s0
-----------------------------------------------
[2023-09-11T13:28:20] [9]  Issuing command: nmcli con del enp1s0
Connection 'enp1s0' (197a76a0-a28a-4db4-8e64-a90557e47c9f) successfully deleted.
-----------------------------------------------
[2023-09-11T13:28:20] [10]  Successfully deleted enp1s0: nmcli con del enp1s0
-----------------------------------------------
[2023-09-11T13:28:20] [11]  Setting enp7s0 ip address to 192.168.122.111/24 with name System-NIC-192.168.122.111 for ethernet enp7s0 UUID=d0cf6083-8f35-4be1-8705-95ac804eecac
-----------------------------------------------
[2023-09-11T13:28:20] [12]  Issuing Command:  nmcli con add con-name System-NIC-111 ifname enp7s0 type ethernet ip4 192.168.122.111/24 gw4 192.168.122.1
Connection 'System-NIC-111' (8eee96f7-8a42-4bb4-b57a-e15d222743f1) successfully added.
-----------------------------------------------
[2023-09-11T13:28:20] [13]  Successfully added con-name System-NIC-111
-----------------------------------------------
[2023-09-11T13:28:20] [14]  Deleting enp7s0: nmcli con del enp7s0
-----------------------------------------------
[2023-09-11T13:28:20] [15]  Issuing command: nmcli con del enp7s0
Connection 'enp7s0' (d0cf6083-8f35-4be1-8705-95ac804eecac) successfully deleted.
-----------------------------------------------
[2023-09-11T13:28:20] [16]  Successfully deleted enp7s0: nmcli con del enp7s0
-----------------------------------------------
[2023-09-11T13:28:20] [17]  Displaying Network Interfaces
-----------------------------------------------
[2023-09-11T13:28:20] [18]  Issuing command: nmcli con show
NAME            UUID                                  TYPE      DEVICE
System-NIC-110  6bd11875-8971-41d0-9089-c3caebc02bb0  ethernet  enp1s0
System-NIC-111  8eee96f7-8a42-4bb4-b57a-e15d222743f1  ethernet  enp7s0
virbr0          02b8c655-36de-4379-b096-b48de5941117  bridge    virbr0
-----------------------------------------------
[2023-09-11T13:28:21] [19]  Checking for the install cron job entry
-----------------------------------------------
[2023-09-11T13:28:21] [20]  Issuing command: crontab -l
@reboot  /usr/bin/bash /usr/local/bin/set-static-ip.sh >> /root/cron.log
-----------------------------------------------
[2023-09-11T13:28:21] [21]  Restarting Network Services
-----------------------------------------------
[2023-09-11T13:28:21] [22]  Issuing command: nmcli networking off
-----------------------------------------------
[2023-09-11T13:28:21] [23]  Issuing command: nmcli networking on
-----------------------------------------------
[2023-09-11T13:28:21] [24]  Displaying Network Interfaces
-----------------------------------------------
[2023-09-11T13:28:21] [25]  Issuing command: ncmli con show
NAME            UUID                                  TYPE      DEVICE
System-NIC-110  6bd11875-8971-41d0-9089-c3caebc02bb0  ethernet  enp1s0
System-NIC-111  8eee96f7-8a42-4bb4-b57a-e15d222743f1  ethernet  enps7
-----------------------------------------------
[2023-09-11T13:28:21] [26]  GOOD: Found System-NIC Network Device
@reboot  /usr/bin/bash /usr/local/bin/set-static-ip.sh >> /root/cron.log
-----------------------------------------------
[2023-09-11T13:28:21] [27]  Sleeping for 15 seconds... then removing cron job
-----------------------------------------------
[2023-09-11T13:28:36] [28]  Removing cron jobs
-----------------------------------------------
[2023-09-11T13:28:36] [29]  Issuing command: crontab -r
-----------------------------------------------
[2023-09-11T13:28:36] [30]  Completed Network Setting Setup
Posted in Command Line FU, Linux, Networking | Tagged , , | Leave a comment

Modify gnome dock from the command line

To modify the gnome desktop dock (i.e. launcher or launchpad) from the command line an easy way is to perform the following:

/usr/bin/dbus-launch dconf write /org/gnome/shell/favorite-apps "['firefox.desktop', 'org.gnome.Nautilus.desktop', 'org.gnome.Terminal.desktop', 'terminator.desktop', 'gnome-control-center.desktop']"

This above will add Firefox, The File Manager, Terminal, Terminator and Gnome Settings to the desktop

Posted in Linux | Leave a comment

Downloading an RPM package including all of its dependencies on Fedora

There are times when you need to fully download an RPM and all of its dependencies.


However,

If you have already downloaded the RPM re-downloading the RPM and all its dependencies can be very difficult.

I have found the following is a way to use an alternate installation ‘root’ directory so that you can ensure you are not using your system RPM database, and you can download all of the dependencies for the package.

In the following example I

  1. Create an “/installroot” directory
  2. Create a directory called /data/repo/terminator to store the downloaded RPM and its dependencies
  3. Download the ‘terminator’ package for fedora 34
# mkdir /installroot
# mkdir /data/repo/terminator
# dnf -y install --installroot=/instroot --downloaddir=/data/repo/terminator --downloadonly --noautoremove --releasever=34 terminator

The results will look like the following!

# ls /data/repo/terminator/
acl-2.3.1-1.fc34.x86_64.rpm
adwaita-cursor-theme-40.1.1-1.fc34.noarch.rpm
adwaita-icon-theme-40.1.1-1.fc34.noarch.rpm
alsa-lib-1.2.6.1-3.fc34.x86_64.rpm
alternatives-1.15-2.fc34.x86_64.rpm
atk-2.36.0-3.fc34.x86_64.rpm
at-spi2-atk-2.38.0-2.fc34.x86_64.rpm
at-spi2-core-2.40.3-1.fc34.x86_64.rpm
audit-libs-3.0.6-1.fc34.x86_64.rpm
avahi-libs-0.8-14.fc34.x86_64.rpm
basesystem-11-11.fc34.noarch.rpm
bash-5.1.0-2.fc34.x86_64.rpm
bzip2-libs-1.0.8-6.fc34.x86_64.rpm
ca-certificates-2021.2.52-1.0.fc34.noarch.rpm
cairo-1.17.4-3.fc34.x86_64.rpm
cairo-gobject-1.17.4-3.fc34.x86_64.rpm
colord-libs-1.4.5-2.fc34.x86_64.rpm
coreutils-8.32-32.fc34.x86_64.rpm
coreutils-common-8.32-32.fc34.x86_64.rpm
cpio-2.13-10.fc34.x86_64.rpm
cracklib-2.9.6-27.fc34.x86_64.rpm
crypto-policies-20210213-1.git5c710c0.fc34.noarch.rpm
crypto-policies-scripts-20210213-1.git5c710c0.fc34.noarch.rpm
cryptsetup-libs-2.3.7-1.fc34.x86_64.rpm
cups-libs-2.3.3op2-17.fc34.x86_64.rpm
curl-7.76.1-12.fc34.x86_64.rpm
cyrus-sasl-lib-2.1.27-9.fc34.x86_64.rpm
dbus-1.12.20-3.fc34.x86_64.rpm
dbus-broker-29-2.fc34.x86_64.rpm
dbus-common-1.12.20-3.fc34.noarch.rpm
dbus-libs-1.12.20-3.fc34.x86_64.rpm
dconf-0.40.0-3.fc34.x86_64.rpm
dejavu-sans-fonts-2.37-16.fc34.noarch.rpm
device-mapper-1.02.175-1.fc34.x86_64.rpm
device-mapper-libs-1.02.175-1.fc34.x86_64.rpm
diffutils-3.7-8.fc34.x86_64.rpm
dracut-055-6.fc34.x86_64.rpm
elfutils-debuginfod-client-0.186-1.fc34.x86_64.rpm
elfutils-default-yama-scope-0.186-1.fc34.noarch.rpm
elfutils-libelf-0.186-1.fc34.x86_64.rpm
elfutils-libs-0.186-1.fc34.x86_64.rpm
expat-2.4.7-1.fc34.x86_64.rpm
fedora-gpg-keys-34-2.noarch.rpm
fedora-release-34-39.noarch.rpm
fedora-release-common-34-39.noarch.rpm
fedora-release-identity-basic-34-39.noarch.rpm
fedora-repos-34-2.noarch.rpm
file-5.39-7.fc34.x86_64.rpm
file-libs-5.39-7.fc34.x86_64.rpm
filesystem-3.14-5.fc34.x86_64.rpm
findutils-4.8.0-2.fc34.x86_64.rpm
flac-libs-1.3.3-7.fc34.x86_64.rpm
fontconfig-2.13.94-5.fc34.x86_64.rpm
fonts-filesystem-2.0.5-5.fc34.noarch.rpm
freetype-2.10.4-3.fc34.x86_64.rpm
fribidi-1.0.11-3.fc34.x86_64.rpm
fuse-libs-2.9.9-11.fc34.x86_64.rpm
gawk-5.1.0-3.fc34.x86_64.rpm
gawk-all-langpacks-5.1.0-3.fc34.x86_64.rpm
gdbm-libs-1.19-2.fc34.x86_64.rpm
gdk-pixbuf2-2.42.6-1.fc34.x86_64.rpm
gdk-pixbuf2-modules-2.42.6-1.fc34.x86_64.rpm
gettext-0.21-4.fc34.x86_64.rpm
gettext-libs-0.21-4.fc34.x86_64.rpm
glib2-2.68.4-1.fc34.x86_64.rpm
glibc-2.33-21.fc34.x86_64.rpm
glibc-common-2.33-21.fc34.x86_64.rpm
glibc-doc-2.33-21.fc34.noarch.rpm
glibc-minimal-langpack-2.33-21.fc34.x86_64.rpm
gmp-6.2.0-6.fc34.x86_64.rpm
gnutls-3.7.4-1.fc34.x86_64.rpm
gobject-introspection-1.68.0-4.fc34.x86_64.rpm
graphite2-1.3.14-7.fc34.x86_64.rpm
grep-3.6-2.fc34.x86_64.rpm
grub2-common-2.06-9.fc34.noarch.rpm
grub2-tools-2.06-9.fc34.x86_64.rpm
grub2-tools-minimal-2.06-9.fc34.x86_64.rpm
grubby-8.40-51.fc34.x86_64.rpm
gsm-1.0.19-5.fc34.x86_64.rpm
gstreamer1-1.19.1-2.1.18.4.fc34.x86_64.rpm
gtk3-3.24.30-1.fc34.x86_64.rpm
gtk-update-icon-cache-3.24.30-1.fc34.x86_64.rpm
gzip-1.10-5.fc34.x86_64.rpm
harfbuzz-2.7.4-3.fc34.x86_64.rpm
hicolor-icon-theme-0.17-10.fc34.noarch.rpm
iptables-legacy-libs-1.8.7-8.fc34.x86_64.rpm
jbigkit-libs-2.1-21.fc34.x86_64.rpm
json-c-0.14-8.fc34.x86_64.rpm
kbd-2.4.0-2.fc34.x86_64.rpm
kbd-misc-2.4.0-2.fc34.noarch.rpm
keybinder3-0.3.2-11.fc34.x86_64.rpm
keyutils-libs-1.6.1-2.fc34.x86_64.rpm
kmod-29-2.fc34.x86_64.rpm
kmod-libs-29-2.fc34.x86_64.rpm
kpartx-0.8.5-4.fc34.x86_64.rpm
krb5-libs-1.19.2-5.fc34.x86_64.rpm
langpacks-core-font-en-3.0-14.fc34.noarch.rpm
lcms2-2.12-1.fc34.x86_64.rpm
libacl-2.3.1-1.fc34.x86_64.rpm
libarchive-3.5.2-2.fc34.x86_64.rpm
libargon2-20171227-6.fc34.x86_64.rpm
libasyncns-0.8-20.fc34.x86_64.rpm
libattr-2.5.1-1.fc34.x86_64.rpm
libblkid-2.36.2-1.fc34.x86_64.rpm
libbpf-0.4.0-1.fc34.x86_64.rpm
libbrotli-1.0.9-4.fc34.x86_64.rpm
libcanberra-0.30-24.fc34.x86_64.rpm
libcanberra-gtk3-0.30-24.fc34.x86_64.rpm
libcap-2.48-2.fc34.x86_64.rpm
libcap-ng-0.8.2-4.fc34.x86_64.rpm
libcbor-0.7.0-3.fc34.x86_64.rpm
libcloudproviders-0.3.1-3.fc34.x86_64.rpm
libcom_err-1.45.6-5.fc34.x86_64.rpm
libcurl-7.76.1-12.fc34.x86_64.rpm
libdatrie-0.2.13-1.fc34.x86_64.rpm
libdb-5.3.28-49.fc34.x86_64.rpm
libeconf-0.4.0-1.fc34.x86_64.rpm
libepoxy-1.5.9-1.fc34.x86_64.rpm
libevent-2.1.12-3.fc34.x86_64.rpm
libfdisk-2.36.2-1.fc34.x86_64.rpm
libffi-3.1-28.fc34.x86_64.rpm
libfido2-1.6.0-2.fc34.x86_64.rpm
libgcc-11.3.1-2.fc34.x86_64.rpm
libgcrypt-1.9.3-3.fc34.x86_64.rpm
libgomp-11.3.1-2.fc34.x86_64.rpm
libgpg-error-1.42-1.fc34.x86_64.rpm
libgusb-0.3.8-1.fc34.x86_64.rpm
libibverbs-37.2-2.fc34.x86_64.rpm
libICE-1.0.10-6.fc34.x86_64.rpm
libicu-67.1-7.fc34.x86_64.rpm
libidn2-2.3.2-1.fc34.x86_64.rpm
libjpeg-turbo-2.0.90-3.fc34.x86_64.rpm
libkcapi-1.2.1-1.fc34.x86_64.rpm
libkcapi-hmaccalc-1.2.1-1.fc34.x86_64.rpm
libmount-2.36.2-1.fc34.x86_64.rpm
libnghttp2-1.43.0-2.fc34.x86_64.rpm
libnl3-3.5.0-6.fc34.x86_64.rpm
libnsl2-1.3.0-2.fc34.x86_64.rpm
libogg-1.3.4-4.fc34.x86_64.rpm
libpcap-1.10.1-1.fc34.x86_64.rpm
libpng-1.6.37-10.fc34.x86_64.rpm
libpsl-0.21.1-3.fc34.x86_64.rpm
libpwquality-1.4.4-6.fc34.x86_64.rpm
libseccomp-2.5.3-1.fc34.x86_64.rpm
libselinux-3.2-1.fc34.x86_64.rpm
libsemanage-3.2-1.fc34.x86_64.rpm
libsepol-3.2-2.fc34.x86_64.rpm
libsigsegv-2.13-2.fc34.x86_64.rpm
libSM-1.2.3-8.fc34.x86_64.rpm
libsmartcols-2.36.2-1.fc34.x86_64.rpm
libsndfile-1.0.31-6.fc34.x86_64.rpm
libssh-0.9.6-1.fc34.x86_64.rpm
libssh-config-0.9.6-1.fc34.noarch.rpm
libstdc++-11.3.1-2.fc34.x86_64.rpm
libtasn1-4.16.0-4.fc34.x86_64.rpm
libtdb-1.4.3-6.fc34.x86_64.rpm
libtextstyle-0.21-4.fc34.x86_64.rpm
libthai-0.1.28-6.fc34.x86_64.rpm
libtiff-4.2.0-1.fc34.x86_64.rpm
libtirpc-1.3.2-0.fc34.x86_64.rpm
libtool-ltdl-2.4.6-40.fc34.x86_64.rpm
libunistring-0.9.10-10.fc34.x86_64.rpm
libunwind-1.4.0-5.fc34.x86_64.rpm
libusbx-1.0.24-2.fc34.x86_64.rpm
libutempter-1.2.1-4.fc34.x86_64.rpm
libuuid-2.36.2-1.fc34.x86_64.rpm
libverto-0.3.2-1.fc34.x86_64.rpm
libvorbis-1.3.7-3.fc34.x86_64.rpm
libwayland-client-1.20.0-4.fc34.x86_64.rpm
libwayland-cursor-1.20.0-4.fc34.x86_64.rpm
libwayland-egl-1.20.0-4.fc34.x86_64.rpm
libwebp-1.2.2-1.fc34.x86_64.rpm
libX11-1.7.2-3.fc34.x86_64.rpm
libX11-common-1.7.2-3.fc34.noarch.rpm
libX11-xcb-1.7.2-3.fc34.x86_64.rpm
libXau-1.0.9-6.fc34.x86_64.rpm
libxcb-1.13.1-7.fc34.x86_64.rpm
libXcomposite-0.4.5-5.fc34.x86_64.rpm
libxcrypt-4.4.28-1.fc34.x86_64.rpm
libxcrypt-compat-4.4.28-1.fc34.x86_64.rpm
libXcursor-1.2.0-5.fc34.x86_64.rpm
libXdamage-1.1.5-5.fc34.x86_64.rpm
libXext-1.3.4-6.fc34.x86_64.rpm
libXfixes-6.0.0-1.fc34.x86_64.rpm
libXft-2.3.3-6.fc34.x86_64.rpm
libXi-1.7.10-6.fc34.x86_64.rpm
libXinerama-1.1.4-8.fc34.x86_64.rpm
libxkbcommon-1.3.0-1.fc34.x86_64.rpm
libxml2-2.9.13-1.fc34.x86_64.rpm
libXrandr-1.5.2-6.fc34.x86_64.rpm
libXrender-0.9.10-14.fc34.x86_64.rpm
libXtst-1.2.3-14.fc34.x86_64.rpm
libzstd-1.5.2-1.fc34.x86_64.rpm
lua-libs-5.4.4-1.fc34.x86_64.rpm
lz4-libs-1.9.3-2.fc34.x86_64.rpm
memstrack-0.2.2-1.fc34.x86_64.rpm
mkpasswd-5.5.10-1.fc34.x86_64.rpm
mpfr-4.1.0-7.fc34.x86_64.rpm
ncurses-6.2-4.20200222.fc34.x86_64.rpm
ncurses-base-6.2-4.20200222.fc34.noarch.rpm
ncurses-libs-6.2-4.20200222.fc34.x86_64.rpm
nettle-3.7.3-1.fc34.x86_64.rpm
openldap-2.4.57-6.fc34.x86_64.rpm
openssl-libs-1.1.1n-1.fc34.x86_64.rpm
openssl-pkcs11-0.4.11-2.fc34.x86_64.rpm
opus-1.3.1-8.fc34.x86_64.rpm
os-prober-1.77-7.fc34.x86_64.rpm
p11-kit-0.23.22-3.fc34.x86_64.rpm
p11-kit-trust-0.23.22-3.fc34.x86_64.rpm
pam-1.5.1-8.fc34.x86_64.rpm
pango-1.48.11-1.fc34.x86_64.rpm
pcre2-10.36-4.fc34.x86_64.rpm
pcre2-syntax-10.36-4.fc34.noarch.rpm
pcre-8.44-3.fc34.1.x86_64.rpm
pigz-2.5-1.fc34.x86_64.rpm
pixman-0.40.0-3.fc34.x86_64.rpm
popt-1.18-4.fc34.x86_64.rpm
procps-ng-3.3.17-1.fc34.1.x86_64.rpm
publicsuffix-list-dafsa-20190417-5.fc34.noarch.rpm
pulseaudio-libs-14.2-3.fc34.x86_64.rpm
python3-3.9.12-1.fc34.x86_64.rpm
python3-cairo-1.20.1-1.fc34.x86_64.rpm
python3-configobj-5.0.6-23.fc34.noarch.rpm
python3-dbus-1.2.18-1.fc34.x86_64.rpm
python3-gobject-3.40.1-1.fc34.x86_64.rpm
python3-gobject-base-3.40.1-1.fc34.x86_64.rpm
python3-libs-3.9.12-1.fc34.x86_64.rpm
python3-pip-21.0.1-4.fc34.noarch.rpm
python3-psutil-5.8.0-5.fc34.x86_64.rpm
python3-setuptools-53.0.0-3.fc34.noarch.rpm
python3-six-1.15.0-5.fc34.noarch.rpm
python-pip-wheel-21.0.1-4.fc34.noarch.rpm
python-setuptools-wheel-53.0.0-3.fc34.noarch.rpm
python-unversioned-command-3.9.12-1.fc34.noarch.rpm
qrencode-libs-4.1.1-1.fc34.x86_64.rpm
readline-8.1-2.fc34.x86_64.rpm
rpm-4.16.1.3-1.fc34.x86_64.rpm
rpm-libs-4.16.1.3-1.fc34.x86_64.rpm
sed-4.8-7.fc34.x86_64.rpm
setup-2.13.7-3.fc34.noarch.rpm
shadow-utils-4.8.1-10.fc34.x86_64.rpm
shared-mime-info-2.1-2.fc34.x86_64.rpm
sound-theme-freedesktop-0.8-15.fc34.noarch.rpm
sqlite-libs-3.34.1-2.fc34.x86_64.rpm
systemd-248.10-1.fc34.x86_64.rpm
systemd-libs-248.10-1.fc34.x86_64.rpm
systemd-networkd-248.10-1.fc34.x86_64.rpm
systemd-pam-248.10-1.fc34.x86_64.rpm
systemd-rpm-macros-248.10-1.fc34.noarch.rpm
systemd-udev-248.10-1.fc34.x86_64.rpm
terminator-2.1.1-1.fc34.noarch.rpm
tpm2-tss-3.1.0-1.fc34.x86_64.rpm
tzdata-2022a-1.fc34.noarch.rpm
util-linux-2.36.2-1.fc34.x86_64.rpm
vte291-0.64.2-1.fc34.x86_64.rpm
vte-profile-0.64.2-1.fc34.x86_64.rpm
which-2.21-26.fc34.x86_64.rpm
whois-nls-5.5.10-1.fc34.noarch.rpm
xkeyboard-config-2.33-1.fc34.noarch.rpm
xml-common-0.6.3-56.fc34.noarch.rpm
xz-5.2.5-9.fc34.x86_64.rpm
xz-libs-5.2.5-9.fc34.x86_64.rpm
zlib-1.2.11-26.fc34.x86_64.rpm

If there is a need to download a GROUP of packages such as Gnome Desktop, you may do the following

# dnf -y group install "Basic Desktop" GNOME  --installroot=/installroot  --downloadonly --downloaddir=/tmp/repo -releasever=34

*note: If you need to re-download them again on the same system you should make a new /installroot directory.

Posted in Command Line FU, Linux | Tagged , , , , | Leave a comment

List only ethernet Network Adapters on Debian/Fedora

Sometimes you want a quick way to verify all ethernet network adapters that are seen by the kernel at boot time. I find going directly to the pseudo filesystem is the fastest.

For example.

# ls /sys/class/net|egrep -v "^vir|^lo|^wl"
enp1s0

Similarly, you an modify the egrep accordingly if you want to view wifi and ethernet adapters and exclude any bridge or virtual adapters

# ls /sys/class/net|egrep -v "^v|^b|lo"
eno1
wlp3s0

Posted in Linux, Networking | Tagged , , , | Leave a comment

Remove any potential special characters or spaces from an IP address using AWK

Got stuck earlier in an interesting regex mystery and I command-line FU’d an AWK Solution.

PROBLEM

I want to strip out all spaces and/or special characters from an IP address

PROCESS

I know how to validate an IP address no problem..


Good IPO

# echo 192.168.1.122 |egrep -q  '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'; echo $?
0

Bad IP

# echo 192.168.xxx.111  |egrep -q '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'; echo $?
1

However..

What if am gathering user input via script and I want to strip out any and ALL characters except the numeric IP Address!

For example,

If IP

' _192. 168.122.35'_   "

And I want to only display

192.168.122.35

Leading/trailing spaces can be stripped no problem, but it will still print the special characters

# echo "   _192. 168.122.35'_   "|awk '{gsub(/^[[:space:]]+|[[:space:]]+$/,"",$0); print}'
_192. 168.122.35'_
#


SOLUTION

I put together the following awk script to strip out everything and ONLY print the IP address.

awk -F "." '{for (i=1;i<=NF;i++) {sub("[^[:digit:]]+", "", $i);gsub(/^[[:space:]]+|[[:space:]]+$/,"",$i);if (i < NF) {p="."}else{p=""}  ;printf $i p}}'

Example

#  echo ' _ 192 .168 .120.111 "@  '|awk -F "." '{for (i=1;i<=NF;i++) {sub("[^[:digit:]]+", "", $i);gsub(/^[[:space:]]+|[[:space:]]+$/,"",$i);if (i < NF) {p="."}else{p=""}  ;printf $i p}}'
192.168.120.111
#

To put it all together in a quick script called ‘btest’

#!/bin/bash
if [ $# != 0 ]; then
        if [ $(echo "$1"  |egrep -q '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'; echo $?) == 0 ]; then
                echo "Validated IP address [$1]"
                IP=$(echo "$1"|awk -F "." '{for (i=1;i<=NF;i++) {sub("[^[:digit:]]+", "", $i);gsub(/^[[:space:]]+|[[:space:]]+$/,"",$i);if (i < NF) {p="."}else{p=""}  ;printf $i p}}')
                echo "Corrected IP Address=$IP"
        else
                echo "Invalid IP address [$1]"
        fi

else
        echo "Enter IP address"
fi

If we were to enter an IP address of “192.168.1.11′” which contains a ‘tick’ at the end , the initial Validation would succeed.

But I can then show you how we use awk to strip out any misc characters

# ./btest "192.168.1.11'"
Validated IP address [192.168.1.11']
Corrected IP Address [192.168.1.11]

If we were to add leading and trailing white spaces on the argument we can see that it is still corrected

# ./btest " 192.168.1.11' "
Validated IP address [ 192.168.1.11' ]
Ensuring IP does not have any special characters or spaces
Corrected IP Address [192.168.1.11]

If we type an invalid IP Address we see it is caught

# ./btest " 192.168.1.xx' "
Invalid IP address [ 192.168.1.xx' ]

If I got extra wild and crazy and used the following for an IP address we would see it would still succeed

# ./btest ' _ 192.168.120.111 "@  '
Validated IP address [ _ 192.168.120.111 "@  ]
Corrected IP Address [192.168.120.111]

Now to put it all together into a script that will gather user input

#!/bin/bash
e=0
while [ $e == 0 ]; do
        printf "Enter IP address > "
        read ip
        if [ ! -z "$ip" ]; then
                if [ $(echo "$ip"  |egrep -q '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}'; echo $?) == 0 ]; then
                        echo "Validated IP address [$ip]"
                        ip=$(echo "$ip"|awk -F "." '{for (i=1;i<=NF;i++) {sub("[^[:digit:]]+", "", $i);gsub(/^[[:space:]]+|[[:space:]]+$/,"",$i);if (i < NF) {p="."}else{p=""}  ;printf $i p}}')
                        echo "Corrected IP Address [$ip]"
                        e=1
                else
                        echo "Invalid IP address [$ip]"
                        e=0
                fi

        else
                echo "ERROR: Enter IP address"
        fi
done

Example 1

# ./btest
Enter IP address > 192.168.1.222
Validated IP address [192.168.1.222]
Corrected IP Address [192.168.1.222]

Example 2

# ./btest
Enter IP address > '192.168.122.111 '
Validated IP address ['192.168.122.111 ']
Ensuring IP does not have any special characters or spaces
Corrected IP Address [192.168.122.111]
Posted in Command Line FU, Linux | Tagged , , , , , | Leave a comment