Split and merge files from the command line
Although some file archivers offer us the option of split the files, this
can be easily accomplished with two commands: split
and cat
.
Although some file archivers offer us the option of split the files, this
can be easily accomplished with two commands: split
and cat
.
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.
Categories: FOSS
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.
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.
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.
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.
In Vim, we can turn characters to uppercase, lowercase or invert the case in a few key presses.
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.
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.
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.
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.
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.
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.
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.
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.
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:
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).
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.
Categories: Commands, FOSS, KDE, Linux, Text manipulation
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.
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.