Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

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

Home » Linux

Office Software for Linux/Ubuntu – What are the Options?

Office For Linux

This article will cover some options for office productivity software for Linux. Microsoft Office dominates the office productivity space – it’s the industry standard. If you’re in business, other businesses probably expect to be able to send you an Excel or Word file and for you to be able to view or edit it. Microsoft Office, of course, does not run on Linux (unless you want to run an ancient version under emulation). It’s also not open-source or free. Here are some of the best alternatives … Read more

Home » Linux

How To Run Commands in the Background [Linux/Ubuntu]

Linux Ubuntu Run Command in Background

This article will show you how to run commands in the Linux (including Ubuntu) shell background. This is useful when working remotely via SSH. Say you’re connected remotely via SSH to a remote computer, and you want to execute a lengthy task. While the task is running, usually, you’d have to keep the connection open, with the terminal window open. However, this can be a hassle if you need to close the window to perform another task or if you have a spotty internet connection … Read more

Home » Linux

The tr Command in Linux – What It Is and How To Use It

Linux tr Command

The tr (translate) command in Linux reads text from standard input, performs some modification to the text, and then sends it to standard output. This article explains and shows why and how you might use it. tr Command Syntax Here’s the syntax you’ll need to use the command: tr OPTIONS SET1 [SET2] Note that: OPTIONS should be a list of options from the below table The characters in SET1 will be replaced with the characters in the corresponding position in SET2 These are optional – some of the OPTIONS are capable of performing translations, … Read more

Home » Linux

How to Use the which Command in Linux, With Examples

Linux which Command

This tutorial will teach you how to use the which command in Linux with some simple examples. The which command will tell you the path to the executable used by a command on the system if it exists. Why is this useful? Say you’ve got two copies of the MySQL executable installed on your system (installed via different means), and you want to know which one is actually in use so that the other can be removed – the which command can tell you which of the two is called when you execute MySQL on … Read more