Tag Archives: tutorial

Split a file into a number of equal parts

As an example, we have a file named primary_data_file.txt that contains 616 lines of data. We want to split this into 4 files, with the equal amount of lines in each.

The following command should do the trick:

The option -da generates the suffixes of length 1, as well as using numeric suffixes instead of alphabetical.

The results after running the command are the following files:

Introduction to cron

cron is a time-based job scheduler. This piece of software utility is used when you need to have a program run repeatedly at set time.

The daemon that runs in the background is named crond, while the file that contains the jobs themselves is named crontab.

You have three main directories:

  • /etc/crontab¬†is the main system crontab file.
  • /var/spool/cron/ a directory for storing crontabs defined by users.
  • /etc/cron.d/ a directory for storing system crontabs.


Creating a crontab-file for your user is easy. Usage depends on what you need to do.


This command will allow you to edit the current user’s crontab. If a crontab doesn’t already exist, it will create a new one once you have saved your changes.

Edit another user’s crontab

You can also edit another user’s crontab, but only if you have the correct permissions in place to do so.



..to list another user’s crontab.

These are the most common usages of the command crontab. For a couple of more options, see man crontab.


The syntax of a crontab-file looks like this:

Each asterisk represents a field. Starting from left to right, the fields are as follows:

  • Minute (0 – 59)
  • Hour (0 – 23)
  • Day of month (1 – 31)
  • Month (1 – 12)
  • Day of week (0 – 7, where 0 and 7 is Sunday)

On the fields Month and Day of the week, you can also use names instead of numeric values.


There are various operators that you can use with cron. Here’s the list:

Asterisk (*)

An asterisk (*) is used to indicate that every instance (i.e. every hour, every weekday, etc.) of the particular time period will be used. So if you use an asterisk in the field Hour, it means that it will run every hour.

Comma (,)

With this operator you can specify a list of values. If you use 1,5 in the field Day of week, this would mean Monday and Friday.

Dash (-)

While comma specifies a list of values, dash specifies a range. 1-5 in the field Day of week would mean Monday to Friday.

Forward slash (/)

Forward slash¬†specifies a step value. If you’d like to execute a command every other hour, you could use 0-23/. You can also use steps after an asterisk, so if you want the command to run every two hours instead, use */2.



In this example the script backup.sh runs at 14:45, the first day of the month, every month.


This line runs the command list_files.sh at 04:30 on the 1st and 15th of each month, plus every Friday.


The line above runs the command wake_up.sh at 08:00, Monday to Friday.


..and this line would run the program annoy_wife.sh every five minutes, every day.

As always, if you want to know more about cron, check out the command man cron.

Have fun!

Split and merge PDFs – part 2

A while ago I wrote a post named Split and merge PDFs with pdftk. Unfortunately, pdftk seems no longer to be maintained for Fedora 21. So we have to use another alternative – poppler-utils:

Install the package with:

..and you can use them to both split and merge files. poppler-utils contains a list of tools that you can use to manipulate PDFs:

  • pdfdetach — lists or extracts embedded files (attachments)
  • pdffonts — font analyzer
  • pdfimages — image extractor
  • pdfinfo — document information
  • pdfseparate — page extraction tool
  • pdftocairo — pdf to png/jpeg/pdf/ps/eps/svg converter using cairo
  • pdftohtml — pdf to html converter
  • pdftoppm — pdf to ppm/png/jpeg image converter
  • pdftops — pdf to postscript (ps) converter
  • pdftotext — text extraction
  • pdfunite — document merging tool

So, we move on to merging and splitting:



Check out man pdfseparate for more information about the tool.

Introduction to lsof

Today I’m going to introduce you to the exciting world of lsof.

As you will see, it’s a nifty little tool that has various uses, and it has so many switches that you need both a and a + to use all the options available! As the description of the command says in its man-page:

lsof – list open files

So, let’s get started.


List network connections

Continue reading