Thursday, September 4, 2008

Finding large files on ubuntu/debian

Yesterday our LTSP server which runs on debian suddenly stopped working. After some investigation I found out that free hard disk space on the server was very low. The machine has 500+ accounts. I had to locate big files for back up.

The following code can be used for this.
 
$ find /home/sunil -type f -size +20000k -exec ls -lh {} \; | awk '{ print $8 ": " $5 }'


You can replace /home/sunil with what ever path you want to search. Also you can try changing the size from 20000k( 20MB) to some other value.

Sunday, August 17, 2008

Looking at man pages

One of my friends was asking how to look into the correct man page.

The Unix man pages are generally divided into the following sections.

Section Description
1 General commands
2 System calls
3 C library functions
4 Special files (usually devices, those found in /dev) and drivers
5 File formats and conventions
6 Games and screen savers
7 Miscellanea
8 System administration commands and daemon
You can look in various sections

$ man 5 passwd
$ man 1 passwd
The first command above gives you details about the structure of /etc/passwd, whereas the second command above will give you details about passwd command.
If you want to get all man page sections , you must install the following packages on (
debian/ubuntu)
manpages-dev - Manual pages about using GNU/Linux for development
manpages - Manual pages about using a GNU/Linux system


You can also try installing the package funny_manpages

Exploring the proc diretory on Linux

The /proc directory on ubuntu ( or any other linux ) is an interesting place to look at. See this listing.

sunil@debian:~$ ls /proc
1 2043 23019 31945 6893 devices key-users swaps
10 2234 2426 32039 6894 diskstats kmsg sys
10003 2239 2471 4 693 dma loadavg sysrq-trigger
101 2240 24877 5 7014 driver locks sysvipc
1135 2246 24878 591 705 execdomains meminfo tty
1292 2247 2508 5934 885 fb misc uptime
13872 2248 2509 6 9 filesystems modules version
13923 2249 2510 609 969 fs mounts vmstat
142 2250 2511 611 acpi ide mtrr zoneinfo
143 2254 2512 6857 asound interrupts net
1492 2255 2515 6858 buddyinfo iomem partitions
1510 2258 27933 6859 bus ioports scsi
1771 2261 27970 6860 cmdline irq self
2 22998 27971 6876 cpuinfo kallsyms slabinfo
2037 22999 3 6891 crypto kcore stat

This directory is not residing on your hard disk. Instead it is a snapshot of things inside your kernel. You can see a lot of numbers in the listing above. These refer to various processes running on the system. There are several files you can peek at in /proc . Look at cpuinfo.

sunil@debian:/proc/6891$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 4
model name : Intel(R) Celeron(R) CPU 2.66GHz
stepping : 9
cpu MHz : 2660.155
cache size : 256 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 5
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx lm constant_tsc up pni monitor ds_cpl tm2 cid cx16 xtpr lahf_lm
bogomips : 5325.03

This file give you all the information the currently running kernel has , about your processor.
You can explore the rest of the files to find out a lot of system and network related information.