Home » Articles by: Brad Morton

The Linux Shutdown (& Reboot) Command

Linux Shutdown

The shutdown command in Linux shuts down your computer safely. All users and processes will be notified, and processes are given the chance to exit safely. The shutdown command can also reboot and bring the system to other power levels. Syntax shutdown [OPTION]… TIME [MESSAGE] Options Here are the available options for the shutdown command, straight from the manual: Option Description -r Requests that the system be rebooted after it has been brought down. -h Requests that the system be either halted or powered off after it … Read more

Home » Articles by: Brad Morton

Best Media Server Software for Linux [2021]

Best Media Server Software for Linux

Find the best media server software for Linux in 2021 with a built-in web client, native client, support for multiple formats, and more. Home media servers have become increasingly popular and there are a number of commercial and free options. Media servers are also a popular project for people tinkering with Raspberry Pi’s, can be a cool introductory project for people getting started in Linux and networking, or can just be a good way to put an old computer to use. Home media servers can … Read more

Home » Articles by: Brad Morton

How to Check if a File or Directory Exists in Bash [+ Examples]

bash check if file exists

You can check whether a file or directory exists on a Linux system using the test command in bash. See our examples below to find out how. The test Command Syntax test EXPRESSION The test command will evaluate the EXPRESSION. Expressions can be built using the following operators and can be built using a combination of operators. -d file True if file is a Directory. [[ -d demofile ]] -e file True if file Exists. [[ -e demofile ]] -f file True if file is a regular File. [[ … Read more

Home » Articles by: Brad Morton

Building a Python Script to Resize & Watermark Images [Code Included]

Building a Python Script to Resize Watermark Images

In this project, we take you through building, packaging, and publishing a command-line application using Python to resize and watermark images. Whenever I complete an article for LinuxScrew, I need to go through and add watermarks and make other small adjustments to any photos I’ve taken. This can be tedious so I thought, why not automate it. Then I thought, why not make a command-line app to do it (rather than just a bash script), and show you how you can make your own command-line … Read more

Home » Articles by: Brad Morton

Guide to Foreign Key Constraints in MySQL and MariaDB [With Examples]

Guide to Foreign Key Constraints in MySQL

In this guide, we cover foreign key constraints in MySQL and MariaDB, along with a number of useful examples. MySQL (and its fork MariaDB) are Relational Database Management Systems (RDBMS) – Database Systems which hold data in tables which can be related to each other. Tables in an RDBMS are organized into columns that contain data in rows (also called tuples). Each row will usually have a Primary Key – a unique value to identify the row in the table. To define relationships between two rows in two different … Read more

Home » Articles by: Brad Morton

Quickly and Easily Outlining Text in GIMP 2 [3 Easy Steps]

outline text in gimp 2

Here’s a quick 3-step method for outlining text in GIMP 2. GIMP is the most popular photo manipulation and image editing package for Linux. Many tutorials go through a long-winded process of converting the text to paths and expanding selections, but in the end, if you want quick results, this is the method to use. Step 1: Write some text using the text tool Click on the text tool in the toolbox, and write some text to outline. Step 2: Select the Text by Colour … Read more

Home » Articles by: Brad Morton

Python “while” Loops [with Examples]

python while loops

This tutorial explains how to create loops in Python by using the “while” statement. Included below are the syntax and examples. In programming (and thus, in Python), a loop is a statement which will execute a block of code repeatedly until a condition is met, or the loop is broken out of manually. This article will look at Python Loops and conventions to use when writing them. Looping with the while statement, Syntax and Example Here is a basic loop which will increment (add 1) the variable ‘i’ … Read more

Home » Articles by: Brad Morton

Python time.sleep() to Pause, Sleep, Wait or Stop a Python Script

Pause Sleep Wait or Stop a Python Script

There is a useful function in Python called ‘sleep()’. It’s part of the ‘time’ module and allows you to pause, sleep, wait, or stop a Python script or application. Python can be used to make useful command-line tools to streamline your workflow, but sometimes you need to wait for the user, or for a pre-defined amount of time. For example, you may want to prompt the user to press a key when they have finished reading instructions or give them time to override a default … Read more

Home » Articles by: Brad Morton

Python List ‘sort()’ Method – Sorting Lists in Python Easily

Sorting Lists in Python Easily

In Python, there’s an easy way to sort lists: using the sort() method. This tutorial explains how to use sort(), with examples. We’ve covered the following in Python: Removing list items Checking if items are in lists Finding items in lists Now it’s time to find out how to sort a list. Syntax for the sort() Method list.sort(reverse=True|False, key=sortFunction) Note that: ‘reverse’ should be a True/False boolean value and is optional reverse=True will sort the list descending The default is reverse=False True/False values case sensitive in Python! … Read more

Home » Articles by: Brad Morton

Python: Find in a List and Return Values [using ‘filter’]

Python Find in a List and Return Values

This tutorial explains how to find items within a list in Python and return the values, using “filter”. Previously we covered checking whether items exist in a list in Python, but that could only tell us whether they were present, or not (with a boolean return value containing the result). If you are searching a list for a specific value, you already know what the value of the matching items will be so the above method is sufficient. However, what if you are searching by a set of … Read more