Re: Filesystem at 100% capacity, what files are large?

From: Dr. David Kirkby (drkirkby_at_ntlworld.com)
Date: 08/01/03


Date: Fri, 01 Aug 2003 17:08:02 +0100


> I was wondering if anyone had a script to find files with a directory
> and through the sub-directory path that are of a large size or over a
> specified size so that I can avoid these problems ahead of time in
> the future.

find / -size +50000000b

will find files over 50,000,000 bytes. In fact, if you replace the 'b'
by 'k', you can find files in kb, rather than bytes, which is a bit
more useful I would admit.

I've got a script that looks for potentially odd things, which I've
stuck at the bottom. It is customised for my machine, but it might
give you a few useful ways of using 'find'.

> Also, is there any way to allocate space from one filesystem to another?

Not aware of one. But you often get around problems of running out of
space on one file system by putting a directory on another file
system, but having a link between them.

Anyway, here's a script I run to find potentially odd files.

#!/bin/sh
PATH=/bin
export PATH
echo "first finding any files that are world writable" | tee
/tmp/findbad.file_world_writeable.$$
find / -type file -perm -o+w -print | tee -a
/tmp/findbad.file_world_writeable.$$
echo "now finding any directories that are world writable" | tee
/tmp/findbad.dir_world_writeable.$$
find / -type dir -perm -o+w -print | tee -a
/tmp/findbad.dir_world_writeable.$$
echo "now finding any files in /usr/local that are not world readable"
| tee /tmp/findbad.file_local_non_readable.$$
find /usr/local -type file ! -perm -o+r -print | tee -a
/tmp/findbad.file_local_non_readable.$$
echo "now finding any directories in /usr/local that are not world
readable" | tee /tmp/findbad.dir_local_non_readable.$$
find /usr/local -type dir ! -perm -o+r -print | tee -a
/tmp/findbad.dir_local_non_readable.$$
echo "now looking for any directories in /usr/local that are not world
executable" | tee /tmp/findbad.dir_local_non_executable.$$
find /usr/local -type dir ! -perm -o+x -print | tee -a
/tmp/findbad.dir_local_non_executable.$$
echo "finally checking that /usr/local/samba and
/usr/local/etc/sudoers are only readable to root" | tee
/tmp/findbad.local_security.$$
'ls -l /usr/local/samba' | tee -a /tmp/findbad.local_security.$$
ls -l /usr/local/etc/sudoers | tee -a /tmp/findbad.local_security.$$
echo "Find files with a user not in the password file" | tee
/tmp/findbad.no_owner.$$
find / -nouser -print | tee -a /tmp/findbad.no_owner.$$
echo "Find files with a group not in the password file" | tee
/tmp/findbad.non_group.$$
find / -nogroup -print | tee -a /tmp/findbad.non_group.$$
echo "Find any files with the uid bit set" | tee
/tmp/findbad.uid_set.$$
find / -perm -u+s -print | tee -a /tmp/findbad.uid_set.$$
echo "Find any files with the gid bit set" | tee
/tmp/findbad.gid_set.$$
find / -perm -g+s -print | tee -a /tmp/findbad.gid_set.$$
echo making all files under /export/home/davek owned by davek
chown -R /export/home/davek davek
echo "Find any files under /export/home that belong to root" | tee
/tmp/findbad.are_root.$$
find /export/home -user root -print | tee -a /tmp/findbad.are_root.$$
echo "Find any files over 50Mb" | tee /tmp/findbad.big.$$
find / -size +50000000b | tee /tmp/findbad.big.$$

-- 
Dr. David Kirkby,
Senior Research Fellow,
Department of Medical Physics,
University College London,
11-20 Capper St, London, WC1E 6JA.
Tel: 020 7679 6408 Fax: 020 7679 6269
Internal telephone: ext 46408
e-mail davek@medphys.ucl.ac.uk


Relevant Pages

  • Re: Possible bug with tee or variable scope ??
    ... below shows a variable not changing when tee is used and changing (as ... echo " Fn before: $Name." ... And "echo foo" is not started in a subshell (zsh ... via a pipe and tees it to both stdout and some-file, ...
    (comp.unix.shell)
  • Re: print screen and file
    ... echo "ble message" | tee /tmp/new_file ... I recommend `man tee' ... It appends "root log " to /var/log/mylog.log, ... If you want to echo ...
    (comp.unix.shell)
  • Re: Possible bug with tee or variable scope ??
    ... We see exactly the same behavour with a borne parent as well on ... (the sub shells may be ksh on hp-ux, bash on Linux, borne on Solaris ... And if the tee is spawned off in a subshell ... echo " Fn before: $Name." ...
    (comp.unix.shell)
  • Re: Problem with periodically done scripts
    ... + echo Checking for uids of 0: ... tee /dev/stderr ... echo Checking for passwordless accounts: ...
    (freebsd-questions)