Linux Subshells for Beginners With Examples

Linux Subshells for Beginners With Examples

Making use of subshells in Bash provides you with an ability to generate context sensitive information from right within your Bash command. For example, if you want to modify a text string right inside an echo statement, then this can be done easily with subshells.

In this tutorial you will learn:

  • How to use employ the use of subshells in Bash
  • How to use subshells to obtain context sensitive information
  • Basic Bash subshell usage examples

Read more

Setting a cron job for every 5 minutes in crontab

How to set crontab to execute every 5 minutes

cron is the job scheduler in Linux systems that can execute commands or scripts at regular intervals. Each task scheduled in cron is called a cron job. The utility used for scheduling these jobs is called crontab.

A common cron job that Linux admins use on their systems is to execute a command or script every 5 minutes. In this guide, we’ll show you how to use crontab to setup a cron job that runs every 5 minutes.

In this tutorial you will learn:

  • How to set crontab to execute every 5 minutes

Read more

npm on Linux

Install npm on Linux

npm is the package manager for Node.js and the JavaScript coding language. It can be installed on a Linux system and then used on the command line to download and install JavaScript packages and their requisite dependencies.

It’s especially useful for developers working with Node.js, as npm’s online registry contains a plethora of JavaScript packages that can be browsed and downloaded with ease. It’s available for installation on any major Linux distro and operates in much the same way as a distro’s package manager, which you’re probably already familiar with.

In this guide, we’ll show you how to install npm on various Linux distributions. We’ll also show you basic usage commands for npm, such as installing and removing software packages.

In this tutorial you will learn:

  • How to install npm on major Linux distributions
  • Basic usage commands for npm

Read more

Killing a process by name on Linux

How to kill process by name

How to kill a process on a Linux system is an essential thing for admins and users to know. The go-to method for this is usually with the kill command, which involves killing a process by its PID (process ID).

Sometimes, though, it’s more convenient to kill a process by name rather than going through the routine of locating its PID each time. There are two commands we can use to kill a process by name, those being killall and pkill.

In this tutorial, we’ll go over both killall and pkill commands and show examples for how they can be used to kill processes by name only.

In this tutorial you will learn:

  • How to kill a process by name with killall and pkill

Read more

Excluding a directory from rsync transfer

Rsync: exclude directory

The rsync command on a Linux system can be used to synchronize the contents of two directories. By default, rsync will transfer all files and directories over to the specified destination. If there’s a subdirectory you wish to exclude from the transfer, rsync gives us two options for doing so.

In this tutorial, we’ll show two methods for excluding one or multiple directories from an rsync transfer. Follow along with the example commands below on your own system to configure a directory for exclusion.

In this tutorial you will learn:

  • How to exclude a directory in rsync command

Read more

Deleting a local and remote Git branch

Git: delete branch

When working with Git, it’s common for projects to contain multiple branches. Over time, these branches may become irrelevant and need deleted. Other times, they change purpose and its necessary to rename the branch.

In this guide, we’ll show you the step by step instructions for deleting Git branches via the command line on a Linux system. We’ll show the process for deleting local branches as well as remote branches in the sections below.

In this tutorial you will learn:

  • How to delete local and remote Git branches

Read more

nslookup command on Linux

Nslookup Linux command

The nslookup utility can be installed and used on a Linux system to find out information about the DNS records for a domain or IP address. It’s particularly handy when troubleshooting DNS issues. A popular tool that also comes installed with nslookup is dig, which is similar but uses different resolvers. It’s a good alternative to nslookup, but nslookup is typically easier to use.

In this tutorial, we’ll guide you through the installation of nslookup on major Linux distributions and show various command line examples that you can use on your own system when you need to obtain DNS information.

In this tutorial you will learn:

  • How to install nslookup on major Linux distros
  • Nslookup command line examples

Read more

How to obtain Sunrise & Sunset time for any location from Linux command line

Objective

The objective is to use command line and bash shell script to obtain Sunrise & Sunset time information for any given location.

Operating System and Software Versions

  • Operating System: – Linux distribution agnostic.

Requirements

Installed lynx tool and access to shell command line. Your location code obtained from https://weather.codes/search/.

Difficulty

EASY

Conventions

Read more

Creating and testing a symbolic link in Linux

How to create symlink in Linux

Symbolic links (also known as symlinks or soft links) are one of two types of links that you can create on a Linux system. If you’re just now learning about symbolic links, it may help to think of them as “shortcuts,” a term commonly used by Windows systems to represent basically the same thing.

Symbolic links are used to link to hard links. If you’re interested in learning more about hard links and how they compare to symbolic links, check our guide on creating hard and soft links. Suffice it to say that symlinks are just entries in the file system that point to files or directories. They’re mostly used for convenience.

In this guide, we’ll run through the step by step instructions of creating and removing symbolic links. You can follow along with our examples below on your own command line to get a feel for how they work.

In this tutorial you will learn:

  • How to create and remove symbolic links

Read more

Renaming Git branch

Git: rename branch

When working with Git, it’s common for projects to contain multiple branches. Sometimes these branches change purpose over time or simply have a naming error, and in such cases it’s necessary to rename the branch.

In this guide, we’ll show you the step by step instructions for renaming Git branches via the command line on a Linux system. We’ll show the process for renaming local branches as well as remote branches and go over what you need to know to ensure a smooth transition.

In this tutorial you will learn:

  • How to rename local and remote Git branches

Read more

How to monitor network activity on a Linux system

How to monitor network activity on a Linux system

There are many reasons why you may want to monitor the network activity on your Linux system. You may be troubleshooting a network issue, you may want to check to make sure that there are no malicious applications creating suspicious network activity, or you may simply want to know if any processes are phoning home. Whatever the reason, here are a few methods to see which processes on your system are engaged in network activity and who they are communicating with.

Read more

Best Terminal Games on Linux

Best Terminal Games on Linux

Intro

GNU/Linux gaming has come a long way over the past decade. We are lucky to live in an age where there are a number of native linux games including AAA titles to choose from on the platform. Steam has also vastly increased the number of games available on Linux. Despite the vast availability of GUI based games, sometimes it can be more relaxing and entertaining to play terminal based ones. This is not so surprising considering the fact that most Linux users spend a lot of time on the command line and feel at home there. Luckily, there are a number of great terminal based games available on the platform as well.

Read more