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

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

The MySQL/MariaDB ‘SHOW INDEX’ Statement, With Examples

MySQL SHOW INDEX

This article shows you how to use the MySQL SHOW INDEX statement to list the details of indexes and keys in a table. To use the SHOW INDEX statement, you will need to know which database and table you wish to view index information for. Looking to list the databases and tables on your system? What Are Indexes? Indexes are a tool that allows a database to quickly lookup data in a table for a certain column. Usually, when searching a table, the database software must read every row in … Read more

The MySQL/MariaDB ‘DISTINCT’ Statement, With Examples

MySQL Distinct

The MySQL DISTINCT operator returns only unique values from a column from a database table; duplicates are not returned.  Here’s how to use it. The DISTINCT operator can be useful in many scenarios; for example, you may want to generate a list of countries you have shipped to, or you may want to provide a drop-down menu containing unique product options for the user to select. Example Usage of MySQL DISTINCT Examples will use the following table: table_orders: order_id shipping_country product_category 1 Australia soap 2 China … Read more

The MySQL (and Maria DB) TRUNCATE Command, With Examples (And Warning!)

MySQL Truncate

MySQL (and its functional equivalent, MariaDB) have two things named TRUNCATE – so watch out which one you want to use or suffer dire consequences! This article outlines the difference and usages of the MySQL TRUNCATE function and TRUNCATE TABLE statement – they share similar names but do very different things. TRUNCATE Function – Truncating a Number to a Certain Number of Decimal Places First, the TRUNCATE function. The TRUNCATE function reduces the number of decimal places for a given number. MySQL TRUNCATE Function Syntax TRUNCATE(number, decimals) Note that: number is a number decimals is an integer … Read more

The Difference Between JavaScript and Node.js – Which Should I Use?

JavaScript vs Node JS

This article explains JavaScript and Node.js and their relationship with each other. What is JavaScript? JavaScript has become one of the most popular programming languages for building web applications and has even become a contender for building solid desktop and mobile applications. In the browser, there is no competitor – browsers run JavaScript for their client-side code- allowing them to pop up windows, disable buttons, animate screen elements, and retrieve data. This is what JavaScript was built for. What is it Good For? JavaScript Runs … Read more

isdigit(), isalpha() and Other Checks in Python, With Examples

Python isdigit isalpha

Both Python versions 2 and 3 provide several helpful string methods that let you find the string’s contents.  Here’s how to use them. The functions in this article are useful if you want to validate user input – for example, you may want to check that a user-inputted string is a valid number before converting it to a number variable to prevent errors and warn the user that they need to try again. isdigit() and isalpha() are commonly used methods to identify a string’s contents, but … Read more

How to Round Numbers Up/Down/Nearest in Python

Python Round Numbers

This article will show you how to round numbers up, down, and to the nearest 1, 10 100 (or any number) in the Python programming language. Truncation vs. Rounding Truncation isn’t technically rounding, but it serves a similar purpose, so I’ll include it here. It’s the simplest way to shorten a number – just cutting off the characters at the end until it’s in the format you require. Rounding gets the nearest number, whereas truncation cuts off digits from the number. For example: To round 2.9 to … Read more

Checking If A File Exists in Python, With Examples

Checking if a File Exists in Python

This article will outline several methods which can be used to check that a file exists/is readable in the Python programming language. You may wish to check whether a file exists before reading or writing to it to reduce the number of alerts you need to display to the user or to make sure you aren’t accidentally overwriting an existing file (or a combination of both, letting the user know a file already exists and giving them a choice to overwrite it). Using pathlib to Check if … Read more

How to use the PHP parse_url() Function, With Examples

PHP parse_url

The PHP parse_url() function processes a given URL and divides it into its individual components.  Here’s how to use it. parse_url() is often used to get the host/domain name from a given URL or the path to a remote host file. Syntax for parse_url() parse_url ( $url , $component ) Note that: $url is the URL (e.g., https://www.linuxscrew.com) which you want to parse Relative URLs may not be parsed correctly $component is optional and can be one of: PHP_URL_SCHEME, PHP_URL_HOST, PHP_URL_PORT, PHP_URL_USER, PHP_URL_PASS, PHP_URL_PATH, PHP_URL_QUERY or PHP_URL_FRAGMENT … Read more

Categories PHP

What is the ‘this’ Keyword in JavaScript (Object-Oriented Programming)

JavaScript 'this'

The ‘this‘ keyword in JavaScript is a confusing concept for some – the meaning of ‘this‘ changes based on context.  This article explains what ‘this‘ is. What is Object-Oriented Programming Object-Oriented Programming is a way of structuring your code so that data is organized into objects. JavaScript supports Object-Oriented programming and provides various tools to help implement it. Put simply, rather than having a bunch of separate abstract variables describing an item, you combine them into a single object which represents that item. You can also add functions … Read more