Backup Files with Specific File Extension
Here is how you can use rsync to backup only the .ogg files in the Music directory to the OGG directory:
$ rsync -a --prune-empty-dirs --include='*/' --include='*.ogg' --exclude='*' Music/ OGG/
Some sed Tips
Put an * between the number 5 and 6
$ echo '12345678901234567890'| sed -e 's/^.\{5\}/&*/'12345*678901234567890
Put a comma between each number
$ echo "1234567890" |sed -e 's/./&,/g' -e 's/,$//'1,2,3,4,5,6,7,8,9,0
Put comma after every 2, if not even then last number exist by itself
$ echo "1234567890" |sed -e 's/../&,/g' -e 's/,$//'12,34,56,78,90
Slackware Current: Minimal Installation
I’ve been looking for a way to install a minimal version of Slackware (current) in a VM and the smallest that I’ve safely come up with so far is this:
- Package group A
- Package group AP
- Package group D
- Package group F
- Package group K
- Package group L
- Package group N
I will try to get it smaller but I need this startup environment for another experiment so I’ll settle for this. Yes, it is still a wopping 12GB. Geez…
Red Hat Subscription Service
Once you have installed RHEL 9, register your RHEL subscription by running the following command on the terminal. The username and password are the login details to your Red Hat account.
$ sudo subscription-manager register --username=username --password=password
To confirm that the system is registered to Red Hat Subscription Management (RHSM), run the command:
$ sudo subscription-manager list --installed
Then refresh and subscribe:
Speed Up DNF Package Manager
You can increase the download speed for installing packages using DNF by updating the maximum number of simultaneous package downloads.
Start by editing the /etc/dnf/dnf.conf file:
$ sudo nano /etc/dnf/dnf.conf
Add the following line to enable DNF parallel downloads:
max_parallel_downloads=10
Another option is to select the fastest mirror from the Fedora public mirrors by adding the following line:
fastestmirror=True
Creating a Python requirements.txt File
This can be done quickly by typing:
$ pip freeze >requirements.txt
at the command line.
To install packages using a requirements file just use pip:
$ pip install -r requirements.txt
To check if the packages in your requirements.txt file are up-to-date use:
$ pip list --outdated
and to update those packages:
$ pip install -U <packagename>
Python: Initializing a New Project using venv
Start out by creating a new directory or cloning a repository (which creates a directory) and cd into it:
$ git clone https://gitlab.com/username/proj-name$ cd proj-name/
Initialize the virtual environment:
$ python3 -m venv venv$ source venv/bin/activate
Install whatever dependencies you need:
$ pip install package1 package2
Then develop and/or run your program:
Printing Numbers using Thousand Separators
You can use a pipe to awk to output numbers with thousands separators (commas). For Example, here’s how you can total the 5th column of the ls -l command and print it with thousands separators:
$ ls -l | awk '{total = total + $5}END{print total}' | LC_ALL=en_US.UTF-8 awk '{printf("%'"'"'d\n", $0) }'21,387
This can be adapted to other commands as necessary.
GCC can't find stdio.h in Alpine Linux
A while ago, I installed the iSH app on my iPad which made it possible for me to develop Python and C code as well as use it as an SSH client. However, I ran into an issue when trying to compile C code because the compiler couldn’t resolve stdio.h. The following excerpt from StackOverflow resolves the issue:
Install libc-dev in addition to GCC, or just install build-base for everything (alpine-sdk is probably an overkill). To install run the following command:
Ubuntu: Disable cloud-init on Startup
In systems that use systemd and have a current (17.0+) version of cloud-init, upstream documentation describes the process for disabling cloud-init with either of the following:
* touch /etc/cloud/cloud-init.disabled
or,
* add cloud-init=disabled to the kernel command line.