r00t.gr

Programming and more

Entries for the ‘Linux’ Category

Install json (and pcre) for php (CentOS Linux 5.5)

Today I tried to run a script that was using json and got the following error: Fatal error: Call to undefined function json_encode()Fatal error: Call to undefined function json_encode() The problem was that the json library wasn’t installed. I researched google a little and I found how to install it and configure php to use […]

How to change user’s folder in linux (Ubuntu, CentOS, all unix)

To change the default user directory in linux, you have to run: usermod -d /path/to/new/homedir/ usernameusermod -d /path/to/new/homedir/ username You have to run this as root. If you don’t have root access, you can do that: Login with the user you want to change the folder. Then edit .bashrc file: vi ~/.bashrcvi ~/.bashrc And add […]

Install nginx v1.0.0 + php + eaccelerator + mysql + ftp + file and memory caching on an Ubuntu 10.04 System

I am designing at the moment a new website. I don’t want to reveal much, but i except this to have much traffic, and there will be a lot of php running in the background, and the site will use a very large database, and a remote API. So it is very important that i […]

How to avoid duplicate lines in Linux Command line (bash history)

I will try and explain the problem first. Many times, when you work with a linux machine, (in my case mostly CentOS) through command line, you write some commands. Many times you use the same commands more more than one times in a row. For example you run ls many times this command will be […]

Find large files in linux

How to get a list of large files in linux Usually in servers with large traffic, there are files, like logs, that grow uncontrollably. you want to find them and maybe create some rotate command to delete them from time to time. Another senario is, your hard disk is full, and you want to find […]

Find zero byte size files in a directory

I had one script running in one of my servers, to download some files. It was running with cron every day downloading new files. But one day i noticed something strange, some of my files where zero-sized. This was due to some downtime of the server i got the files from. So know i was […]

OpenVZ VPS and Java Memory Error and how to fix it.

There is a “bug” or more correctly an error when someone is trying to run a simple Java Program inside a OpenVZ (HyperVM, Virtuozzo) VPS. If you are in a harry and just want the answer, scroll down to the post and see it. It the story goes like this:   The problem: At first […]

Download and install Sun Java to CentOS system

I use java a lot, and i love the fact that the same program that you write and compile to windows, runs in Linux and virtually any other OS. But i have notice that by simply running   yum install java yum install java You get some other java impementation and not the Sun Java […]

Find out how much free memory (ram) do you have in linux

There are a couple ways to learn how much free RAM there is on your linux machine. The most accurate way though is:   free -m free -m And the output is: total used free shared buffers cached Mem: 7956 7704 252 0 196 6331 -/+ buffers/cache: 1176 6780 Swap: 12290 0 12289 What that […]