Python is a dynamically typed, interpreted, general purpose programming language. It's useful for everything from system scripting, to web applications, to full graphical desktop programs. Because of that, it's no surprise that demand for Python programming skills is only increasing, and top companies like Google, Mozilla, Instagram(Facebook), and Reddit rely on it as part of their core technology stack. Not only that, but Python is a favorite in both academic and scientific circles and is gaining ground in the financial sector. Top universities are even using it to teach programming in their computer science programs.

With all of that said, you'd probably be thinking that Python is something super difficult to learn and only accessible to the elite in the technology field, but you couldn't be more wrong. Python is easy. Python is really easy. In fact, Python is one of the first languages used to teach children to program. Python was designed to be very clear and simple to understand. It reads like plain English, and its syntax makes use of spaces rather than brackets and semicolons, so it always looks clean and uncluttered. It's very difficult, if not impossible, to wright messy Python. This helps out new programmers and programmers new to Python big time because you can always tell what you're looking at, or at least, get a decent sense of what it does. This way, you can look at code examples from established open source projects to get an idea of what professional grade Python looks like and how it's used.

Python and Linux work incredibly well together. It wasn't all that long ago that Python supplanted Perl as the de facto scripting and "glue" language on Linux systems. This means that many scripts and utilities that ship with modern Linux systems are written in Python. As a result, most Linux distributions have Python installed by default, but there is a bit of a catch. There are two current versions of Python. Python 2.7.X and Python 3.X.X are both current. Syntactically, they are very similar, but Python 3 has some features that Python 2 doesn't. That means that they are not entirely compatible and many distributions package them separately. So, your system may have Python 2, but not Python 3 or vice versa. This guide and the others in the series are going to cover Python 3. It is the future of Python, and it's not so bad to go back to Python 2 after you've worked with Python 3.

The following article will explain a simple procedure on how to list work days ( business days ) on a Linux command line. Please note that the below procedure does not take into account a public holidays for your relevant country as it simply only shows word days while excluding weekends.

For this we will be using ncal command. Let's start the complete workout by displaying a calendar for a current month start:
$ ncal -h
    August 2016       
Mo  1  8 15 22 29   
Tu  2  9 16 23 30   
We  3 10 17 24 31   
Th  4 11 18 25      
Fr  5 12 19 26      
Sa  6 13 20 27      
Su  7 14 21 28 

The following config will discuss a basic example on how to execute shell script during a boot time on systemd Linux. There maybe various reason why you might want to execute shell script during Linux startup like for example to start a particular custom service, check disk space, create a backup etc.

The following example below will serve as a basic template to be later modified to suit your specific needs. In the example below we will check a disk space of a /home/ directory during a boot time and write a report to /root/ directory.

Systemd service unit

First, we need to create a systemd startup script eg.disk-space-check.serviceand place it into /etc/systemd/system/ directory. You can find the example of such systemd startup script below:




Although you may think that you have learned to master Linux command line with bash shell, there are always some new tricks to learn to make your command line skills more efficient. This article will teach you a few more basic tricks on how to make your life with the Linux command line & bash more bearable and even enjoyable.

Bash Command History Expansion

This section will mostly deal with bash shortcuts in combination with three bash history expansion characters "!", "^" and "#". Bash Command History Expansion character "!" indicates start of history expansion. The "^" is a substitution character to modify a previously run command. The last optional character is "#", which denotes the reminder of the line as a comment.

Repeat last command

$ echo Bash Shortcuts
Bash Shortcuts
$ !!
echo Bash Shortcuts
Bash Shortcuts

!! is probably the easiest and most popular bash shortcut, which simply shows and executes your last entered command.


For most of us WEP encryption has become a joke. WPA is quickly going the same way thanks to many tools such as Aircrack-ng. On top of this, wired networks are no strangers to unwanted guests as well. Anyone serious about security should have a good Intrusion Detection system in their toolbox.

There are already some very good IDS's (Intrusion Detection Systems) available. Why would anyone want to re-invent the wheel in Bash??? There are a couple of reasons for this. Obviously Bash scripts can be very light weight. Especially compared to some of the GUI programs that are out there. While programs like Etherape suck us in with pretty colors, they require constant monitoring to know when the network has changed. If you are like most of us, you only use the computer for two things, work and play. By using the system bell to alert for new clients online you can leave this script running and not have to have a constant watch. If you do decide you want to inspect what a suspicious client is doing more closely, you can always open up etherape, wireshark, or your tool of choice. But until you have a problem you can play or work on other things.

Another bonus to this program is that it will only show ip addresses on the networks connected to your computer. If you were hosting a busy server or perhaps downloading the latest Linux distro though a torrent client, an IDS may be flooded with connections. Looking for a new malicious client can be like looking for a needle in a hay stack. While this script may seem simple compared to other IDS's, simplicity can have its perks too.

What you will need

Nmap is required for this script to work. We will not be doing any port scanning. However, to make this script fast we needed something better than a regular ping. Nmap's -sP parameter will only use a ping scan to check if a clients up. There were some variations in how Nmap outputs information between versions. So far this script has only been tested using Nmap 5.00 (Debian Squeeze) and 5.21 (Debian Sid). You may have luck with other distros and versions of Nmap. However, with all the possibilities I could only support a couple at this time.

Let's consider a following back script example. The script returns error value using $? variable.
$ cat 

echo $?
After execution we can see the the actual error message and bash 127 error return code:
$ ./ 

./ line 3: non-existing-command: command not found


If you already have some experience as a Linux system administrator, chances are you know what cron is and what it does. If you're just starting working with Linux, it's essential knowledge that will certainly serve you later. Either way, if you already have the knowledge, this article will refresh it. If not, you will get a guide to start you up. So you're only expected to have some basic knowledge of Linux systems and, as usual, a desire to learn.

Cron's name comes from Chronos, the Greek personification of time. And it's a very inspired choice, because cron helps you schedule different tasks you want your system to perform at given times. If you used Windows systems, chances are you stumbled across the Scheduled Tasks tool. Generally speaking, the purpose is the same, the differences are...well, too many to name here. The idea is cron is more flexible and appropriate for serious system management tasks. If you need some example use cases, just think about backups : do you want to perform backup tasks when you're responsible for hundreds of machines? We thought not. You just write a simple shell script using rsync, for example, schedule it to run, say, daily and forget about it. All you have to do now is check the logs from time to time. We even know people that use cron to remind them of important personal events, like birthdays.

But cron is just a daemon running the tasks you tell it to run. Is there a tool to help us edit/add/remove those tasks? Of course, and it's called crontab (the name comes from cron table). But let us start from step one : installation.


The aim of this article is to provide an overview of the GNU R programming language. It starts a series of articles devoted to programming with R. Its objective is to present, in an organized and concise manner, the elementary components of the R programming language. It is designed to help you understand R code and write your own. It is assumed that the reader has already some basic programming knowledge of R. If you are not familiar with any of R features it is recommended that you first read A quick GNU R tutorial to basic operations, functions and data structures.


An R expression is an elementary component of R code. Expression in R can be:

  • assignment statement;
  • conditional statement;
  • arithmetic expression.

Examples of R expressions:

> y<-100
> if (1==1) 1 else 0
[1] 1
> 100/5
[1] 20

R expression are constructed from objects or functions. It is common to separate them with a new line, however, you can also separate expressions with semicolons as below.


Whether you would like to share your code and data with other people or simply pack up your code in a concise way, the ability of building a custom package in GNU R may come useful to you. In this article we will outline as clearly as possible the process of building a basic package in R. This does not include more advanced knowledge on building R packages. This tutorial, however, will get you started. You may also find How to install and use packages in GNU R of help if you are not familiar with using R packages at all.

Creating a package structure

Every package consists of a set of functions that are programmed to apply with a common aim. Additionally, a sample data is often provided with the package in R. Let us now propose a simple example. Below we defined four R objects: two functions div() and pow() and two data sets in a form of two vectors data1 and data2.


GNU R offers a wide variety of packages for its users. There are all kinds of packages for R, which allow to display graphics or perform statistical tests. Some packages are designed for applications specific to a given industry. Many packages are already a part of the basic R installation, however, some of them need to be additionally installed into GNU R. This article will describe how to install and use packages under R.

What is a Package

A package is a set of functions, help files and data files that have been linked together. In order to use a package in R you need to first make sure that it is installed in the local library. In general, the one system-level library is used for storing the default R packages. You can, however, add additional libraries. You also need to remember about loading packages into your current R session. This is very important when using R. It is recommended that you do not load too many packages at the time. Loading a large number of packages may result in errors due to clashes of function names coming from two different packages.


In this quick GNU R tutorial to statistical models and graphics we will provide a simple linear regression example and learn how to perform such basic statistical analysis of data. This analysis will be accompanied by graphical examples, which will take us closer to producing plots and charts with GNU R. If you are not familiar with using R at all please have a look at the prerequisite tutorial: A quick GNU R tutorial to basic operations, functions and data structures.

Models and Formulas in R

We understand a model in statistics as a concise description of data. Such presentation of data is usually exhibited with a mathematical formula. R has its own way to represent relationships between variables. For instance, the following relationship y=c0+c1x1+c2x2+...+cnxn+r is in R written as


which is a formula object.

Linear regression example

Let us now provide a linear regression example for GNU R, which consists of two parts. In the first part of this example we will study a relationship between the financial index returns denominated in the US dollar and such returns denominated in the Canadian dollar. Additionally in the second part of the example we add one more variable to our analysis, which are returns of the index denominated in Euro.


In the last two articles we have learned how to install and run GNU R on the Linux operating system. The purpose of this article is to provide a quick reference tutorial to GNU R that contains introduction to the main objects of the R programming language . We will learn about basic operations in R, functions and variables. Moreover, we will introduce R data structures, objects and classes.

Basic Operations in R

Let us start with a simple mathematical example. Enter, for instance, addition of seven and three into your R console and press enter, as a result we obtain:

> 7+3
[1] 10

To explain in more detail what just happened and what is the terminology we use when running R, we say that the R interpreter printed an object returned by an expression entered into the R console. We should also mention that R interprets any number as a vector. Therefore, "[1]" near our result means that the index of the first value displayed in the given row is one. This can be further clarified by defining a longer vector using the c() function. For example:


GNU R can be run on the Linux operating system in a number of ways. In this article we will describe running R from the command line, in an application window, in a batch mode and from a bash script. You will see that these various options for running R in Linux will suit a specific task. Some of them are more suitable for simple statistical analysis that can be done in one line of code, others for more sophisticated programs that require executions of a larger number of R expressions. Finally, we may want to run a program that will take a day or two to run on a Linux cluster. In this case we will run R in a background, which allows us for logging out from the cluster.

Running R from the Linux command line

Probably, the simplest way to run R under Linux is to run it from the Linux command line. That is,

$ R

As a result of this command the following appears:

R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit) R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.



This article will deal mainly with the installation of R on Linux, but also will provide a simple example on how to use R for plotting. This is the first article of the series of R articles so subscribe to our RSS feed for regular updates. Everyone, who is interested in using R for their work or is simply interested in this software is invited to follow this series of articles. The main objective of these articles is to provide a quick reference to R with illustrative examples.

What is GNU R?

R is an open source programming language (software package) and environment used mainly for statistical data analysis. It is licensed under the GNU General Public License (GPL). R is a very intuitive programming language. You can do in a few lines of R code a lot, mainly because there is a large number of packages available for R, which means a large number of preprogrammed functions for you to use. You can get R packages through Comprehensive R Archive Network (CRAN).

R's strengths are: graphical visualization of data such as plots, data analysis, statistical data fits.

R's weaknesses are: complex structured data storage, querying data, dealing with large data sets, which do not fit in the computer's memory.

Installing GNU R on Linux/Unix.

Package Management System

Debian / Ubuntu / Mint

On Debian like Linux systems such as Debian, Ubuntu or Linux Mint you can install R from standard repositories. This is a preferred way of getting R installed on your system. The command bellow will download and install R along with all its prerequisites:

$ sudo apt-get install r-base

Submit your RESUME, create a JOB ALERT or subscribe to RSS feed.
Subscribe to NEWSLETTER and receive latest news, jobs, career advice and tutorials.
Get extra help by visiting our LINUX FORUM or simply use comments below.

You may also be interested in: