Installing eAccelerator In Ubuntu Server
eAccelerator is a free open-source PHP accelerator & optimizer. It increases the performance of PHP scripts by caching them in their compiled state, so that the overhead of compiling is almost completely eliminated. It also optimizes scripts to speed up their execution.
“eAccelerator typically reduces server load and increases the speed of your PHP code by 1-10 times.” – eAccelerator
CentOS Firewall Init Script
I wrote a simple chkconfig compatible firewall init script for CentOS/RedHat/Fedora based Linux systems.
It will setup iptables firewall rules allowing anyone to access user defined ports (22,80 by default). It also has the ability to whitelist and blacklist IP’s. I’ve tested it with chkconfig on CentOS 5.
Print next few lines after pattern in AWK
Input data.txt is a collection report for XYZ corp group by different collection zones.
$ cat data.txt Total Collection = $10291 {Fri May 8} zone7 4500 zone8 3545 zone1 1200 zone0 900 zone3 70 zone5 67 zone11 9 Total Collection = $11847 {Sat May 9} zone1 2800 zone3 2800 zone6 2567 zone8 2300 zone9 1200 zone12 90 zone11 90
Required: We need to find out the top 4 collection zones for each day from the above file. i.e. to print next 4 lines where the pattern “Total Collection =” is found (as the items are sorted on collection amount).
This is how we can achieve this using awk:
$ awk '/^Total Collection =/{c=4;next}c-->0' data.txt zone7 4500 zone8 3545 zone1 1200 zone0 900 zone1 2800 zone3 2800 zone6 2567 zone8 2300
Now if we need to print the header line also, something like:
$ awk '/^Total Collection =/{c=4;{print}next}c-->0' data.txt Total Collection = $10291 {Fri May 8} zone7 4500 zone8 3545 zone1 1200 zone0 900 Total Collection = $11847 {Sat May 9} zone1 2800 zone3 2800 zone6 2567 zone8 2300
And if you want to just print the date part as the header with top 4 collection zones.
$ awk -F "[{,}]" '/^Total Collection =/{c=4;{print $2}next}c-->0' data.txt Fri May 8 zone7 4500 zone8 3545 zone1 1200 zone0 900 Sat May 9 zone1 2800 zone3 2800 zone6 2567 zone8 2300
Multiple FS in AWK
Sample file:
$ cat summary.txt A|Jan|clerk|02:45 B|Jan|Salesman|02:12 C|Jan|Accountant|03:12 A|Feb|clerk|01:10 B|Feb|Salesman|11:10 B|March|Salesman|3:10 C|Feb|Accountant|3:34
Output Required:
(First field)|(last field converted to minutes)
i.e. A|165 B|132 C|192 A|70 B|670 B|190 C|214
This is how we can specify two field separators (| and 🙂 with FS in awk:
$ awk 'BEGIN{FS="[|,:]"; OFS="|"} {print $1,$(NF-1)*60+$NF}' summary.txt
How to change the hostname in Ubuntu
To change hostname in Ubuntu or any Debian variant Linux, modify the /etc/hostname and /etc/hosts.
sudo vi /etc/hostname
Change the old hostname to a new hostname.
sudo vi /etc/hosts
Also, change the oldhostname to a new hostname,
192.168.1.100 newhostname
After done, changing the /etc/hostname and /etc/hosts, you need to restart the hostname service.
sudo /etc/init.d/hostname.sh stop
sudo /etc/init.d/hostname.sh start
And then you log out from the shell and log in back. Once logged in, type
hostname
to check on the changes you have made for the hostname.
Ubuntu auto shutdown due to high CPU temperature
I use a laptop with Ubuntu 8.10 installed at work. While running the some high process, the CPU temperature get really high and its automatically shutdown the system. This thing happen every 2 or 3 days and its really annoying. The syslog showed the following error message:
ACPI: Critical trip point
Critical temperature reached (100 C), shutting down.
How to reset Ubuntu root password
If your memory or mistyping leaves you without the right password to get into an account on a Linux computer, there’s no need to reformat. You’ll just need to reboot into single user mode to reset it. Here’s how to do it on a typical Ubuntu machine with the GRUB bootloader:
- Reboot the machine.
- Press the ESC key while GRUB is loading to enter the menu.
- If there is a ‘recovery mode’ option, select it and press ‘b’ to boot into single user mode.
- Otherwise, the default boot configuration should be selected. Press ‘e’ to edit it.
- Highlight the line that begins with ‘kernel’. Press ‘e’ again to edit this line.
- At the end of the line, add an additional parameter: ‘single’. Hit return to make the change and press ‘b’ to boot.
The system should load into single user mode and you’ll be left at the command line automatically logged in as root. Type ‘passwd’ to change the root password or ‘passwd someuser’ to change the password for your “someuser” admin account.
Reboot
Once your done, give the three finger salute, or enter ‘reboot’ to restart into your machine’s normal configuration.
That’s all there is to it. Now just make sure to write your password down on a post-it and shove it somewhere safe like under your keyboard. 🙂
[ Source: Hackzine.com ]
How to setup headless Sun xVM VirtualBox on Ubuntu server
The steps are not too difficult but I did have to find a few places for information. Search on the forum turn up nothing on this subject so hopefully this HOWTO would be helpful to someone out there.
Note: This is not using the OSE version.
Background:
VirtualBox has a very good GUI running on the host to manage guest OS. However when running a server, we typically do not want to run X on it. Fortunately VirtualBox has commandline tools to manage guest systems. It also provides the VirtualBox Remote Desktop Protocol (VRDP) to allow connection to the guest remotely.
Clarification of terms used:
Host – refers to the machine we are trying to install VirtualBox.
Guest – the VirtualBox guest system that is setup on the host.
Remote – the PC that we are working on to connect to the host via SSH.
This setup was done on a fresh install of Ubuntu Server 8.04 with openssh-server installed.
All the following steps are done by SSH into the host from a remote (I’m using Windows for now).
Google Chrome (BETA) for Windows
Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier.
One box for everything
Type in the address bar and get suggestions for both search and web pages.
Thumbnails of your top sites
Access your favorite pages instantly with lightning speed from any new tab.
Shortcuts for your apps
Get desktop shortcuts to launch your favorite web applications.
[ Source: Google Chrome ]