Posts Tagged bash

LVM Part 2: Volume Groups

📅 April 1, 2024
We have our physical volumes created, but what do we do with them?

Can we format them? Can we store data on them?

No, not yet. A physical volume merely specifies a drive or partition that is to be used with LVM. The next step is to assign physical volumes to volume groups, and this is were the fun and flexibility of LVM becomes apparent.

Read the rest of this entry »

, ,

Leave a comment

Bash: Typed Variables with declare

📅 March 23, 2024
Variables are untyped in Bash by default, but there might be times when we need to create variables that hold only specific data types or have specific purposes.

The declare command allows us to achieve this in order to add extra protections on variables, and there are a few different types allowed.

Need a variable that only stores lowercase strings? How about an integer only and reject all other values? Maybe you need an indexed or associative array? Perhaps you need to create a constant?

Read the rest of this entry »

,

Leave a comment

Bash: The let Keyword

📅 March 18, 2024
JavaScript has the let keyword that creates a variable with scope.

Bash has the let keyword too, but it serves a different purpose.

Read the rest of this entry »

,

Leave a comment

What is nohup?

📅 March 17, 2024
“Help! I need to keep a program running after closing the terminal.”

There can be times when we connect to a remote system via SSH, for example, and we need to run a lengthy process on the remote system. However, we also might need to log out or close the connection, but we want the process to continue running.

Normally, the process terminates when the terminal is closed.

nohup is a way to keep a remote process running even after the terminal is closed.

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

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