Split and merge files from the command line

Saturday, June 18, 2011 | En Español

Although some file archivers offer us the option of split the files, this can be easily accomplished with two commands: split and cat.

Read more...

Categories: Commands, FOSS, Linux

The confusing prefixes for binary multiples

Friday, June 17, 2011 | En Español

Expressing sizes in informatics can be confusing at times, this is due to the lack of standardization among hardware manufacturers, programs and operating systems regarding the use of prefixes (K, M, G) when expressing binary multiples. A standard does exist, this is what ISO/IEC 80000-13:2008 is about, it defines a standard for the use of prefixes for binary multiples, however, it has not been widely adopted as of the writing of this post.

This confusion originates from the early days of informatics. In computing, the most basic unit of information is the bit, which could be think of as a switch, it has only two states, on and off (1 and 0). Because you can't store but a certain state (on or off) in a bit, a bigger unit was created, the byte, which is just a group of bits. A byte consists of 8 bits, and this allows to represent a value, from 0 to 255.

The SI (International System of Units) defines that K (Kilo) denotes 1000, and M (Mega) represents 1000×1000, this is based in our base-10 numeric system. Originally 1 kilobyte meant 1000 bytes (103) and there was no confusion. However, in the world of computing, because everything is based on the bit, the numeric system in use is base-2. People noticed the convenience of denote 1 kilobyte as 1024 bytes (210), and one megabyte as 1024×1024 (220); instead of the SI Kilo and Mega convention, which denotes 1KB as 103 bytes, and 1MB 106 bytes.

Read more...

Categories: FOSS

xorg.conf configuration for a H770 series monitor

Saturday, May 21, 2011 | En Español

Just in case someone else need it (or in case I need it in the future). It is not a modern monitor, so it is not automatically configured.

Read more...

Categories: FOSS, Linux

Managing MySQL from the command line

Friday, March 18, 2011 | En Español

If our hosting service offer us a SSH shell and have MySQL installed, or if we have MySQL installed in our computer, we can administer a database from the Command Line Interface. If we develop programs that require the use of a MySQL database, most likely we are already familiarized with SQL statements. By the use of the mysql command we can send this queries to the database.

Read more...

Categories: Commands, FOSS, Linux, MySQL

Using rsync and cron to automate incremental backups

Tuesday, February 15, 2011 | En Español

Data loss is a serious concern to both individuals and companies that rely in the use of computers for their every day life or operations. Those who have a Unix based system count with powerful tools to prevent this, such as rsync to backup the information, and cron to make the backup process automated. In previous posts I wrote about the basics of rsync and it's usage as a daemon, as well as the basics of cron. In this post the focus is on the backup functionality of rsync, and its conjoint usage with cron to automate the backup process.

Read more...

Categories: Commands, FOSS, Linux, rsync, SSH

Vim and the x11 clipboard

Tuesday, February 08, 2011 | En Español

We can access the clipboard of x11 (the graphical system over which most desktop environments run, such as Gnome and KDE) to share text between Vim and other graphical applications.

x11 have two different global areas where it stores content to be shared between applications, one is known as the "cut-buffer", this is the location where the text that we copy or cut is stored, this is what most people associate with system clipboard. And the other is known as "selection", in x11, whenever we select something with our mouse, we can paste this selection in the location of the mouse cursor by pressing the middle button. Vim can access the content of both storages, get the text from this global storages, or put text on them.

Read more...

Categories: FOSS, Vim

Uppercase and lowercase characters in Vim

Sunday, February 06, 2011 | En Español

In Vim, we can turn characters to uppercase, lowercase or invert the case in a few key presses.

Read more...

Categories: FOSS, Vim

Configure the syntax highlighting in Vim

Saturday, February 05, 2011 | En Español

When we enable syntax highlighting (by using :syntax enable), Vim will take into consideration the extension of the file to determine the appropriate syntax highlighting rules, and if this fails it will search the contents of the file for specific patterns in order to determine the file type. But if we are working in a temporary file that we don't intend to save, or if we opened, e.g., a file with HTML extension but we find that it contains PHP code in it, we can change the rules of the syntax highlighting.

Read more...

Categories: FOSS, Vim

Configure unrecognized keys in Linux

Saturday, January 15, 2011 | En Español

Occasionally I am presented with keyboards that contain keys that are not recognized by default in Linux. In most cases the fix consist in select a different keyboard layout, modern Linux distributions cover a wide variety of keyboards, but some times there is no keyboard layout available that matches our keyboard and the functionality of some keys is lost. In this post I write about how to detect and map unrecognized keys. I am making the assumption that you are working in a graphical environment and that you want to give it some functionality to the key there.

Read more...

Categories: Commands, FOSS, Linux

Using cronjobs in Linux

Thursday, January 06, 2011 | En Español

cron is a daemon that allow us to schedule the launching of programs and scripts. This allow us to automate the execution of diverse tasks in our computer. cron is launched when we boot our computers and stays running in the background.

Read more...

Categories: Commands, FOSS, Linux

Running rsync as a daemon

Tuesday, January 04, 2011 | En Español

If the host computer is not running SSH (or RSH), we can configure and run rsync as a daemon in this computer. This would have rsync listening to the port 873 for incoming connections from other computers utilizing rsync. While this is not recommended for the transfer of files across unsecured networks, such as the Internet, because the actual data transfer is not encrypted, we can use this to keep information synchronized between different computers in internal networks, as well as perform backups.

Read more...

Categories: Commands, FOSS, Linux, rsync

Making better use of the Caps Lock key in Linux

Monday, November 15, 2010 | En Español

How frequently do we really use the Caps Lock key?, This is one of the best positioned keys in our keyboard, as it rests next to the A key, however, in this space we have this Caps Lock key that we seldom utilize. For those who type without looking at the keyboard it is an even more important space, as it is readily available with a minor movement of the left pinky. I am sure that there are people who do utilize it in a daily basis, but it is my understanding that this is a minority.

But this can be easily changed in Linux. And believe me, you wont regret this change once you grow accustomed to it. For a Vim user there is no question about what to do with this key, we can swap it for the Escape key, or turn it into a second Escape key, although I personally didn't want to lose the functionality so I just swapped it. Other possible uses are to turn it into another Backspace key, or into a Control key, we can even give it the functionality of a multimedia key.

Read more...

Categories: Commands, FOSS, KDE, Linux

My most used htaccess settings

Sunday, November 07, 2010 | En Español

The file .htaccess allows us to change some of the settings of a server for a particular directory and it's subdirectories. While it is preferable to make this type of configurations in the server configuration file itself by the use of a <Directory> section, sometimes we simply don't have access to this configuration file, specially when we have a shared hosting account. Most shared hosting providers allows us to make changes to the behavior of the server only in this way.

Read more...

Categories: Apache, FOSS, PHP

Synchronizing folders with rsync

Tuesday, November 02, 2010 | En Español

In this post I cover the basics of rsync, in preparation for a subsequent post that will cover backups and it's use in conjunction with cronjobs to automatize the backup process. From the copying and synchronization of local files and folders, to it's use for transfer information among computers. Its use as a daemon when SSH is unavailable was moved to it's own section.

Read more...

Categories: Commands, FOSS, Linux, rsync

Installing Slackware in an encrypted LVM

Saturday, October 02, 2010 | En Español

Introduction

When a laptop is lost or stolen (or it may be a desktop computer, but this is more likely to happen with a computer that we carry around), at first we may resent the price of the machine itself (and the personal data on the machine if you do not back-up frequently, which you really should, specially if you move your computer around a lot), until we realize that whomever is in possession of the computer posses access to all of our information: our photos, our documents, our media, all of our browser history, and, to make things worst, he/she may have access to sensitive information such as our credit card and log in information of the websites that we visit. If this lost computer used to belong to a corporate user, things are even worst, as whoever took possession of the computer may have obtain sensitive information about the company or about the clients of the company.

Read more...

Categories: FOSS, Linux, Slackware

Working with UTF-8 in PHP, MySQL and Apache

Wednesday, September 15, 2010 | En Español

As I have previously posted in this website, I believe it is a good idea to standardize in one character encoding across all parts of a system, and as my preferred character encoding is UTF-8, when I create a PHP system I check the following things:

  • That the browser receives and interprets the output of my PHP scripts as UTF-8.
  • That the (X)HTML forms accept UTF-8.
  • That PHP treats the data received from a MySQL database as UTF-8.

Read more...

Categories: (X)HTML, Apache, FOSS, MySQL, PHP

How to create a reverse SSH tunnel

Sunday, September 12, 2010 | En Español

Sometimes that we need to connect via SSH into another computer, we find out that this computer that we intend to SSH into (which we are going to call "destiny") may be utilizing NAT and therefore it doesn't count with a public IP address that we could use to connect to it, or it may be behind a firewall that won't allow access from the outside.

If "destiny" can successfully establish a SSH connection to another computer that is accessible, we can utilize this second computer to establish a reverse SSH tunnel to our "destiny" computer, we are going to call this second computer "origin" (even if it is not actually the computer that we are going to use to manage "target" remotely, but only a bridge).

Read more...

Categories: Commands, FOSS, Linux, SSH

Create a KTouch lecture from a list of words

Sunday, September 12, 2010 | En Español

Since I didn't find any lecture that I liked for KTouch, at least not one that allowed me to simply practice typing with a large number of random words, I thought it would be useful to create one based in random words taken from one of the lists of words usually located in /usr/share/dict, although this very same procedure can be use with any list of words. It didn't take to long to do it, but nevertheless it was interesting.

I include at the end the lecture that results from this procedure, as well as a lecture based in the words from the book The Adventures of Sherlock Holmes.

Read more...

Categories: Commands, FOSS, KDE, Linux, Text manipulation

Detecting and changing the encoding of text files.

Tuesday, August 24, 2010 | En Español

When you receive and need to handle multiple text files that use characters that are not natural to the English language, you may run into the problem that is dealing with different character encodings. This is particularly noticeable in websites, where if the browser try to interpret the text file with an encoding that differs from the actual encoding that the file is using, we can see strange symbols where this characters were supposed to show, but it is not limited to websites, any program that is made to work with languages other than English may present a similar problem if it is not appropriately handled.

Read more...

Categories: Commands, FOSS, Linux

Defining SSH servers

Sunday, August 22, 2010 | En Español

If we need to log in often to the same SSH server(s), instead of type the entire connection command every time that we do it, since a connection command that may go something like this:

ssh -p 34567 username@subdomain.domain.tld

We can create a SSH configuration file that would allow us to define the parameters of a server, and then start a connection to it by simply typing the name that we gave it.

Read more...

Categories: Commands, FOSS, Linux, SSH