Compare the output of two commands

..without creating a temporary file:

The -y is just to show a side-by-side comparison. Very handy! And the result?

Thanks to my colleague Ingvar for showing me this!

No Wi-Fi device found

I just reinstalled one of my machines with Fedora 21. The install went great, but when the machine was done rebooting, and I was trying to set up my access to a wireless network with nmcli (NetworkManager), I got the following error-message:

..and:

Spending a lot of time finding what the problem was, I finally found the solution.  It seems that Wi-Fi support in NetworkManager has been separated to a plugin. The package NetworkManager-wifi was missing. According to Pablo S. Torralba, who was kind enough to comment on this post, it should be enough to kill NetworkManager and launch it again as root. Should that fail, you can always try the old reboot-trick!  Either way, it should hopefully be working.

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

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

Edit

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.

List

or

..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.

Syntax

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.

Operators

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.

Examples

First

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

Second

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

Third

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

Fourth

..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:

Merge

Split

Check out man pdfseparate for more information about the tool.

Convert FAT32 to NTFS without losing data

I had a USB-stick formatted with FAT32, and when I tried transferring a file over 4GB to it, I suddenly got the error:

The file ‘example.iso’ is too large for the destination file system.

The file system FAT32 only supports file sizes of up to 4GB, thus this error. Luckily there’s an easy way to fix this – convert the file system from FAT32 to NTFS. This can be done easily with the command convert, and should not cause you to lose data on the device you’re converting, or have to format it. However, backup is always adviced.

So, the conversion itself:

1. Click on the Start-menu
2. Type cmd in the search bar
3. Check the disk for errors with the command:

Where e: is the letter of the drive of the USB-stick.

4. Execute the conversion with:

The conversion-process will take a few minutes, and in the end the program will inform you when the conversion was successful.

That’s all there is to it. :)