Home » Linux

Linux diff – How to Show Differences and Make Patches, With Examples

Linux Diff Command

The diff command is an easy way to compare files or directories from the Linux shell. This article will show you how to use it, with some examples of common usage. The diff command performs a line-by-line comparison of two files or directories and outputs the differences between them. Why would you want to compare files or directories? You might have two files with the same name that look similar and want to see the difference between them. Comparing changes to the programming code in a project you’re … Read more

Home » Linux

Recover Deleted Files in Ubuntu/Linux, With Examples

Ubuntu Recover Deleted Files

We’ve all been there (I’ve been there) – a file was deleted that shouldn’t have been. Here is how to attempt recovery on Ubuntu/Linux. with examples. Backup Your Files First up, keep backups of your files, and keep your backups up to date. The easiest way to recover a file is not to have to try to recover it at all – you can just go and retrieve it from your backup. No fuss. No stress. No praying. How Deleted Files are Recovered When a file … Read more

Home » Linux

cat Command in Linux/Bash – How to Use It, With Examples

cat Command Linux Bash

The cat (concatenate) command in Linux/Bash is most commonly used to read the contents of a file. It outputs the contents of a given file. Here’s how to use it. cat concatenates files to standard output – by default, this is to the console for viewing on your computer screen. This makes it useful for quickly viewing the contents of files. It also has other uses, but first, the syntax: cat Syntax cat [OPTIONS] [FILE] Note that: If FILE is not specified, will read from standard input (stdin) Multiple FILEs can be specified, separated by … Read more

Home » Linux

Running Ubuntu in VirtualBox on Windows/Mac [Tutorial]

Running Ubuntu In VirtualBox

Here’s a straightforward set of instructions (with lots of screenshots) on how to set up Ubuntu Linux in VirtualBox for running Ubuntu in a Virtual Machine on Windows 10 and macOS. VirtualBox allows you to set up and run virtual machines on your computer easily.  A virtual machine is a whole computer, virtualized running on top of your current operating system – allowing you to try out and experiment with new operating systems and tools without reformatting your computer. Download and Install Virtualbox The first … Read more

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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