Monthly Archives: September 2016

Linux BASH Programming Cookbook (PDF Guide)

Delve into the world of Linux BASH Programming with this compact cookbook that introduces common recipes for the BASH command line!

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. First released in 1989, it has been distributed widely as it is a default shell on the major Linux distributions and OS X.

In this ebook, we provide a compilation of BASH programming examples that will help you kick-start your own projects. We cover a wide range of topics, from user management and permissions setting, to specific commands like sed, tar, etc. With our straightforward tutorials, you will be able to get your own projects up and running in minimum time.

With this free eBook you will also receive weekly news, tips and special offers delivered to your inbox courtesy of System Code Geeks.

Related posts

Getting Started with Ubuntu 16.04 (PDF Guide)

Getting Started with Ubuntu 16.04 is a comprehensive beginners guide for the Ubuntu operating system.

Getting Started with Ubuntu 16.04 is not intended to be a comprehensive Ubuntu instruction manual. It is a quick-start guide that will get you doing the things you need to do with your computer easily, without getting bogged down with technical details. With the help of this guide, it should not take long before new users get used to the Unity desktop environment. Unity includes the Launcher, the Dash, the hud, indicators, and an on screen display notification system(osd). All these features will be explained in this guide.

Related posts

Linus Torvalds Confirms the Date of the First Linux Release

Linus Torvalds, the creator of the Linux kernel, has finally discovered the date of its first release: September 17, 1991. Twenty-five years later, to the day, Torvalds posted this message on his Google+ page:

Today is the 25th anniversary of the Linux-0.01 release, I do believe.

Normally the Linux anniversary is counted from the announcement email, which was August 25, because that was the actual public statement of intent. The 0.01 code drop happened a couple of weeks later and wasn’t publicly announced.

Earlier during an interview with Linux Pro Magazine, Torvalds said he was not sure about the actual Linux anniversary day, because there was possibly more than one date. Although August 25 is the date he announced the project he was working on, Torvalds said he never announced the first release publicly and simply uploaded it to an FTP server and emailed those who were interested in it.

Since then, he said, he lost all those email communications, so he didn’t remember exactly when the first version of Linux was released. The only way to find out, he said, was to look at the timestamp on the first release. That’s exactly what he seems to have done: The makefile of the first release is stamped September 17, 1991.

However, that doesn’t change the official birthday of Linux. Torvalds settled that matter during a keynote discussion at LinuxCon North America (Toronto) when he said August 25 is the official date to use as a birthday.

Source link

Install Glances on Ubuntu 16.04

Sponsored Link

Glances is a cross-platform curses-based monitoring tool which aims to present a maximum of information in a minimum of space, ideally to fit in a classical 80×24 terminal or higher to have additional information. It can adapt dynamically the displayed information depending on the terminal size. It can also work in client/server mode. Remote monitoring could be done via terminal or web interface.

Glances is written in Python and uses the psutil library to get information from your system.

Glances Features

The following system monitoring details will be provided

Process list
Network interface
Disk I/O
Filesystem (and folders)
System info
Quicklook (CPU, MEM, LOAD)


Written in Python, Glances will run on almost any plaftorm : GNU/Linux, FreeBSD, OS X and Windows.


Glances includes a XML-RPC server and a RESTFUL-JSON API which can be used by another client software.

Web UI

No terminal at hand ? Use the built-in Web UI and monitor your system from any device.


Export all system statistics to CSV, StatsD, InfluxDB, ElasticSearch or even RabbitMQ. Glances also provides a dedicated Grafana dashboard.

Install Glances on Ubuntu 16.04

Open the terminal and run the following command

sudo apt-get install glances

Using glances

You can run the following command from your terminal to see the details of your system


Output looks as follows


Press ESC or “Ctrl + C” to quit from the Glances terminal.

By default, the interval time is set to 1 second, but you can define the custom interval time while running glances from the terminal.

To set the interval time to 5 seconds, run the following command:

glances -t 5

You can check glances documentation for more details.

Sponsored Link

Related posts

Beginning Grep for Linux SysAdmins

GNU grep is an amazing power tool for finding words, numbers, spaces, punctuation, and random text strings inside of files, and this introduction will get you up and running quickly.

We’ll stick to GNU grep and the Bash shell, because both are the defaults on most Linux distros. You can verify that you have GNU grep, and not some other grep:

$grep -V
grep (GNU grep) 2.21
Copyright (C) 2014 Free Software Foundation, Inc.

It’s unlikely that you will bump into a non-GNU grep on Linux unless you put it there. There are some differences between GNU grep and Unix grep, and these are often discussed in documentation and forums as though we spend our days traipsing through multiples Linuxes and Unixes with gay abandon. Which sounds like fun, but if you use only Linux then you don’t need to worry about any differences.

Basic grep

We humans tend to think in terms of the numbers, words, names, and typos we want to find, but grep doesn’t know about these things; it looks for patterns of text strings to match. That is why you see the phrase “pattern matching” when you’re studying grep and other GNU text-processing tools.

I suggest making a plain text file to use for practicing the following examples because it limits the scope, and you can quickly make changes.

Most of us know how to use grep in simple ways, like finding all occurrences of a word in a file. First type your search term, and then the file to search:

$ grep word filename

By default, grep performs a case-sensitive search. You can perform a recursive case-insensitive search in a directory and its subdirectories:

$ grep -ir word dirname

This is an easy and useful way to find things, but it has a disadvantage: grep doesn’t look for words, it looks for text strings, so when you search for “word” grep thinks that “wordplay” and “sword” are matches. When you want an exact word match use -w:

$ grep -w word filename

Use ^ and $ to find matches at the beginnings and ends of lines:

$ grep ^word filename
$ grep word$ filename

Use -v to invert your match and find the lines that do not contain your search string:

$ grep -v word filename

You can search a list of space-delimited files, which is useful when you have just a few files to search. grep prefixes each match with its filename, so you know which files your matches are in:

$ grep word filename1 filename2 filename3
filename1:Most of us know how to use <code>grep</code> in simple ways
filename2:<pre><code>$ grep word filename</code></pre>
filename3:This is an easy and useful way to find things

You can also see the line numbers with -n, which is fab for large files:

$ grep -n word filename1 filename2 filename3

Sometimes you want to see the surrounding lines, for example when you’re searching log or configuration files. The -Cn option prints the number of preceding and following lines that you specify, which in this example is 4:

$ grep -nC4 word filename

Use -Bn to print your desired number of lines before your match, and -An after.

So how do you search for phrases when grep sees the word after a space as a filename? Search for phrases by enclosing them in single quotes:

$ grep 'two words' filename

What about double quotes? These behave differently than single quotes in Bash. Single quotes perform a literal search, so use these for plain text searches. Use double quotes when you want shell expansion on variables. Try it with this simple example: first create a new Bash variable using a text string that is in your test file, verify it, and then use grep to find it:

$ VAR1=strings
$ echo $VAR1
$ grep "$VAR1" filename


Now let’s play with wildcards. The . matches any single character except newlines. I could use this to match all occurrences of “Linuxes” and “Unixes” in this article:

$ grep -w Linux.. grep_cheat_sheet.html
$ grep -w Unix.. grep_cheat_sheet.html

Or do it in one command:

$ grep -wE '(Linux..|Unix..)' grep_cheat_sheet.html

That is an OR search that matches either one. What about an AND search to find lines that contain both? It looks a little clunky—but this is how it’s done, piping the results of the first grep search to the second one:

$ grep -w Linux.. grep_cheat_sheet.html |grep -w Unix..

I use this one for finding HTML tag pairs:

$ grep -i '<h3>.*</h3>' filename

Or find all header tags:

$ grep -i '<h.>.*</h.>' filename

You need both the dot and the asterisk to behave as a wildcard that matches anything: . means “match a single character,” and * means “match the preceding element 0 or more times.”

Bracket Expressions

Bracket expressions find all kinds of complicated matches. grep matches anything inside the brackets that it finds. For example, you can find specific upper- and lower-case matches in a word:

$ grep -w '[lL]inux' filename 

This example finds all lines with pairs of parentheses that are enclosing any letters and spaces. A-Z and a-z define a range of patterns, A to Z inclusive uppercase, and a to z inclusive lowercase. For a space simply press the spacebar, and you can make it any number of spaces you want:

$ grep '([A-Za-z ]*)' filename 

Character classes are nice shortcuts for complicated expressions. This example finds all of your punctuation, and uses the -o option to display only the punctuation and not the surrounding text:

$ grep -o "[[:punct:]]" filename

That example isn’t all that practical, but it looks kind of cool. A more common type of search is using character classes to find lines that start or end with numbers, letters, or spaces. This example finds lines that start with numbers:

$ grep "^[[:digit:]]" filename

Trailing spaces goof up some scripts, so find them with the space character class:

$ grep "[[:space:]]$" filename

Basic Building Blocks

These are the basic building blocks of grep searches. When you understand how these work, you’ll find that the advanced incantations are understandable. GNU grep is ancient and full of functionality, so study the GNU grep manual or man grep to dig deeper.


Learn more about system management in the Essentials of System Administration training course from The Linux Foundation.