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

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