Archive for February, 2024

Intro to Python Multithreading

📅 February 23, 2024
Multithreading allows your Python script to perform more than one thing at the same time. This is called concurrency, and it can be used to help make your programs more efficient and speed up their apparent execution…somewhat.

Python provides the threading module, so you can run multiple functions simultaneously. It is pretty cool stuff, but the world of concurrency opens an entirely new set of issues to deal with.

Let’s write a simple Python script that runs the same function multiple times — simultaneously — to show how to perform multithreading in Python.

Read the rest of this entry »

,

Leave a comment

Bash: Read JSON File to Add Many Users

📅 February 22, 2024
“Can Bash parse a JSON file?”

Yes, but not natively like Python can using the json module.

Parsing a JSON file from a Bash script usually involves writing custom code that parses strings and such, but there is a handy program call jq that handles the details of JSON parsing for use.

Suppose we want to add a batch of user accounts, each user with a unique password and assignment to a Linux specific group. This involves more user information that a simple username with a temporary common password. We can store this user information in a JSON file, and then let a Bash script process the user data from the file to create the users.

Here is one way to achieve this.

Read the rest of this entry »

, , ,

Leave a comment

Add New Users from a Text File

📅 February 21, 2024
“I have a LOT of users to add, but I do not want to add them one by one. Can I use a script?”

Yes! This is what Linux specializes in. We can write a script that reads a list of usernames from a text file to create these users on a given system and assign them all a default password.

Here is one way to achieve this magic.

Read the rest of this entry »

, ,

Leave a comment

How to Change Your Linux Hostname

📅 February 18, 2024
“How do I change the name of my computer without reinstalling it?”

The name of your Linux computer is called a hostname, and it can be changed anytime by the administrator.

Most of the time, the name you assign to your Linux installation need never be changed, but there are situations where this is necessary. For example, duplicating VMs or accidental duplicate naming by two different people. If you use LibreNMS, then you cannot add devices with duplicate hostnames. Therefore, a hostname might need to be changed.

No, you do not need to reinstall your entire OS. In fact, it is easy with a few commands and a reboot. Here are two ways to rename the hostname.

Read the rest of this entry »

, ,

Leave a comment

Bash2048 – A 2048 Game in the Terminal

📅 February 12, 2024
Remember the game 2048? Let’s play it in a terminal!

Here is a fun variation on the addictive “How far can you go?” number combining puzzle game — but from a bash script.

Read the rest of this entry »

, , ,

Leave a comment

cmatrix – Falling ASCII Characters

📅 February 9, 2024
“I want to impress others who look over my shoulder.”

In a world of point, click, and swipe, nothing scares people like the command line.

Well, let’s put some real fear into them with cmatrix!

Just let this run in its own terminal adjacent to BpyTOP or bmon to geek out your desktop.

Read the rest of this entry »

,

Leave a comment

asciiquarium – The Cutest Lil’ Aquarium for your Terminal

📅 February 5, 2024
“What? An animated ASCII art aquarium that runs in a terminal? Yes!”

ASCII art is fun, but animated ASCII art is even more impressive. Why not brighten your day with a secondary terminal filled with marine life as you use Linux?

ASCIIQuarium is one of those rare gems that few seem to know about but always provides hours of entertainment in the background once discovered. It is as essential as sl, cowsay, and fortune, so why not?

Let’s have fun!

Read the rest of this entry »

, ,

Leave a comment

Monitor Network Connections with nmcli

📅 February 4, 2024
If you use a Linux distribution, such as Ubuntu or Linux Mint, then you probably have NetworkManager installed. NetworkManager handles network connectivity, and you have probably already interacted with it via a GUI interface when setting up a network connection from the panel.

But did you know that NetworkManager can also be controlled from the command line?

nmcli is the command-line tool that allows us to perform NetworkManager functions straight from the terminal. This is good news because it means we can script NetworkManager’s behavior as boot up tasks or cron jobs. In fact, we can use nmcli to show all current network connections in a custom gnome-terminal.

Here are a few examples for nmcli.

Read the rest of this entry »

, , ,

Leave a comment