Tag Archive for 'Linux'

Monitoring network connections on Linux

Here is a great TCP/UDP Port finder tool.   This was useful for finding out which port “cbt” was in my Iftop listing.  It was 7777, which was in use for the Unreal Engine on an Ark: Survival Evolved game server. Iftop is the best real time network monitoring tool for Linux that has graced my system to date — or so it seems until one finds Iptraf. Iptraf is another excellent tool for monitoring network traffic in real time.  The Iptraf manual is here.  Netstat wasn’t suitable for this purpose due to the use of UDP as the main protocol.  Netstat is certainly useful, but no switches that I could locate would enable the program to show the UDP traffic in real time and the associated addresses of those connected to the server.  Iptraf shows the UDP traffic in a rapidly updating scroll box.  Iftop shows the traffic in an easy to read display that includes the address and hostname of the connected system.

This list doesn’t relate to more in depth management tools. This list is for easy console monitoring of a server running such games as ARK Survival Evolved.

Install cron on Fedora 38

dnf install cronie
systemctl enable crond.service
systemctl start crond.service

Building an anti-bitrot bunker

When I first obtained a CompTIA A+ certification some time ago, the concept of bit rot related to what happens to software reliability as the number of updates to the system increases. Over time, software that worked in years past ceases to work as new system updates block system calls or change permissions and files that the software originally relied upon. This slow decaying of reliability was called bit rot. There are some other definitions floating around on the internet, but that is the one most relevant for me.

To prevent this and reduce the amount of time spent in sorting out the bit rot introduced to my investments by Microsoft’s proclivities, I have standardized on two operating systems for major time investments in computing that occupy my life.  Windows still has a place since I sometimes use Windows only games to play with my child.  Other than that necessity, I have built the things I rely on for use with Linux.  The two versions that I have standardized on are Debian and Fedora. Specifically Debian 12 and Fedora 38.  These are not what is used for the website, but they are the major components of my anti-bitrot infrastructure.  I am aware this may not be good security practice, but this isn’t to get me a job, this is to serve an aging man and his family reliably over time.

There are a few reasons that I selected Fedora 38 and Debian 12. Fedora 38 still has Python 2.7 in the repositories.  It was within 2 versions for upgrading from Fedora 36. Fedora 36 was what I was running in my Windows Subsystem for Linux instance, and I upgraded it to Fedora 38.   When deciding to move back to bare metal for my Linux software development and automation needs, I decided to standardize on that one.  Debian has a 32 bit version. I have both the 32-bit and 64-bit deployed in my network.  Debian 32 bit allows on to easily 32-bit builds of Java on a Linux server.  One can add the testing repository and have the latest Java in 32 bit form.  32-bit Java is necessary to run older Minecraft versions.  My family has a large set of mod-collections and old Java Minecraft instances and maps going back about 8 years. I can then run the latest JVM and the latest Minecraft on the same server because the 32bit JVM is available.  It is very annoying to try and  manage 32bit and 64bit Java virtual machines on the same host, so having it all 32-bit solves a huge problem.  One can add the Debian 11 repository and install Python2.7 if one wants to use old Python versions.  I need this old Python version for a project that I worked on over the course of the last 8 years.

The general anti-bit rot measure for Debian is to always use apt-get to install packages as this will leave the .deb file in the cache.  Then copy those .deb files on a regular basis to another location for use as a repository for other Debian installations.  This can be configured to work via a cron job.  Debian is really the only long-term viable game in town if one wants a 32-bit anti-bitrot bunker that will last into the future, over say, a ten year time horizon. Save the .deb files on a private web-server inside the network and periodically update that repository with the files copied via the sweeps from the cache directory.

For Fedora, this should work with any version.  Fedora 38 is the one I use.  Edit the /etc/dnf/dnf.conf file to say keep_cache=True, and this will save the dowloaded RPMS.  One can then build their repository using only what they need if so desired.  The other genuine long term standardization option is to mirror the entire repositories to the private webserver within one’s network.  To do this, install yumdownloader.   Then, move all of the .repo files from /etc/yum.repos.d except for one to a temporary location.  Then, go into a directory with a lot of space.  For Fedora 38, the complete mirror was 229GB.  Then use yumdownloader * and it will download all files from that repository.  Then, use yumdownloader –source * and it will download all source packages for the packages that it just downloaded.  Then, go back to /etc/yum.repos.d and switch that .repo file out with one that was moved previously, and repeat the process until all repositories have been completely downloaded.  Then, copy all downloaded RPMS to one large directory on the webserver and use createrepo to create the meta data.  Then on the client machines, create a .repo pointing to your own webserver, and move the existing .repo files in /etc/yum.repos.d to an archival location.   Then all of your installations will occur from your own webserver and all machines will have the same versions of packages.

In my case, I then install the data science specifics that I need for the automated software that I created.  The process varies slightly depending on whether the system is Fedora or Debian.

For Debian:

Add bullseye to sources.list
Install python2 via bullseye repositories
Install pip via the downloaded file from https://linuxhint.com/install-pip-on-debian-11/ that is to say,
1. wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
2. python2 ./get-pip.py
Apt-get install libcurl4-openssl-dev

R:
Install.packages(‘curl’)
Install.packages(‘fpp2’)
Install.packages(‘magrittr’)
Install.packages(‘urca’)
Install.packages(‘vars’)
Install.packages(‘psych’)
Apt-get install r-cran-rjava
Install.packages(‘rJava’)
Install.packages(‘xlsx’)
Install.packages(‘Hmisc’)
Install.packages(‘prophet’)
Install.packages(‘dplyr’)
pip2 install parsedatetime==2.5
apt-get install awscli
pip2 install boto3
apt-get install r-cran-car

Troubleshooting steps if .xlsx and others are not built:
Are all R packages installed successfully with a 0 exit status?

On Fedora, the repositories do not contain R components in the same way the Debian repositories do.  Here is the process for Fedora 38.

Used the script https://bootstrap.pypa.io/pip/2.7/get-pip.py
pip2 install parsedatetime==2.5 –user
dnf install libcurl
dnf install libcurl-devel
dnf install R
dnf install awscli
pip2 install boto3 –user
dnf install cmake

Within R:
install.packages(‘car’)
install.packages(‘curl’)
install.packages(‘fpp2′)
install.packages(‘magrittr’)
install.packages(‘urca’)
install.packages(‘vars’)
install.packages(‘psych’)
install.packages(‘rJava’)
install.packages(‘xlsx’)
install.packages(‘Hmisc’)
install.packages(‘prophet’)
install.packages(‘dplyr’)

VirtualBox Disk Conversion

To convert a dynamic VirtualBox disk to a Fixed disk, run the following command:

vboxmanage clonemedium disk /path/disk.vdi /path/newdisk.vdi -variant Fixed

using –variant Standard would create a dynamic disk.  Then open the virtual machine and remove the existing disk and attach the new disk.  Then use the media manager to delete the unused media.

Use the following command to list registered virtual disks:

vboxmanage list hdds

Debian 12 PATH and X11

A few quirks with Debain 12 include that path not being set in similar fashion to Fedora, Ubuntu, and other distributions.  One must regularly set

export PATH=$PATH:/usr/sbin

In Gnome, applications will open on the server instead of the client when using X11 forwarding.  This will occur even though xcalc opens on the client normally.  The way to avoid this is to add the following to .bashrc

unset XDG_RUNTIME_DIR 
unset GDK_BACKEND

The general rule is compress, then encrypt.1, 2

1. https://stackoverflow.com/questions/4676095/when-compressing-and-encrypting-should-i-compress-first-or-encrypt-first

2. https://crypto.stackexchange.com/questions/33737/is-it-better-to-encrypt-before-compression-or-vice-versa

Move /var to new disk

To add a new virtual disk and move the existing Linux partition to the new disk use the following process. The process assumes standard partitions without the use of Logical Volume Manager (LVM).

1. Backup the existing VM. One good way to do that is to clone the Virtual Machine and use the procedure on the new Virtual Machine.

2. Create the partition and format it.

$ mount /dev/sbd /mnt
$ shopt -s dotglob
$ rsync -aulvXpogtr /var/* /mnt
$ nano /etc/fstab

Add this line, replacing sdb and ext4 as necessary:

/dev/sdb /var ext4 defaults,noatime,nofail 0 2

Then

$ mv /var/ /var.old

Reboot and enjoy the new drive.

Install Java 21 in Debian 12

Minecraft Java edition lost compatibility with Java 17 between 1.20.4 and 1.20.6. Version 1.20.4 works with Java 17, and 1.20.6 no longer works with Java 17.  Several guides appear online for installing downloaded packages of the 64-bit runtime from Oracle or other sources.  Since Debian offers 32-bit server operating systems in the present day, the package manager versions are the easiest option if one uses the 32-bit version of Debian.  One of the reasons to use the 32-bit version of Debian is for use with older versions of Minecraft such as 1.10 and 1.12.  The older versions’ ecosystem contain an incredible number of mods.  The older versions require 32-bit java runtimes and the easiest way to handle that is to use a 32-bit operating system and then one can have newer versions of Java alongside older versions of Java and then one can run any version of Minecraft and Minecraft Forge that they desire.

Edit /etc/apt/sources.list to contain the following lines:

deb http://deb.debian.org/debian testing main
deb-src http://deb.debian.org/debian testing main

Then, run the following commands.

apt-get update
apt-get install openjdk-21-jre
java –version

https://wiki.debian.org/DebianTesting contains a good reference guide for using Debian Testing, including details on upgrading to the next distribution.  The approximate Java lifecycle can be found at https://www.oracle.com/java/technologies/java-se-support-roadmap.html.

Print environmental variables in Bash

Use printenv to see what environment variables are set.

#!/usr/bin/env bash
printenv
    set -x

.nanorc in CentOS

Edit $HOME/.nanorc to contain the following:

include /usr/share/nano/java.nanorc
include /usr/share/nano/man.nanorc
include /usr/share/nano/nanorc.nanorc
include /usr/share/nano/python.nanorc
include /usr/share/nano/sh.nanorc
include /usr/share/nano/html.nanorc
include /usr/share/nano/perl.nanorc
include /usr/share/nano/php.nanorc

CentOS 7 uses a much older version of nano than the one that presently ships on most distributions. The php.nanorc on newer The following should appear in /usr/share/nano/php.nanorc on CentOS7 to allow syntax highlighting for php:

 

## Syntax highlighting for PHP

syntax "php" "\.(php[23457s~]?|phtml|ctp)$"

# PHP markings.
color brightgreen "()"

# Function names.
color white "\

The .bashrc file I use on CentOS6

The .bashrc file I use on CentOS6

 

# .bashrc

# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# system variables
export VISUAL=nano  # sets nano as the crontab editor
export GZIP=-9      # maximum compression
export XZ_OPT=-9    # maximum compressions

# ls modifications
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# calculator
calc() { echo "$*" | bc -l; }

# Generate a UUID
uuid() { UUID=$(cat /proc/sys/kernel/random/uuid) && echo $UUID; }

# CHANGE SHELL/WINDOW TITLE
# Works on Opensuse 15.3
# PS1=$PS1"\[\e]0;test1\a\]"
shellrename() { read -p "Enter new shell name: " name && PS1=$PS1"\[\e]0;${name}\a\]"; }

# For older versions of gnome-terminal
# shellrename() { read -p "Enter new shell name: " name && PROMPT_COMMAND='echo -ne "\033]0;${name}\007"'; }

# Zen Burn
# Another old way that works great in gnome-terminal while causing problems
# in some configurations involving SSH:
echo -ne '\e]12;#BFBFBF\a'
echo -ne '\e]10;#DCDCCC\a'
echo -ne '\e]11;#3F3F3F\a'
echo -ne '\e]4;0;#3F3F3F\a'
echo -ne '\e]4;1;#705050\a'
echo -ne '\e]4;2;#60B48A\a'
echo -ne '\e]4;3;#DFAF8F\a'
echo -ne '\e]4;4;#506070\a'
echo -ne '\e]4;5;#DC8CC3\a'
echo -ne '\e]4;6;#8CD0D3\a'
echo -ne '\e]4;7;#DCDCCC\a'
echo -ne '\e]4;8;#709080\a'
echo -ne '\e]4;9;#DCA3A3\a'
echo -ne '\e]4;10;#C3BF9F\a'
echo -ne '\e]4;11;#F0DFAF\a'
echo -ne '\e]4;12;#94BFF3\a'
echo -ne '\e]4;13;#EC93D3\a'

The best Alias for ls

The best alias for ls is

ls –halF

It is easy to remember, and produces easy to read output with human readable file sizes and / marks present by the directory names..

Install iftop on Oracle Linux 9

dnf install oracle-epel-release-el9
dnf install iftop

iptraf is already in the default repositories.

A good version of ll

A really good version of the ll alias is:

ls –lahF, although on some versions ls –lahp looks better than F.

LS alias and Mozilla DRM bar

Some useful aliases that are not always preconfigured on every Linux version:

alias ll=’ls -alF’
alias la=’ls -A’
alias l=’ls –CF’

To eliminate the DRM warning in Firefox and Librewolf without enable DRM, add this to “userChrome.css”:

 notification[value="drmContentDisabled"]{ display:none !important; }

toolkit.legacyUserProfileCustomizations.stylesheets must be set to true in about config.

Double Sided Scan and PDF

The following script scans PDFs via an auto-document feeder in Hp-Lip and then collates the pages to the correct order when there are reverse sides. No scans will be saved if no data is transmitted for the second set of scans. The second set of scans is the reverse of the pages.

#!/usr/bin/env bash

YMD=$(date +"%Y-%m-%d")
Y=$(date +"%Y")
WORKDIR=/home/username/Temp/
OUTPATH=/home/username/Scans/${Y}/
#  Create a folder, ~/Temp and create a folder, ~/Scans
mkdir -p "/home/username/Scans/${Y}"

hp-scan --adf --mode=color &&
PART=hpscan
LATESTSCAN=`ls -t ${PART}*pdf | sed "1q"`
echo "${LATESTSCAN} ready for ${FILEOUTPUT}"

#  Why you shouldn't parse the output of ls
#  http://mywiki.wooledge.org/ParsingLs 
#  This does not use the FILEOUTPUT variable itself because the cp command
#  seems to have trouble copying the file correctly, even with switches. 

# Thanks Elektropepi at https://github.com/qpdf/qpdf/issues/259
function pdfscanmerge() {
	if [ $# -ne 3 ]; then 
		echo "Usage: pdfscanmerge"; return; fi let odd_pages=$(qpdf --show-npages $1) let even_page=$(qpdf --show-npages $2) argument= for (( odd_page=1; odd_page0 ]; then argument+="$2 $even_page " fi let even_page-- done qpdf --empty --pages $argument -- $3 } cp ${LATESTSCAN} "$WORKDIR$1-uncompressed-scanned-${YMD}.pdf" gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -sOutputFile="$OUTPATH${YMD}-$1.pdf" ${LATESTSCAN} sleep 1 rm -f ${LATESTSCAN} rm -f "$WORKDIR$1-uncompressed-scanned-${YMD}.pdf" killall evince read -p "Load the reverse sides and press any key:" n hp-scan --adf --mode=color && PART=hpscan LATESTSCAN=`ls -t ${PART}*pdf | sed "1q"` echo "${LATESTSCAN} ready for ${FILEOUTPUT}" cp ${LATESTSCAN} "$WORKDIR$1-uncompressed-scanned-reverse-${YMD}.pdf" gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -sOutputFile="$OUTPATH${YMD}-$1-reverse.pdf" ${LATESTSCAN} sleep 1 rm -f ${LATESTSCAN} rm -f "$WORKDIR$1-uncompressed-scanned-reverse-${YMD}.pdf" killall evince pdfscanmerge "$OUTPATH${YMD}-$1.pdf" "$OUTPATH${YMD}-$1-reverse.pdf" "$OUTPATH${YMD}-$1-collated.pdf" rm -f "$OUTPATH${YMD}-$1.pdf" rm -f "$OUTPATH${YMD}-$1-reverse.pdf"

Automated Database Restart

Here is a script that checks to ensure the database is running and restarts the service if it is not running.  This was used on a very low memory server to ensure a database remained operational, despite it sometimes crashing due to out of memory errors.

#!/bin/bash

timestamp="$(date)"
systemctl stop httpd && echo "${timestamp}" Stopping Apache... >> /home/centos/administration/apache.log
systemctl is-active mariadb && echo "${timestamp}" MariaDB is active so not starting >> /home/centos/administration/mariadb_active.log || echo "${timestamp}" MariaDB is not Active >> /home/centos/administration/mariadb_inactive.log
systemctl is-active mariadb && echo "${timestamp}" No need to restart MariaDB || systemctl start mariadb
systemctl start httpd && echo "${timestamp}" restarting apache...>> /home/centos/administration/apache.log

AppImage Integration

To install AppImages and integrate them with the desktop environment like a conventional package,  use the AppImage Launcher. LibreWolf’s documentation contains a how-to document on using AppImage Launcher.

Functions in Bash

This is the code for a function in Bash script.

 #!/bin/bash
 # Define a function
 greet() {
 echo "Hello, $1"
 }
 # Call the function with "World" as the argument
 greet "World"

Looping through filenames in Bash

To loop through the subdirectories in a folder, when those subdirectories may contain spaces in the file names, use the following procedure.

OLD_IFS=$IFS && IFS=$'\n'
 for directory in $HOME/somefolder/*/; do
 echo “some code here”
 done
 IFS=$OLD_IFS

 

Bash and *nix Note no. 2

 

This document contains some notes on .bashrc for use with Linux systems.

alias ll=’ls -alF’
alias la=’ls -A’
alias l=’ls –CF’

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

The preceding two blocks come standard on Ubuntu as of version 2022.04. One tweak for WSL2 on Windows might be the addition of this line.

sudo bash “/etc/rc.local”

and in the rc.local follow, add the following.

#!/bin/bash
rm -f /etc/resolv.conf
echo “nameserver 1.1.1.1″ >> /etc/resolv.conf
echo “nameserver 8.8.8.8″ >> /etc/resolv.conf

This is because WSL2 may place non-routable IP addresses using 172… in resolv.conf. As of this writing, following steps recommended to disable the generation of the file fails to resolve the issue where the file is newly generated with every new terminal launched in Windows terminal. Having this run with each new Bash login ensures success with network communications.  The location /etc/rc.local may seem like an odd location for this.

The crontab to ensure to check each minute to ensure a virtual machine is running in VirtualBox is as follows.

*/1 * * * * VBoxManage startvm “VMNAME” –type headless
*/1 * * * * VBoxManage startvm “VMNAME2″ –type headless

If the virtual machine is already running, then it will not start a new copy of it. This is better than attempting to run the script via a system wide script after a reboot.  Running it this way allows a simple crontab for the user for whom the machine needs to run under. To run a script every five minutes, add the crontab as follows:

*/5 * * * * /home/USERNAME/nextcloudcron

In this example, the nextcloudcron script will run every five minutes.  This particular script is one for use contacting my Nextcloud instance for webcron.  It does not contain a .sh on the filename, because some implementations may disallow crontab scripts with file extensions.

The following checks inside a subdirectory and pulls in the files therein as bash sources. This is useful for breaking aliases, variables, and other items into different files.

if [ -d ~/.bashrc.d ]; then
for rc in ~/.bashrc.d/*; do
if [ -f "$rc" ]; then
. “$rc”
fi
done
fi

The following uses nano as the crontab editor.

export VISUAL=nano

On Oracle Linux 9 on AWS, it is necessary to install Cronie to enable cron jobs.  To ensure this starts after reboots, add the following to /etc/rc.local.

bash /sbin/crond

To create a date line for a log file, use the following:

echo $(date) >> /home/USER/FILENAME

The Shebang for the top of bash files is

#!/usr/bin/env bash

To auto-update via DNF and leave a log of what was accomplished, use the following script.  The script will write a list of the updates to the systemupdates.log file, and then update the system with details of that process written to the dnfupdates.log file.

#!/usr/bin/env bash
echo $(date) >> /home/USER/systemupdates.log
sudo dnf check-update >> /home/USER/systemupdates.log
echo $(date) >> /home/USER/dnfupdates.log
sudo dnf update -y >> /home/USER/dnfupdates.log 2>&1

Bash and *nix Note no. 1

7 July 2023:
Ubuntu 22.04′s update notifier seems to not include the option to configure any settings, at least after certain conditions exist on a particular system.  To stop the notifier from appearing.  To stop the notifier from appearing use

sudo apt-get remove update-notifier

7 July 2023:
There are non-snap builds of ungoogled-chromium for Ubuntu

6 July 2023 and prior:

To disable automatic updates on Ubuntu:

sudo dpkg-reconfigure unattended-upgrades
sudo apt remove packagekit

In .bashrc create the following alias:

alias nano="nano -c --guidestripe 80"

This will open always Nano with line and column numbering along with a long line marker at the specified column. The long line marker feature works for Nano version higher than 4, which doesn’t include the version in the CentOS 7 repositories.

In .bashrc add the following line:

export DISPLAY=\
"`grep nameserver /etc/resolv.conf | sed 's/nameserver //'`:0"

This adds the IP address of the instance to the display variable for use with Windows Subsystem for Linux and VcXsrv.

In .nanorc add the following items. The first two lines are commented because the command line switch used in the alias for the line numbers creates no artifacts when using copy-paste.

#set linenumbers
#set constantshow

# https://www.nano-editor.org/dist/latest/nanorc.5.html
set guidestripe 80

include /usr/share/nano/autoconf.nanorc
include /usr/share/nano/patch.nanorc
include /usr/share/nano/nanorc.nanorc
include /usr/share/nano/groff.nanorc
include /usr/share/nano/awk.nanorc
include /usr/share/nano/man.nanorc
include /usr/share/nano/java.nanorc
include /usr/share/nano/sh.nanorc
include /usr/share/nano/po.nanorc
include /usr/share/nano/texinfo.nanorc
include /usr/share/nano/python.nanorc
include /usr/share/nano/perl.nanorc
include /usr/share/nano/pov.nanorc
include /usr/share/nano/ocaml.nanorc
include /usr/share/nano/tcl.nanorc
include /usr/share/nano/debian.nanorc
include /usr/share/nano/lua.nanorc
include /usr/share/nano/xml.nanorc
include /usr/share/nano/gentoo.nanorc
include /usr/share/nano/objc.nanorc
include /usr/share/nano/tex.nanorc
include /usr/share/nano/guile.nanorc
include /usr/share/nano/php.nanorc
include /usr/share/nano/c.nanorc
include /usr/share/nano/nftables.nanorc
include /usr/share/nano/spec.nanorc
include /usr/share/nano/elisp.nanorc
include /usr/share/nano/ruby.nanorc
include /usr/share/nano/go.nanorc
include /usr/share/nano/nanohelp.nanorc
include /usr/share/nano/default.nanorc
include /usr/share/nano/json.nanorc
include /usr/share/nano/css.nanorc
include /usr/share/nano/mgp.nanorc
include /usr/share/nano/asm.nanorc
include /usr/share/nano/mutt.nanorc
include /usr/share/nano/javascript.nanorc
include /usr/share/nano/postgresql.nanorc
include /usr/share/nano/rust.nanorc
include /usr/share/nano/fortran.nanorc
include /usr/share/nano/cmake.nanorc
include /usr/share/nano/makefile.nanorc
include /usr/share/nano/html.nanorc
include /usr/share/nano/changelog.nanorc

Using Tar and Gzip:

tar -zcvf output_file_name[.tar.gz or .tgz] directory_to_compress

tar -Jcvf output_file_name[.tar.xz] directory_to_compress
reads compression level for XZ from environmental variable, but note that xz utils is not installed by default on ubuntu 10.04

tar -xvf works to extract .tar.gz file created like in the above

The Tar and Gzip commands use compression settings specified in .bashrc

export GZIP=-9

export XZ_OPT=-9

Add the following to .bashrc for a console calculator:

calc() { echo "$*" | bc -l; }

For the ll alias, use the following in .bashrc

alias ll='ls -alF'

To change the terminal name use the following in .bashrc.  The command differs depending upon which version of Gnome one uses.

# For older versions of gnome-terminal
#shellrename() { read -p "Enter new shell name: " name && PROMPT_COMMAND='echo -ne "\033]0;${name}\007"'; }
# Works on OpenSUSE 15.3
#PS1=$PS1"\[\e]0;test1\a\]"
shellrename() { read -p "Enter new shell name: " name && PS1=$PS1"\[\e]0;${name}\a\]"; }

To obtain a uuid, add the following to .bashrc:

uuid() { UUID=$(cat /proc/sys/kernel/random/uuid) && echo $UUID;

Zen Burn color scheme for the terminal, but sometimes causes problems with work via SSH.

# Zen Burn
# Another old way that works great in gnome-terminal while causing problems
# in some configurations involving SSH:
echo -ne '\e]12;#BFBFBF\a'
echo -ne '\e]10;#DCDCCC\a'
echo -ne '\e]11;#3F3F3F\a'
echo -ne '\e]4;0;#3F3F3F\a'
echo -ne '\e]4;1;#705050\a'
echo -ne '\e]4;2;#60B48A\a'
echo -ne '\e]4;3;#DFAF8F\a'
echo -ne '\e]4;4;#506070\a'
echo -ne '\e]4;5;#DC8CC3\a'
echo -ne '\e]4;6;#8CD0D3\a'
echo -ne '\e]4;7;#DCDCCC\a'
echo -ne '\e]4;8;#709080\a'
echo -ne '\e]4;9;#DCA3A3\a'
echo -ne '\e]4;10;#C3BF9F\a'
echo -ne '\e]4;11;#F0DFAF\a'
echo -ne '\e]4;12;#94BFF3\a'
echo -ne '\e]4;13;#EC93D3\a'

Circa 2015: Adding Windows to CentOS 7 and Grub 2 after installing CentOS and no automatic configuration of Windows boot options. The file to manually edit is /etc/grub.d/40_custom.

menuentry "Windows 10 Professional" { set root=(hd0,1) chainloader +1 }

After editing, update Grub and reboot using the following command.

grub2-mkconfig –output=/boot/grub2/grub.cfg

The following shows one of the custom file contents circa 2018 or 2019 after some changes to installers and autodetection.

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the menu entries you want to add after this comment.
# Be careful not to change the 'exec tail' line above.
menuentry "Windows (system) (on /dev/sda1)" --class windows --class os { insmod part_msdos insmod ntfs insmod ntldr set root='(hd0,msdos1)' ntldr ($root)/bootmgr}

Minecraft Tweaks

To launch

java -Xms2048M -Xmx2048M --add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -jar server-1.21.1.jar nogui

Synchronize time on CentOS 6

This will start the time service and synchronize the clocks on CentOS 6.

yum install ntp 
chkconfig ntpd on 
ntpdate pool.ntp.org 
/etc/init.d/ntpd start