whois script to check many domains and TLDs at once

Check domain name availability with bash and whois

If you’ve ever tried to come up with a catchy domain name, you know how annoying it can be to keep checking to see if a certain name is available. Fortunately, on Linux we can make the task a little easier on us by using the whois command. When a domain is available, the output from whois will let us know that it’s not able to find any information for that domain.

It’s easy enough then to put this functionality into a Bash script, which helps to automate checking lots of different TLDs (Top Level Domains, like .com, .net, .org, etc).

In this guide, we’ll show how to check domain name availability from the command line on Linux. Then, we’ll give you a simple Bash script that you can copy onto your own system and check for lots of domains at once. Read on to learn how.

In this tutorial you will learn:

  • How to install whois on major Linux distros
  • How to check for domain name availability with whois command
  • Bash script for checking domain name availability

Read more

Replacing all tab characters with spaces on Linux

Replace all TAB characters with spaces

If you have a lot of tab characters inside a text document or program file, they can be annoying because of how they’re represented differently in various text editors. For example, when you send your code to someone else, is it going to display the same way on their screen as it did on yours? Tabs are a bit unpredictable in this respect, and spaces are a much safer bet.

In this guide, we’ll show how to replace all the tab characters inside a file with spaces on Linux. We can use various Linux commands to do the job for us, which we’ll go over below. Depending on your situation and the file in question, some commands may be more suitable than others.

In this tutorial you will learn:

  • How to replace tab characters with spaces

Read more

Configuring Gmail as a Sendmail relay on Linux

Configuring Gmail as a Sendmail email relay

Sendmail is email routing software that can allow Linux systems to send an email from the command line. This allows you to send email from your bash scripts, hosted website, or from command line using the mail command. Another example where you can utilize this setting is for notification purposes such as failed backups, etc.

In this guide, we’ll go over the step by step instructions to configure Gmail as a relay for the sendmail client on Linux. Note that Sendmail is just one of many utilities which can be configured to rely on a Gmail account. Others that are capable of this include postfix, exim, ssmpt, etc. The instructions here should work for any mainstream Linux distribution.

In this tutorial you will learn:

  • Gmail configuration prerequisites
  • How to install Sendmail and mail utilities on Linux
  • How to configure Gmail as a relay for Sendmail
  • How to test the config by sending an email from command line

Read more

Using the mv, rename, and mmv commands to rename files between uppercase and lowercase on Linux

Rename all file names from uppercase to lowercase characters

As a Linux user, you’re likely already familiar with using the mv command to rename a file on a Linux system. The task becomes a little more difficult when you need to rename multiple files at the same time on Linux.

One of the most common batch renaming jobs that are performed is to change all file names to lowercase letters. There are several different ways to do this on Linux. One way is with the native mv utility and a bit of Bash scripting, and the other methods involve the rename and mmv tools, which may or may not already be installed on your Linux distro by default.

In this guide, we’ll go over various command line examples to rename all files from uppercase to lowercase letters on Linux. Some commands will work only for files, some for directories, and some commands work recursively. Take a look at all the different examples below to decide which command(s) to use that would best suit your needs.

In this tutorial you will learn:

  • How to rename all files from uppercase to lowercase using mv, rename, or mmv commands
  • How to install rename and mmv on major Linux distros

Read more

ansible-logo

Ansible tutorial for beginners on Linux

A system administrator, in the vast majority of cases, has to take care of more than one server, so he often has to perform repetitive tasks on all of them. In these cases automation is a must. Ansible is an open source software owned by Red Hat; it is written in the Python programming lanaguage, and it is a provisioning and configuration management software which help us in the aforementioned cases. In this tutorial we will see how to install it and the basic concepts behind its usage.

In this tutorial you will learn:

  • How to install Ansible on the most used Linux distributions
  • How to configure Ansible
  • What is the Ansible inventory
  • What are the Ansible modules
  • How to run a module from the command line
  • How to create and run a playbook
ansible-logo

Read more

Various examples for removing duplicate lines from a text file on Linux

Removing duplicate lines from a text file using Linux command line

Removing duplicate lines from a text file can be done from the Linux command line. Such a task may be more common and necessary than you think. The most common scenario where this can be helpful is with log files. Oftentimes log files will repeat the same information over and over, which makes the file nearly impossible to sift through, sometimes rendering the logs useless.

In this guide, we’ll show various command line examples that you can use to delete duplicate lines from a text file. Try out some of the commands on your own system, and use whichever one is most convenient for your scenario.

In this tutorial you will learn:

  • How to remove duplicate lines from file when sorting
  • How to count the number of duplicate lines in a file
  • How to remove duplicate lines without sorting the file

Read more

Various Bash examples for redirecting standard output and standard error to the same file

Bash – Redirect both standard output and standard error to same file

The Bash shell is the most popular shell on Linux systems, and to use the shell efficiently, you need a little knowledge about Bash shell redirections. This is also an essential step in learning Bash scripting.

In this guide, we’ll show how to redirect standard output and standard error to the same file on the Bash shell command line. This will include several examples so you can pick the right method in any scenario.

In this tutorial you will learn:

  • How to redirect standard output and standard error to same file
  • How to redirect standard output and standard error to file and terminal
  • How to redirect standard output and standard error to /dev/null

Read more

Renaming multiple files at once on Linux

How to rename multiple files on Linux

Renaming files on Linux systems is usually handled by the mv (move) command. The syntax is just mv old.txt new.txt. Simple enough, but what if we have multiple files that need to be renamed at once, even hundreds of them? The default mv utility can’t handle renaming more than one file unless we do a bit of scripting. There are also other utilities we can install to solve the problem, like rename and mmv.

In this guide, we’ll show you how to use the mv command as well as the rename and mmv tools to rename multiple files on your Linux distro. We’ll go over several examples so you can understand the syntax and how to use each method.

In this tutorial you will learn:

  • How to rename multiple files at once with mv command
  • How to install rename on major Linux distros
  • How to install mmv on major Linux distros
  • How to use mmv, through command examples
  • How to use rename, through command examples

Read more

Appending text to a file in Bash on Linux

How to append to file on bash shell command line

The Bash shell is the most popular shell on Linux systems, and to use the shell efficiently, you need a little knowledge about Bash shell redirections. This is also an essential step in learning Bash scripting.

In this guide, we’ll show how to append text or command output to a file on the Bash shell command line. This will include several examples so you can pick the right method in any scenario.

In this tutorial you will learn:

  • How to append text or command output to a file
  • How to append and view command output at the same time
  • How to append multiple lines of text to a file
Appending text to a file in Bash on Linux

Appending text to a file in Bash on Linux

Read more

Listing environment variables

How to set and list environment variables on Linux

Environment variables are part of the Linux system shell that contain changing values. They help facilitate scripts and system programs, so that code can accommodate a variety of scenarios. Unlike regular shell variables, environment variables can be accessed system-wide, by any user or process.

Let’s look at a very simple example to see how environment variables work and why they exist. There are many system programs and user made scripts that need to access a current user’s home directory. This can be done reliably through the HOME environment variable. Therefore, a script that contains the following line can be used by any user on the system and it will generate the same result.

$ echo $SHELL > $HOME/current-shell.log

$ cat $HOME/current-shell.log
/bin/bash

In this guide, we’ll show how to list all the environment variables on a Linux system, as well as set new ones. Setting new environment variables can either be done temporarily, or permanently if you need them to survive a reboot. We’ll show instructions for both methods below.

In this tutorial you will learn:

  • How to list environment variables on Linux
  • How to set a temporary environment variable on Linux
  • How to set a permanent environment variable on Linux

Read more

How to Discover, From Inside a Bash Script, the Path the Script Is In

How to Discover, From Inside a Bash Script, the Path the Script Is In

When you develop complex Bash scripts and start putting various scripts into a folder, where one script interacts with another by, for example, starting it, it quickly becomes necessary to ensure we know the path the script was started from, so we can start the other scripts with a fully qualified pathname. This is important because the first script may have been started from outside the script’s directory. We could have also done so by using a relative path, so even – somehow – reading the command that started the current script will not work.

In this tutorial, you will learn:

  • What the pwd command is, and what it does
  • How to discover from inside a Bash script what path that same script is in

Read more

Special Bash Variables with examples

Special Bash Variables with examples

Bash is a great coding language, which allows you to do complex things like Big Data Manipulation, or simply create sever or desktop management scripts.

The entry level skill required to use the Bash language is quite low, and one-liner scripts (an often used jargon, which indicates multiple commands executed at the command line, forming a mini-script), as well as regular scripts, can grow in complexity (and how well written they are) as the Bash developer learns more.

Learning to use special variables in Bash is one part of this learning curve. Whereas originally the special variables may look cryptic: $$, $?, $*, \$0, $1, etc., once you understand them and use them in your own scripts, things will soon become clearer and easier to remember.

In this tutorial you will learn:

  • How to use special variables in Bash
  • How to correctly quote variables, even special ones
  • Examples using special variables from the command line and scripts

Read more