Browsed by
Category: BASH

“XDG_RUNTIME_DIR is invalid or not set” on Raspberry Pi 5

“XDG_RUNTIME_DIR is invalid or not set” on Raspberry Pi 5

Recently, while running Rasperry Pi OS (lite) on my sparkly new Raspberry Pi 5 I ran into an issue running the MPV media player. I had created two user accounts, one to log into the Pi with and another to run my program under. I then encountered a strange problem with MPV. MPV output the following error to the console: So… what the heck is that? Can this new user not output to my screen? Sufferin’ suckatash… Looking up the…

Read More Read More

Merge (or Resize) the /home partition on CentOS 7

Merge (or Resize) the /home partition on CentOS 7

CentOS7 by default partitions your storage by putting a large amount of space in the /home directory partition. For most use-cases, this is perfectly fine. However, if you’re working with limited space, and have already installed a default install of CentOS, you may find you need to reclaim some of the space in your /home parition for use with other partitions. Before continuing, you will want to MAKE A BACKUP OF YOUR /HOME DIRECTORY if there’s anything in it you…

Read More Read More

Quick Random Password Generator for Perl

Quick Random Password Generator for Perl

Mostly writing this for my own future benefit, but if this can help someone else in the process, perfect. Basically, create random strings of random sizes using random characters until the size of the resulting string is greater than 16. Pretty simple. #!/usr/bin/perl my @alphanumeric = (‘a’..’z’, ‘A’..’Z’, 0..9,’!’,’_’,’-‘); my @numeric = (0..9); my $randpassword = ”; until ( length($randpassword) > 16 ) { $randpassword = $randpassword . join ”, map $alphanumeric[rand @alphanumeric], 0..(rand @numeric); } print “$randpassword\n” Save the…

Read More Read More

Howto: Mass Rename File Extensions in Linux/BASH

Howto: Mass Rename File Extensions in Linux/BASH

Just recently I had a bunch of HTML files (files with a .html extension) that I wanted to rename to .cfm so that they would be interpreted by a CFML engine. To do this, I created a quick BASH loop and ran it directly in the command line: for i in *.html; do mv $i `basename $i html`cfm; done The semi-colons at the end of the first two lines will tell bash that you want to enter more commands, and…

Read More Read More

BASH Execute a Command in a Variable – with Quotes!

BASH Execute a Command in a Variable – with Quotes!

Just recently I encountered a situation where I was using a BASH script to evaluate some input and then pass a boat-load of parameters to another executable. It just so happened that one of the parameters I was pasisng was a variable that had a space in it. So… –myvar “my spacey attribute”. This command would work great when I ran the command myself, but as soon as I tried to execute the command in my BASH script, the blasted…

Read More Read More

BASH – Generate a Random String

BASH – Generate a Random String

In a recent project, I needed a function that would generate a random string for me. In my case, I was creating a random file name to store some data, but there are other uses as well, so I am posting the BASH code here in the hope that it will help others out ther eon the net writing BASH scripts and need a good random string function: #!/bin/bash function randomString { # if a param was passed, it’s the…

Read More Read More