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

Scopes & Global Variables in Python – Explained

Python Scopes & Global Variables

This article will explain and demonstrate scopes in Python – including the global scope and how to declare global variables. What is a Scope? As you move towards building more complex Python applications, you’ll be using functions, loops, try/except statements for error handling, and other more advanced constructs. Which variables are available within each of these constructs is defined by the variable’s scope. The scope is where the variable is available within your program. Different variables have different scopes, and totally distinct/separate variables in different scopes can share … Read more

Catch Errors/Exceptions in Python with try/except [Examples]

Python try/except to Catch Errors

This article will show you how to use the try/except/finally statements. What are Errors/Exceptions A computer program will produce an error, also known as an exception, when something goes wrong. This could be due to mistyped programming commands (syntax errors) or because the application encountered something unexpected – be it bad user input or a logical condition that can’t be met. When something goes wrong, an exception/error will be thrown – which will usually result in the application stopping and the error being displayed so that it can be found and fixed. … Read more

How to Write to a Text File in Python

Python Write File

This article will show you how to write to a file in the Python programming Language – examples included! All files are, essentially, text files. Data is formatted and stored in various ways – comma-separated values for spreadsheets (CSV), plain text for text files (TXT), all the way to complex image formats for storing documents and images like PDF and JPG files. Once the program you are building is up and running, you’ll want to be able to save the output it produces – so … Read more

Linux for Kids – Distributions, Fun Tools, Games & Learning

Linux for Kids

Want to keep the kids busy over the holidays? Get them interested in computing. It’ll keep them busy for the rest of their lives. Computing is a huge field that covers many different subjects and skills – programming, digital art, music-making, engineering – and understanding computing concepts is increasingly important, and it opens the way for learning about just about anything else one might want to learn. A computer can’t just be a tablet playing youtube videos – kids need to be able to understand … Read more

HEREDOC (Here Documents) in Bash and Linux Shell – Tutorial

Bash Heredoc

This article will show you how to use a Heredoc (Here Document) in Bash/Shell scripts to work with multi-line text. Heredocs are most useful for accepting multi-line input- the user can enter a line of text, press enter, then enter the next line, and so on. It can also be used to define multi-line text in scripts. It can also send multiple commands into an interactive program – this will be shown in the examples later. The examples in this article will work in both … Read more

Check Disk Health in Linux/Ubuntu [How To / Guide]

Linux Check Disk

Concerned that you have a failing hard drive? Make a backup. Then, use these Linux tools to check your disk/drive. Not concerned that you have a failing drive? Back up anyway. It could be failing, and you don’t know it. Or it could get stolen. Or a meteorite could hit it. Back. Up. Your. Files. What is SMART? S.M.A.R.T. (Self-Monitoring, Analysis, and Reporting Technology) is the system most hard disks use to report their health to the installed system. This information can be queried to find out whether a drive is … Read more

Using the printf Command in Bash/Shell, With Examples

Bash printf Command

This article will show you some practical examples for using the printf command in the Bash/Shell on Linux. The printf command outputs text much like the echo command does – but it allows for more control over the output formatting. It’s a useful tool for generating your own formatted text output – especially if you need to embed variables in text, include newlines, align and format text, and even display converted values. printf Syntax The printf command has the following syntax: printf [-v var] format [arguments]… Note that: The -v option … Read more

How to Prompt for User Input in Bash/Shell Scripts

Bash Prompt For Input

This short tutorial will teach you to prompt the user for typed input from your Bash/Shell scripts. It’s easy to learn, easy to do, so read on! The read Command To read user input in shell scripts, use the aptly named read command. It has the following syntax: read OPTIONS VARIABLES Note that: The read command will read a line from standard input and split that input into fields Usually, standard input is the terminal with input from your keyboard, but you can also pipe or redirect input to the read command From the users perspective, they will … Read more

How to Run a Program or Command On Login in Linux

How to Run a Program or Command On Login in Linux

This article will show you how to set up a command to run automatically each time you (or any user) log in on the Linux operating system. Several tasks may be useful to run on login – perhaps you want to connect to a network share or mount a USB drive each time you log in. You might even want to write a script that emails someone to let them know you’ve arrived at work safely and have it sent automatically when you log in. … Read more

How to Run a Script/Command on Startup on Linux/Ubuntu

How to Run a Script/Command on Startup or Login on Linux/Ubuntu

Want to run a program, command, or script when you start or log into your Linux OS? This article will show you how. Running Scripts on Startup with Crontab The best way to run a command whenever your system starts is using crontab. cron is the job scheduler used by Linux to schedule the execution of tasks. The crontab is the text file where those tasks are defined. There is a system-wide crontab file, and each user also has their own individual crontab file for scheduling their own tasks. Adding a System-Wide Startup … Read more