Useful Bash command line tips and tricks examples - Part 2

Useful Bash command line tips and tricks examples – Part 2

In this series we are exploring various tips, tricks and Bash command line examples which will help you become a more advanced Bash user and coder. Bash provides a rich scripting and coding language which puts the power back in the hands of the user and developer. Bash also allows you to learn as you go along, thereby making it a more enjoyable experience. For the first article in our series, please see our article Useful Bash command line tips and tricks examples part 1.

In this tutorial series you will learn:

  • Useful Bash command line tips, tricks and methods
  • How to interact with the Bash command line in an advanced manner
  • How to sharpen your Bash skills overall and become a more proficient Bash user

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

Multi-threaded xargs with examples

Multi-threaded xargs with examples

If you are new to xargs, or do not know what xargs is yet, please read our xargs for beginners with examples first. If you are already somewhat used to xargs, and can write basic xargs command line statements without looking at the manual, then this article will help you to become more advanced with xargs on the command line, especially by making it multi-threaded.

In this tutorial you will learn:

  • How to use xargs -P (multi-threaded mode) from the command line in Bash
  • Advanced usage examples using multi-threaded xargs from the command line in Bash
  • A deeper understanding of how to apply xargs multi-threaded to your existing Bash code

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

Using GNU screen with examples

Using GNU screen with examples

Have you even been in the situation where you were running a 3 hour copy or script on a remote machine, only to find that it broke at 2h 45min because your network connection or SSH connection dropped momentarily? If so, you know how painful that feels 🙂 Welcome to GNU screen, the utility which allows you to start a separate shell which will not be interrupted if your network connection breaks. Read on to discover how to use it and more!

In this tutorial you will learn:

  • How to install and use the GNU screen utility
  • How to configure the GNU screen utility to function better
  • Basic usage examples on how to use the GNU screen utility from the Bash command line

Read more

Random Entropy in Bash

Random Entropy in Bash

When using random numbers in Bash, the question of random entropy will sooner or later come up. This article will help you understand what entropy is, how it can be modified and optimized in Bash, and how it will affect random number generation.

In this tutorial you will learn:

  • How to generate random entropy in Bash
  • How to pre-seed the random number generator in Bash
  • Examples demonstrating random entropy generation in Bash

Read more

xargs for beginners with examples

xargs for beginners with examples

Using xargs, described in the Linux xargs manual as a tool which builds and execute command lines from standard input, once can exert a significant amount of additional power over any other command executed on the Bash command line. Basically, xargs will take the output from any other tool, and use that as it’s own input for further processing and action (hence the reference to executing command lines in the manual). If this is your first few weeks or months with xargs, or you are only just starting, this is the best place for you to get into xargs.

In this tutorial you will learn:

  • How to use xargs from the command line in Bash
  • How xargs works, what it does, and how to use it well
  • Basic usage examples using xargs from the command line in Bash

Read more

Useful Bash command line tips and tricks examples - Part 1

Useful Bash command line tips and tricks examples – Part 1

The Bash command line provides nearly limitless power when it comes to executing nearly anything you want to do. Whether it is processing a set of files, editing a set of documents, handling big data, managing a system or automating a routine, Bash can do it all. This series, of which today we present the first part, is sure to arm you with the tools and methods you need to become a much more proficient Bash user. Even already advanced users will likely pickup something new and exciting. Enjoy!

In this tutorial you will learn:

  • Useful Bash command line tips, tricks and methods
  • How to interact with the Bash command line in an advanced manner
  • How to sharpen your Bash skills overall and become a more proficient Bash user

Read more

Advanced Bash regex with examples

Advanced Bash regex with examples

Using the power of regular expressions, one can parse and transform textual based documents and strings. This article is for advanced users, who are already familiar with basic regular expressions in Bash. For an introduction to Bash regular expressions, see our Bash regular expressions for beginners with examples article instead. Another article which you may find interesting is Regular Expressions in Python.

Ready to get started? Dive in and learn to use regexps like a pro!

In this tutorial you will learn:

  • How to avoid small operating system differences from affecting your regular expressions
  • How to avoid using too-generic regular expression search patters like .*
  • How to employ, or not employ, extended regular expression syntax
  • Advanced usage examples of complex regular expressions in Bash

Read more

Bash regexps for beginners with examples

Bash regexps for beginners with examples

Using regular expressions in Bash provides you with plenty of power to parse nearly every conceivable text string (or even full documents), and transform them into nearly any output desirable. If you regularly use Bash, or if you regularly work with lists, textual strings, or documents in Linux, you will find that many jobs can be simplified by learning how to use regular expressions in Bash. Continue reading to learn basic Bash regular expression skills! If you are already familiar with basic regular expressions in Bash or another coding language, see our more advanced bash regular expressions. If not, continue reading to learn basic Bash regular expression skills!

In this tutorial you will learn:

  • How to use regular expressions on the command line in Bash
  • How regular expressions can parse and transform any text string and/or document
  • Basic usage examples of regular expressions in Bash

Read more

Multi-threaded Bash scripting & process management

Multi-threaded Bash scripting & process management at the command line

The things you can do using Bash script are limitless. Once you begin to developed advanced scripts, you’ll soon find you will start to run into operating system limits. For example, does your computer have 2 CPU threads or more (many modern machines have 8-32 threads)? If so, then you will likely benefit from multi-threaded Bash scripting and coding. Continue reading and find out why!

In this tutorial you will learn:

  • How to implement multi-threaded Bash one-liners directly from the command line
  • Why multi-threaded coding almost always can and will increase the performance of your scripts
  • How background and foreground processes work and how to manipulate job queues

Read more

How to benchmark Disk performance on Linux

How to benchmark Disk performance on Linux

Just bought the latest and greatest – and especially fastest – SDD? Or upgraded your phone’s microSD memory card? Before you start using your shiny new hardware, you may want to run a performance check against the drive. Is the write and read speed up to manufacturer’s specifications? How does your performance compare with that of others? Is that 1TB flash drive you bought on an auction site from China really as fast as the listing said it was? Let us find out!

In this tutorial you will learn:

  • What CLI (Command Line Interface: your Bash or other terminal environment) disk performance measuring tools are available
  • What GUI (Graphical User Interface: your desktop environment) disk performance measuring tool we recommend
  • How to effectively measure disk performance in a straightforward manner
  • Discover and learn with various disk performance measuring examples
  • How to get a sense for the quality of disk/flash hardware you own

Read more