Search
Categories
Ad

Posts Tagged ‘linux’

order directories by size

Monday, June 7th, 2010

Problem

You want to see which directory is the biggest in size.

Solution

% du / | sort -nr

Run mulitple ‘exec’ commands to UNIX ‘find’ command

Tuesday, March 30th, 2010

Problem

You want to apply multiple commands against the results of ‘find’

Solution

Just pass as many exec options as you want :) .

The command below will run ‘id’, ‘echo’ and ‘file’

% find . -type f -exec id {} \; -exec echo ' and ' \; -exec file {} \;

installing phpmyadmin (or other linux-world softwares) to Ubuntu 9.10 server

Monday, February 1st, 2010

Problem

You want to install open-source softwares like phpmyadmin to your ubuntu 9.10, but you got errors.

E: Couldn't find package phpmyadmin.

Solution

Add universe components to your sources.list

deb http://archive.ubuntu.com/ubuntu karmic main universe multiverse restricted
deb-src http://archive.ubuntu.com/ubuntu karmic main universe multiverse restricted
 
deb http://archive.ubuntu.com/ubuntu karmic-updates main universe multiverse restricted
deb-src http://archive.ubuntu.com/ubuntu karmic-updates main universe multiverse restricted
 
deb http://archive.ubuntu.com/ubuntu karmic-security main universe multiverse restricted
deb-src http://archive.ubuntu.com/ubuntu karmic-security main universe multiverse restricted

Check your SIMBL version

Thursday, January 14th, 2010

Problem

You want to know which version of SIMBL is installed on your machine.

Solution

On Leopard,

% head /Library/InputManagers/SIMBL/SIMBL.bundle/Contents/Info.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>CFBundleGetInfoString</key>
        <string>0.8.2, © 2007 Mike Solomon</string>

On Snow Leopard,

% head /Library/Receipts/SIMBL.pkg/Contents/Info.plist

Accidental Server Down … (and so sorry for that!)

Tuesday, September 29th, 2009

My webserver was down since 13th September. It was an accident, and I did not know that until today.
No apache2 processes alive. my web server has gone away by some reasons.

So I started a deep investigation on log files.

When I checking through auth.log files with

cd /var/log;sudo find auth.log -type f -exec grep Success {} /dev/null \;

and I found a lot of

auth.log.5.gz:Aug 29 10:46:03 Shaseki su[6944]: Successful su for nobody by root
auth.log.5.gz:Aug 29 10:46:03 Shaseki su[6949]: Successful su for nobody by root
auth.log.5.gz:Aug 29 10:46:03 Shaseki su[6951]: Successful su for nobody by root

Was my server hacked by someone…? Some clever guy attacked my server and got my root password anyhow, so that he can take full control over my machine??

At the first time I saw these messages, I was so astonished and could not say a word.
But in a few minutes I came to myself and googled that message, and I was relieved.

It was not by a unknown hacker. this is by cron. Open /etc/crontab and found that

11 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
46 10    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
15 10    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly 
)
50 10    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly
 )

As you can see, the time in log messages are almost same as that in crontab.

Hmmmm, So what the hell made my apache gone away?

When I tried to restart my apache like

sudo /usr/sbin/apache2ctl -k start

I got

(98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

,so I could not start up my apache.

Obviously, some process already hold port 80. but

lsof -i :80

returns nothing. I also tried

nestat -an

, but could not find any clues of por-80-riders.

At last, thoght this is what I did not like to, I rebooted the system.

In a few minutes, everything comes back well and, as you see, my apache2 starts running healthly again.

If you know something about such a phenomenon, please leave a comment below. Thank you in advance!

Clear ques of Postfix

Friday, August 28th, 2009

Problem

You want to delete all the messages in sending ques of Postfix.

Solution

$ sudo postsuper -d ALL

No response of Sudo on Fedora 11

Tuesday, August 4th, 2009

Problem

On Fedora11 installed via Vmware, sudo does not respond for thirty or fourty secs.

Solution

The cause is that sudo is looking up your hostname to DNS, and waiting until TIMEOUT event is fired. You can fix this problem by just adding your hostname to /etc/hosts

 su -
 nano /etc/hosts
 127.0.0.1       localhost localhost.localdomain <yourhost> <yourhost>.localdomain localhost4 localhost4.localdomain

Upgrading Ubuntu using CUI: From 7.10 Gusty to 9.04 Jounty

Wednesday, July 15th, 2009

Problem

You want to uprade Ubuntu Linux to the latest version. (9.04 at this time)

Solution

to 8.04 Hardy

If your version is old enough that when you type

>sudo apt-get upgrade

and you will see 404 Errors, then You have to edit your sources.list like this.

$ sudo -s
# mv /etc/apt/sources.list /etc/apt/sources.list.gusty
# sed -e 's/gusty/hardy/g' /etc/apt/sources.list.gusty > /etc/apt/sources.list
# apt-get update
# apt-get upgrade

Then, install update-manager.

$ sudo apt-get install update-manager-core

to 8.10 Intrepid

$ sudo -s
# mv /etc/apt/sources.list /etc/apt/sources.list.hardy
# sed -e 's/hardy/intrepid/g' /etc/apt/sources.list.hardy > /etc/apt/sources.list
# apt-get update
# apt-get dist-upgrade

Intrepid to Jounty

sudo apt-get update
sudo apt-get upgrade
sudo do-release-upgrade

Finally, you can check your Ubuntu version like this.

cat /etc/lsb-release

Checking Ubuntu Version

Wednesday, July 15th, 2009

Problem

You want to check the Ubuntu version from a CUI terminal

Solution

You can find the version info here.

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.04
DISTRIB_CODENAME=jaunty
DISTRIB_DESCRIPTION="Ubuntu 9.04"

g++ on RHEL 5

Wednesday, June 17th, 2009

Problem

g++ is not installed on your Redhat EL 5 at default.

Solution

Try;

% yum install gcc-c++ compat-gcc-*
% which g++

If you still not find g++, maybe g++ is saved as g++32 in /usr/bin. If so, create a symbolic link to g++32.

% ln -s /usr/bin/g++32 /usr/bin/g++