Advanced Linux Subshells With Examples

Advanced Linux Subshells With Examples

If you read our previous linux subshells for beginners with examples article, or are experienced with subshells already, you know that subshells are a powerful way to manipulate Bash commands inline, and in a context sensitive manner.

In this tutorial you will learn:

  • How to create more advanced subshell commands
  • Where you can employ more advanced subshells in your own code
  • Examples of more advanced subshell commands

Read more

GDB debugging tutorial for beginners

GDB debugging tutorial for beginners

You may already be versed in debugging Bash scripts (see How to Debug Bash Scripts if you are not familiar with debugging Bash yet), yet how to debug C or C++? Let’s explore.

GDB is a long-standing and comprehensive Linux debugging utility, which would take many years to learn if you wanted to know the tool well. However, even for beginners, the tool can be very powerful and useful when it comes to debugging C or C++.

For example, if you’re a QA engineer and would like to debug a C program and binary your team is working on and it crashes, you can use GDB to obtain a backtrace (a stack list of functions called – like a tree – which eventually led to the crash). Or, if you are a C or C++ developer and you just introduced a bug into your code, then you can use GDB to debug variables, code and more! Let’s dive in!

In this tutorial you will learn:

  • How to install and use the GDB utility from the command line in Bash
  • How to do basic GDB debugging using the GDB console and prompt
  • Learn more about the detailed output GDB produces

Read more

Generating Random Numbers In Bash With Examples

Generating Random Numbers In Bash With Examples

When coding Bash scripts – especially when developing scripts for functionality testing – we sometimes need to generate a random number or random input. These numbers may also need to be within a specific range. This article will teach you how to perform random number generation in Bash.

In this tutorial you will learn:

  • How to generate random numbers in Bash
  • How to generate random numbers is a specific range
  • Examples demonstrating random number generation in Bash

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

Changing SSH port on Linux

How to change SSH port on Linux

The default port for SSH on Linux systems is 22. There are a few reasons why you may want to change this to some other number. If multiple servers share the same IP address (behind a NAT configuration, for example) you usually can’t have them running SSH on the same port and expect to access them from outside the network.

The other big reason is security. Changing the SSH port would fall under “security through obscurity” which means that the security isn’t technically enhanced, but the SSH port has been obscured and isn’t as easy for attackers to access. In practice, this means that the thousands of bots scanning the internet for open SSH servers are a lot less likely to find yours.

In this article, we’ll take you through the step by step instructions of changing the default SSH port on Ubuntu Linux and CentOS Linux. Since Ubuntu is based on Debian, you can also apply the same instructions to other Debian based systems, like Linux Mint. CentOS is based on Red Hat, so its instructions can also be extended to Fedora and other similar Linux distributions.

In this tutorial you will learn:

  • How to change SSH port on Ubuntu and CentOS Linux

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

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

Installing TeamViewer on Linux

How to install TeamViewer on Linux

TeamViewer is used for controlling remote computers, online meetings, file transfers, and a few other things. Being that it’s proprietary software, it can be a little trickier to install it on a Linux system than most free and open source alternatives.

In this tutorial, we’ll guide you through the step by step instructions to install TeamViewer on most major Linux distributions.

In this tutorial you will learn:

  • How to install TeamViewer on Ubuntu, Debian, and Linux Mint
  • How to install TeamViewer on CentOS, Fedora, and Red Hat
  • How to install TeamViewer on Manjaro and Arch Linux

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

How to propagate a signal to child processes from a Bash script

How to propagate a signal to child processes from a Bash script

Suppose we write a script which spawns one or more long running processes; if said script receives a signal such as SIGINT or SIGTERM, we probably want its children to be terminated too (normally when the parent dies, the children survives). We may also want to perform some cleanup tasks before the script itself exits. To be able to reach our goal, we must first learn about process groups and how to execute a process in background.

In this tutorial you will learn:

  • What is a process group
  • The difference between foreground and background processes
  • How to execute a program in background
  • How to use the shell wait built in to wait for a process executed in background
  • How to terminate child processes when the parent receives a signal

Read more