Welcome to LinuxScrew

A site for Linux lovers worldwide. For newbies, system engineers, administrators, and everybody in between. We cover all things Linux, plus various programming languages, including Python, Javascript, and PHP.

View our featured tutorials and projects in the slider below or scroll down to see all recent articles.

How to Convert a USB Printer to Wireless with a Raspberry Pi
How to Use a Raspberry Pi for Digital Signage
The Worst Things You’ll Probably Google As a Programmer on Linux
How to Build a Raspberry Pi Internet Kiosk
Browsing the Internet on a 1989 Macintosh II with a Web Rendering Proxy
previous arrow
next arrow
Slider

Getting the Absolute (Full) and Relative Path In Linux

Absolute Paths in Linux

This article explains absolute paths and how they differ from relative paths, getting them, and how symbolic links are handled. FileSystem Paths A path is the location of a file in a file system. It’s the directions to the file in the folder it is located. A path consists of a string of characters. Some represent directory names, and a separator character separates the directory names from the file name and extension. Consider the below path: /path/to/my/file.txt It consists of: Forward slashes (/) to separate directories from their subdirectories … Read more

Redirect stdin, stdout, stderr in Linux/Bash, With Examples

Redirect stdin, stdout, stderr in Linux & Bash

The Linux/Bash shell has three data streams that you can tap into when executing commands – stdin, stdout, and stderr. Here’s how to use them. stdin, stdout, stderr allow for the display of text in the console, and the data being output each stream can be directed into other programs. These are referred to as Standard Streams. What is stdin (Standard Input)? Text input stream. Applications can accept text via stdin as input. What is stdout (Standard Output)? The text output stream of a program. Applications send data to other programs (or to the console for viewing) via stdout. … Read more

Remove a User From the Linux Command Line/Shell – How to Do It

Linux Remove User

Here’s a short and sharp article on how to remove a user from a Linux system. These examples will work on the majority of Linux distributions. The userdel Command The userdel command can be run from the Linux shell to remove a user. Here’s the syntax: userdel OPTIONS USERNAME Note that: OPTIONS should be from the below table USERNAME should be the login username of the user to be deleted userdel requires administrative rights and will need to be run as root or using the sudo command BE AWARE – RUNNING ANY userdel … Read more

Why You Should Use Linux in 2021

Why Use Linux 2021

Here’s a bunch of reasons to try out (or continue using) Linux in 2021. Lots has changed on the Linux front in the last decade – here’s why you should give Linux a go. I’ve been using Linux on desktop computers since the early 2000s – starting out with Corel Linux. Early distributions had big fallbacks for the average user – mostly to do with compatibility with Windows machines. While it was already best-in-class for running servers and developing software, creating and sharing images and … Read more

Calculating Absolute Values in Python, With Examples

Python Absolute Value

In this article, you’ll learn about absolute values – what they are, how they’re used, and how to use the Python abs() function to calculate them. What is the Absolute Value of a Number? The absolute value of a number is that number’s value without any regard to its sign. A number’s sign is whether it is positive or negative. So, the absolute value of a number is never negative. To make it simple, consider the absolute value of a number that numbers distance from 0. It is also referred to in mathematics and … Read more

Concatenate Strings in Bash/Shell Scripts, With Examples

Bash Concatenate Strings

Here’s a short article on concatenating (merging) strings in Bash – the right way. Examples included. There are various ways two or more strings could be joined in a shell script. Various programs will accept strings and return them merged/concatenated – but using the side-effect of a programs operation to concatenate strings is a bit of a waste of time, so this article will focus on the simplest, most readable method. Inserting a String into Another A string can be inserted when creating another string … Read more

Command Line Arguments in Python Scripts, With Examples

Python Command Line Arguments

This article will show you simple methods to pass command line arguments to your Python scripts, with some examples. Passing arguments to your script makes it easy to build multi-use scripts that can work on different inputs. This is much easier than re-editing your code every time you want to change the inputs it will be working on. I’ve previously covered building a full command-line application in Python, which accepts command-line options and bundles the application into a distributable package with no external dependencies – … Read more

PHP include – How to Use It, With Examples

How to use PHP include

The PHP include expression allows you to import code from another file and import code from external PHP libraries. Here’s how to use it, with examples. PHP include will execute and import PHP code from another file or library.  It allows you to re-use code and work with libraries provided by others – for example, you may download a library to interact with a mapping service and wish to include it in your code. Syntax include ‘./path/to/file.php’; Simple! The include expression must be followed by the … Read more

Categories PHP

JavaScript Callback Functions How-To, With Examples

JavaScript Callbacks

This article will explain callback functions in JavaScript – what they are, why they’re used, and how to use them. What is a Callback in the JavaScript Programming Language? A callback function is a function that is passed as a parameter to another function to be executed from within the second function. What are Callbacks Useful For? Callback functions are usually used to execute a function when another has been completed. This allows for easy code- reuse. A single function that accepts a callback can be … Read more

Math/Arithmetic in Bash/Shell Scripts, With Examples

Bash Math & Arithmetic

Math is easy, Bash scripting is easy, so performing math/arithmetic in Bash/Shell scripts should be easy too. It is. Here’s how to do it. Working with Integers Bash’s built-in arithmetic can only handle integer (whole number) values. If you attempt to declare a variable with a non-integer value: declare -i e=2.5 You’ll see the following: bash: declare: 2.5: syntax error: invalid arithmetic operator (error token is “.5”) To work with non-integer numbers, you will need to use an external program to perform your calculations – but first, … Read more