Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Monday, December 19, 2011

Find directory with biggest number of files / directories

Today we had a problem related with a number of files in a directory. We needed to find directories with a biggest number of files / directories in it. Here is a small shell script that will list directories and a number of files/directories in each directory.

find . -type d|awk {'print "echo -n "$1".\"\t\"; ls "$1"|wc -l"'} > /tmp/do; . /tmp/do|sort -k 2 -n -r |more

Explaining it a little bit:

"find . -type d" - find all directories bellow current directory
"awk {'print "echo -n "$1".\"\t\"; ls "$1"|wc -l"'} > /tmp/do" - generate a script that will print a directory name (echo -n), make ls in this directory and count a number of lines from ls (wc -l)
". /tmp/do" - execute generated script
"sort -k 2 -n -r" - sort the result using second column (-k 2) as numerical (-n) and in reverse order (-r)

Sunday, November 8, 2009

VMware crashes after updating (upgrading) of host OS (to CentOS 5.4)

If you have in your hostd.log something like this:

Nov 07 21:19:12.648: Worker#23| Caught signal 6 -- tid 31543

this can be related with update(upgrade) of host OS.

After upgrading of a host OS (CentOS 5.3->CentOS 5.4) I got an issue - a guest OS started to crash. Searching around for a possible cause I found bug post in CentOS bug tracker. Seems that issue is related to glibc update (last version is glibc-2.5-42) and a fix is to downgrade to previous version on host OS (glibc-2.5-34).

To be sure that your downgrade of glibc worked - check the size of libc-2.5.so. I got an issue on downgrade (even with --oldpackage rpm was not willing to replace a libc), and that's why I lost some hours trying to figure out what is going on. So, be sure to check the size of the files after downgrade. It can save you some hours :)

Tuesday, July 7, 2009

VMware troubles

Well, I'm not a hardware guru, but from my experience I figured out the following:


Dell Servers + QLogic HBA + IBM Storage = troubles
Dell Servers + Emulex HBA + IBM Storage = working ok
Dell Servers + QLogic HBA + EMC Storage = working ok

Other one issue is:

Any server + Any HBA + Any storage - Fiber Channel Switch = troubles (unclean filesystem on Linux guests with EXT3 filesystem)

Monday, May 25, 2009

"Network Connection Closed Unexpectedly" error while using svn+ssh

If you got a "Network Connection Closed Unexpectedly" error while using svn+ssh (here is a nice HOWTO) then you should comment (or remove) "mesg y" in /etc/bashrc or in $HOME/.bashrc


Worked for me as a charm :)

Tuesday, May 13, 2008

List number of file handles (open files) for each process

Here is a simple script that will show you a number of file handles (open files) used by each process on your Linux system:


ps -e|grep -v TTY|awk {'print "echo -n \"Process: "$4"\tPID: "$1"\tNumber of FH: \"; lsof -p "$1"|wc -l"'} > out; . ./out

Tuesday, April 8, 2008

Cent OS 5.1 + Oracle 10g

Apart of modifying /etc/redhat-release to "redhat-4", there are a couple of packages that you will need to install in order to make Oracle 10g work with Cent OS 5.1:


yum install \
compat-db-4.2.52-5.1 \
glibc-devel-2.5-18.el5_1.1 \
libX11-devel-1.0.3-8.0.1.el5 \
libXau-devel-1.0.1-3.1 \
libXdmcp-devel-1.0.1-2.1 \
libXmu-1.0.2-5 \
libXtst-devel-1.0.1-3.1 \
mesa-libGL-devel-6.5.1-7.5.el5 \
openmotif-2.3.0-0.3.el5 \
xorg-x11-proto-devel-7.1-9.el5.centos

Wednesday, February 13, 2008

Leopard terminal and Midnight Commander

If you use mc while connected to some linux server and you need to select some files - use Ctrl+T

Thursday, January 31, 2008

Perl: CPAN or RPM packages?

Maybe this is just CentOS 5.1 related issue, but...
 
For those of you who will install MailScanner - just a small tip to avoid problems. Spend some time and install required perl modules from CPAN. This will save you some time on fixing SpamAssassin and some other perl modules.

Wednesday, January 16, 2008

Reverse tunnel with SSH

When you need to create a reverse tunnel with SSH, just use the following:

 
ssh -R PORT_ON_REMOTE_SERVER:localhost:PORT_ON_LOCAL_SERVER -l LOGIN REMOTE_SERVER

More comfortable environment

After installing new Linux or Unix system I like to edit /etc/profile or $HOME/.bash_profile and add following lines:

 
alias vi="vim -o"
alias ll="ls -l"
alias la="ls -la"
export EDITOR=vi
 
First line is to use vim instead of vi. Second and third lines will create two aliases for ls -l and ls -la commands. And forth line is to use vi always as system editor. 
 
YES, I love vi!

Rebooting linux without reboot command

Just a sample of how you can reboot or shutdown linux without issuing reboot command, so called hard reboot. That means that system will just make a reset as if you pressed a reset button, without running any shutdown scripts, etc. A kind of dangerous staff, but can be helpful in some occasions.


echo 1 > /proc/sys/kernel/sysrq 
echo b > /proc/sysrq-trigger
 
If you want to force shutdown machine try this.

echo 1 > /proc/sys/kernel/sysrq
echo o > /proc/sysrq-trigger