order directories by size
Monday, June 7th, 2010Problem
You want to see which directory is the biggest in size.
Solution
% du / | sort -nr
| NiceCabbage Blog |
| Life, Design, Web Application |
You want to see which directory is the biggest in size.
% du / | sort -nr
You want to apply multiple commands against the results of ‘find’
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 {} \;
You want to install open-source softwares like phpmyadmin to your ubuntu 9.10, but you got errors.
E: Couldn't find package phpmyadmin.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
You want to know which version of SIMBL is installed on your machine.
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
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!
You want to delete all the messages in sending ques of Postfix.
$ sudo postsuper -d ALL
On Fedora11 installed via Vmware, sudo does not respond for thirty or fourty secs.
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
You want to uprade Ubuntu Linux to the latest version. (9.04 at this time)
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
$ 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
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
You want to check the Ubuntu version from a CUI terminal
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++ is not installed on your Redhat EL 5 at default.
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++