Sorting folders by size

Sorting folders by size

Blog Linux

To know about used space of each partition, we usually use df command. See example below:

And we get a result like this:

In some cases, we’ll add sudo before command to list partitions mounted by others users.

When we need to know about the size of each folder, linux provide us other special program called du.

Such as other programs, du has a lot of arguments and its can combined with other programs like sort.

Now, to get some folders sorted by size, we can send ‘du -h’ output to sort program:

All folders and sub folders will be printed sorted by their sizes. If you limit by only first depth, you can use –max-depth arg.

You’ll get a output like:


Setting static IP address and DNS nameserver to network interfaces

Setting static IP address and DNS nameserver to network interfaces

Blog Linux

If you’re installing an Ubuntu server, and you need set to it a static IP address and some nameservers, you can use the power of bash for it :). To set a static address for an interface, eth0 for instance, you can do this:

And put in this file the lines as below:

Pay attention for two last lines, those lines will be up your interface using those DNS nameservers. With it you don’t need to set a nameservers on /etc/resolv.conf, once on Ubuntu’s boot you erase all your modifications on it.

Comparing to CentOS, the boot process doesn’t replace dns-nameservers of /etc/resolv.conf, particularly I like it, I don’t see no reasons to Ubuntu clean this file.

Deleting files inside a zip file on Linux

Deleting files inside a zip file on Linux

Blog Linux

Sometimes when we’re working with zip files, we need to remove some files inside it to doesn’t override another files during extraction. Linux has a special app to this, we’re talking about zip.

Debian based distros like Ubuntu, Mint, etc., already have this program installed, CentOS for instance doesn’t have installed, so, to install it you will do this:

To those distros, the way to use zip app it’s the same.

Deleting specific files inside a zip file

If you want to delete one or more specific files, you can do this:

Like /bin/rm command, this app also can receive N parameters on –delete arg.

If you want to delete directories inside a zip file, it is the almost same way, but you will add “/*” at the end of string arg. Bellow you have an example of it:

Pay attention to the last parameter, “directory3/sub-folder/*”, in this case, the folder “sub-folder” will be deleted from “directory3” folder.

Be happy : )

Removing deepin-translator from DDE

Removing deepin-translator from DDE

Blog Linux

Deepin is a Chinese Ubuntu-based distro that contains a powerful and very beautiful graphical interface called DDE (deepin-desktop-environment). This interface has a lot of usual features like side control panel, custom software center, an elegant dock menu and the main reason, no critical bugs like Gnome 3 or Unity. You can read more about Deepin here.

One of this features is deepin-translator, this plugin allows for user to quickly translate any selected text putting mouse cursor hover selected text or pressing Ctrl key hover this text. If you’re a developer, sometimes this resource let your work so awful on Eclipse, SQL editors, because you are all time selecting SQL statements to copy-past between editors and deepin-translator always appears hover your selected text, and sometimes it breaks your copy-paste.

To be free of this headache, you can kill the process or remove it from your system. I prefer remove this package, because I really don’t need to translate anything, so to remove you’ll run the command bellow:

Now, feel free from this plugin : )

Mounting USB disks to write live USB

Mounting USB disks to write live USB

Blog Linux

When you are trying to write live USB images of Ubuntu based distros, you’ll need to mount your USB device in a mount point as /media/pendrive/. With tools like UNetBootin you’ll get a message like this:

You must first mount the USB drive /dev/sdb1 to a mountpoint.

So, while you don’t mount your USB device, you cannot proceed with you disk installation. Then, it’s so easy to fix this, you only need do this step before:

Next, mount your device to this folder:

Now, use your prefered tool to write your live USB disk. Here I’m using Unetbootin:

It’s done, now just umount your device and install your unix OS.

If you want know more about advanced mount options, you can access the Help Wiki on link below:

Setup serviio DLNA server on Ubuntu based distros

Setup serviio DLNA server on Ubuntu based distros

Blog Linux

Serviio is a powerful Java media server (DNLA) for Linux, Windows and Mac. After Ubuntu 12, some packages were removed from repositories, such as ffmpeg, that which one is a main dependency os Serviio. So, if you are in distros based on newer versions of Ubuntu (12+), you’ll need to obtain this package from another source, or you can use the steps below.

Add a ffmpeg PPA repository:

After you’ll must update apt’s package list:

Now, install ffmpeg package:

Another required package is dcraw, this one has lots of functions to process and decode images. Some distros have this package, but if you don’t have installed yet, just install it:

To run Serviio just execute your bash file:

And for access GUI:

To inspect Serviio’s logs, you can use tail command:

Enjoy :)

Fixing wrong charset on gedit

Fixing wrong charset on gedit

Blog Linux

If you have problems with charset when you’re editing documents on GEdit, you can fix it changing encoding settings on Gnome environment. For it, use this:

However, you need to check your system locale, on Debian based you can use dpkg-reconfigure for it:


How to send a broadcast message on Ubuntu-based distros

How to send a broadcast message on Ubuntu-based distros

Blog Linux

Sometimes we need to notify another users connected by SSH in same server with a simple message like when we use ‘halt‘ or ‘init 0‘ commands. Ubuntu-based distros have a special program to it, it’s wall. Then, to send a broadcast message for all connected users in server terminal, you can use:

Now, all of SSH users will receive a message like this:

Associating JNLP files on Gnome 3

Associating JNLP files on Gnome 3

Blog Linux

On Gnome 3, the support for mimetypes is more better than compared with old Gnome 2. Now we have a mimetype repository for all files types, where we can easily customize rules to manage apps per files, or files per apps (too!).

Java WEB (Java WEB Start) apps use JNLP or JSP files to open him on client browsers and desktops, the problem starts when we try to open these files on file explorer, they always open on our browsers (Chrome, Firefox, etc.) by default. To change this, we need to do few changes by terminal. Then, follow these steps:

Access the managed mimetypes folder:

Then, create a new file to associate your javaws command with JNLP files. This step requires sudo permission.

Ok, now put this content in this file:

Pay attention to this line:

You’ll put the location of your javaws executable at JVM folder. On Ubuntu-based distros the installation folder always is at /usr/lib/jvm/.

Now, we need registry this new configuration for gnome mimetypes manager. To do this, do this:

At the end of this file, put a new entry referring your previous file ‘javaws.desktop’, like this:

Save and close the file.

Now, you can test across browser or your favorite file explorer.

How to fix the big guy called ‘ibdata1’

How to fix the big guy called ‘ibdata1’

Blog Databases Linux

The file ibdata1 is the system tablespace for InnoDB infrastructure, and it contains several informations about InnoDB such as table data pages, index pages, data dictionary, rollback segments, etc. This file is always growing, then, it’s easy to reach to giant sizes.

The size of this file commonly affects development and test machines, because many drops and imports with databases inflate this one. Then, to fix this problem, I have some steps to ends this problem.

Backup all your databases

Do a full dump of your databases.

Drop all your databases

Now, you’ll need remove all your databases, except for mysql and information_schema databases, because they are used by MySQL to control users and data information about managed databases.

Stop MySQL service

For the next step, you will need stop the MySQL service.


Now, you’ll need change in MySQL how it’s manage InnoDB data, in this case using one file per table. Locate the my.cnf file on your server and putt this parameter at [mysqld] section:

Save with ‘Esc + :wq!’, then go to MySQL data folder:

The ls -alh command in this folder will print something like this:

Delete this file:

Finally, start MySQL service and import your databases again: