Month: September 2014

How to find a particular text string in Linux

You need to use the grep command. The grep command searches the given input FILEs for lines containing a match or a text string.

grep command syntax

The syntax is:

grep "text string to search" directory-path

or

grep [option] "text string to search" directory-path

or

grep -r "text string to search" directory-path

or

grep -r -H "text string to search" directory-path

or

egrep -R "word-1|word-2" directory-path

or

egrep -w -R "word-1|word-2" directory-path

Uncategorized

How to measure actual memory usage of an application or process?

How do you measure the memory usage of an application or process in Linux as ps is not an accurate tool to use for this intent.

Why ps is “wrong”?

Depending on how you look at it, ps is not reporting the real memory usage of processes. What it is really doing is showing how much real memory each process would take up if it were the only process running. Of course, a typical Linux machine has several dozen processes running at any given time, which means that the VSZ and RSS numbers reported by ps are almost definitely “wrong”.

With ps or similar tools you will only get the amount of memory pages allocated by that process. This number is correct, but:

  • does not reflect the actual amount of memory used by the application, only the amount of memory reserved for it
  • can be misleading if pages are shared, for example by several threads or by using dynamically linked libraries

If you really want to know what amount of memory your application actually uses, you need to run it within a profiler. For example, valgrind can give you insights about the amount of memory used, and, more importantly, about possible memory leaks in your program.

Uncategorized

Setting locale to en_US.UTF-8 failed

While trying to install Owncloud I encountered the following error:
Setting locale to en_US.UTF-8/fr_FR.UTF-8/es_ES.UTF-8/de_DE.UTF-8/ru_RU.UTF-8/pt_BR.UTF-8/it_IT.UTF-8/ja_JP.UTF-8/zh_CN.UTF-8 failed

Please install one of theses locales on your system and restart your webserver.
For Debian Linux the solution is very simple, just run the following command:
dpkg-reconfigure locales
And mark at least one of the locales you need.

Uncategorized