Home » Linux

Variables in Bash/Shell Scripts and How To Use Them [Tutorial]

Bash Variables and How to Use Them

This article will show you how to use variables in Bash and Shell scripts in Linux. Bash (or Linux Shell) scripts are files you write containing commands to automate common tasks and save yourself some time. Variables are things in scripts that hold a value for later use – a number, or a filename, or anything, really. Here’s how to define and use variables in Linux Shell scripts. These examples should work in the most popular Linux Shells, Bash, and Zsh. Declaring Bash Variables Bash VARIABLES ARE UNTYPED … Read more

Home » Linux

DIY Raspberry Pi/Python Powered PACHINKO [Kitchen Build]

Raspberry Pi Python Pachinko

Pachinko? Pichinko? Pychinko? I’ve been playing around with is idea for a while because… I don’t know; it seemed like a cool concept. That’s my whole motivation. Here’s a Raspberry Pi and Python-powered pachinko machine. This project is really basic, so it’s good for beginners, and the result is a lot of fun to mess with and would make a good desk ornament to fidget with or something for the kids to build on a rainy day to learn about coding and circuits and all … Read more

Home » Linux

How to Use Functions in Bash/Shell Scripts, With Examples

Bash Function Uses

This article will explain how to use functions in Bash scripts – helping you to reuse your code and simplify your scripts. Why write code multiple times when you can write it once and re-use it? That’s what functions let you do. This article outlines the use of functions in Bash/Shell scripts. What is a Function? A function is a piece of re-usable code. Functions can accept parameters, which allow them to perform the same repeatable actions on different inputs. Functions usually perform any action, output or print results, or return … Read more

Home » Linux

Using the ‘sed’ Command in Bash/Linux, With Examples

Bash sed command

The sed (Stream EDitor) command in Bash/Linux reads text from a stream or file and performs line-by-line operations on it based on a set of supplied criteria.  Here’s how to use it. sed is an automated way to process text. One simple example of where sed can be used is doing a simple find-and-replace for a word in a text document – the text with the words replaced can then be saved to a new file or overwrite the original. Why? Being able to modify text – either from a … Read more

Home » Linux

Using the ‘sleep’ Function in Bash Scripts, with Examples

Bash sleep Command

This article explains the sleep command in Bash/Shell scripts and how and why you might use it. The sleep command in Bash (and other Linux Shells) pauses execution for a specified amount of time – halting the script for a set number of seconds, minutes, hours, etc. Why Pause Execution? Why would you want to pause executing your script? Give the user a chance to interrupt an automated action Await user input Wait for a device to warm up/become available Stop text from flying across the screen if you’re trying to … Read more

Home » Linux

How to List Users and Groups in Linux, With Examples

Linux List Users Groups

Linux supports multiple users and groups, allowing access to be granted to only the resources required.  Here’s how to list users, groups, and group membership. Separating users and groups ensures that different people can’t accidentally interfere with each other’s files and ensures system security by denying access to vital system files. This article details the various ways to query the users and groups on a computer running a Linux Operating System. Listing All Users The /etc/passwd file is a text-file database containing information on all of the users … Read more

Home » Linux

How to Change the Hostname in Linux (Debian, Ubuntu, Arch, RedHat)

Linux Change Hostname

This article will show you how to change the hostname for your Linux device (Debian, Arch, Ubuntu, or RedHat). The methods below should work for the vast majority of current and obsolete Linux Distributions. What is the Hostname? The hostname of a device on the network is the human-readable label of the system. It can be used to identify or connect to a system on the network instead of connecting to it via an IP address. Displaying the Current Hostname Regardless of your distribution, you can find out … Read more

Home » Linux

Raspberry Pi & Python Powered Tank Part III: More Tank

Python Powered Tank Part III More Tank

This was only meant to be a two-parter, but I couldn’t leave well enough alone. Raspberry Pi & Python Powered Tank Part III is an update with better Python code and an improved design. I’ve gone back to fix the biggest issues that were left after Part II. I’ve omitted a bit of the mucking about in this article to keep it focused on what worked. How Did We Get Here? If you haven’t yet checked out the full build process, here are the previous … Read more

Home » Linux

DIY Arduino Powered Soldering Extraction Fan

Arduino Fan

This article will show you to build a DIY soldering extraction fan (to ventilate fumes) using an Arduino and a temperature sensor to activate the fan when the soldering iron is hot. Before you read this, why not open up my other projects in some new tabs for further reading when you’re done? Smart Mirror Wikipedia Scraper Photo Resizer and watermarker Raspberry Pi Powered Palmtop/Laptop Raspberry-Pi augmented Apple Macintosh Python Powered Tank! The Project A thoughtful commenter on a previous article suggested I get an … Read more

Home » Linux

DIY Arduino Powered Electronic Morning Checklist

Arduino Morning Checklist

If you’re the sort of person who has to check the stove is off before leaving the house, then recheck it because you can’t remember if you checked it (and maybe even turn around at the front gate, unlock the door, go back inside and check a final time) – this might be the project for you. Before I get into it, if you haven’t already, check out the other projects I’ve built for LinuxScrew: Python Powered Tank! Python Powered Tank Part II Python Powered … Read more