CLI

Failed to decompress file .tar.bz2

Debian GNU/Linux

If when you try to unpack a file .tar.bz2, you get the following error messages:

tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2

You must solve it by installing the bzip2 package

# apt-get -y install bzip2

Further reading

– man tar

Change the keyboard settings in GNU/Linux

GNU/Linux
Advanced desktop manager as: GNOME, KDE, XFCE offered an easy way to change the keyboard setting using GUI, distributions as BLAG, CentOS, RHEL and Fedora offer the tool: system-config-keyboard; but also we can use the setxkbmap command. setxkbmap allows you to change the settings on our keyboard for X sessions.

Access the same content from 2 different locations of the file system

GNU/Linux
Today LibreByte brings a very interesting trick: how to access the same content from 2 different locations of the file system. If you have been installed an Apache HTTPD server to develop your web applications but want to have the files in your $HOME directory and at the same time want the document root would be at /var/www then we would follows this steps:

$ mkdir ~/www

Then we would add this line to the /etc/fstab file

/home/miusuario/www /var/www 	none 	bind

Then we execute

# mount -a

The 2 previous command links /home/miusuario/www and /var/www to the same content, allowing access to such content from both directions.

If you need that Apache has write access in a DIR within /var/www we should make use of ACL for it you can use acl-webdev script that allows you to easily set permissions so that your user name and the user under which runs the Apache can write in the wished DIR.

For example, you want that your username and the apache user can write to the dir /var/www/cache or /home/miusuario/www/cache then we execute the above script in the following way:

$ ./acl-webdev www/cache apache:apache

It is assumed that before running the above command you has downloaded the acl-webdev script and you given it execute permissions

Further readings

– man mount

Listing directories, 7 practical examples

GNU/Linux

ls is a utility that list information for any file type including directories, by default (when not passed any option) ls displays the contents of the current (or specified) DIR no recursively, ordered alphabetically and ignoring the hidden files/directories.

Rename in mass

GNU/Linux
prename is a utility developed in Perl by Larry Wall (creator of the Perl language) and improved by Robin Barker, which allows you to rename in masses. prename finds all files whose name matches a pattern specified (REGEXP). This utility is part of the perl package in Debian GNU/Linux.

Error decompressing .tar.xz file

Debian GNU/Linux

When you try to unpack a .tar.xz file you get the following error messages:

tar (child): xz: Cannot exec: No such file or directory
(child) tar: Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Get the size of a directory/file on GNU/Linux

Desktops such as GNOME, KDE, LXDE, XFCE offer an easy way to determine the size of a file or directory, right-click on the file in question, select properties from the context menu, but environments servers we dont like those mentioned above so it should resort to the CLI and make use of the du command which calculates the space occupied by a file or directory