System, User and Access information in linux
Who and What is doing What on Your System - finding open sockets,files etc.
$ lsof
or as root
$ watch lsof -i
To list all open Internet files, use:
$ lsof -i -U
You can also get very specific about ports. Do this as root for low
ports.
$ lsof -i TCP:3306
Or, look at UDP ports as follows:
$ lsof -i UDP:1812
Also try fuser. Suppose you have a mounted file-system, and you need
to umount it. To list the users on the file-system /work
$ fuser -u /work
To kill all processes accessing the file system /work in any way.
$ fuser -km /work
Or better yet, maybe you want to eject a cdrom on /mnt/cdrom
$ fuser -km /mnt/cdrom
If you need IO load information about your system, you can execute
iostat. But note, the very first iostat gives a snapshot since
the last boot. You typically want the following command, which gives
you 3 outputs every 5 seconds.
$ iostat -xtc 5 3
Linux 2.6.12-1.1376_FC3smp (squeezel.squeezel.com)
Time: 07:05:04 PM
avg-cpu: %user %nice %system %iowait %idle
0.97 0.06 1.94 0.62 96.41
Time: 07:05:09 PM
avg-cpu: %user %nice %system %iowait %idle
0.60 0.00 1.70 0.00 97.70
Time: 07:05:14 PM
avg-cpu: %user %nice %system %iowait %idle
1.00 0.00 1.60 0.00 97.39
vmstat reports memory statistics. for vmstat for
I/O subsystem total statistics.
$ vmstat
$ ifconfig
$ cat /proc/sys/vm/.. (entries under here)
Also
$ cat /proc/meminfo
$ cat /proc/stat
$ cat /proc/uptime
1078623.55 1048008.34 First number is the number of seconds since boot.
The second number is the number of idle seconds.
$ cat /proc/loadavg
0.25 0.14 0.10 1/166 7778 This shows load at 1,5, and 15 minutes,
a total of 1 current running process out
from a total of 166. The 7778 is the last
process id used.
Ref: http://www.teamquest.com/resources/gunther/ldavg1.shtml
Or current process open file descriptors
$ ls -l /proc/self/fd/0
lrwx------ 1 chirico chirico 64 Jun 29 13:17 0 -> /dev/pts/51
lrwx------ 1 chirico chirico 64 Jun 29 13:17 1 -> /dev/pts/51
lrwx------ 1 chirico chirico 64 Jun 29 13:17 2 -> /dev/pts/51
lr-x------ 1 chirico chirico 64 Jun 29 13:17 3 -> /proc/26667/fd
So you could, $ echo "stuff" > /dev/pts/51, to get output. Note, tree is also
helpful here:
$ tree /proc/self
/proc/self
|-- auxv
|-- cmdline
|-- cwd -> /work/souptonuts/documentation/theBook
|-- environ
|-- exe -> /usr/bin/tree
|-- fd
| |-- 0 -> /dev/pts/51
| |-- 1 -> /dev/pts/51
| |-- 2 -> /dev/pts/51
| `-- 3 -> /proc/26668/fd
|-- maps
|-- mem
|-- mounts
|-- root -> /
|-- stat
|-- statm
|-- status
|-- task
| `-- 26668
| |-- auxv
| |-- cmdline
| |-- cwd -> /work/souptonuts/documentation/theBook
| |-- environ
| |-- exe -> /usr/bin/tree
| |-- fd
| | |-- 0 -> /dev/pts/51
| | |-- 1 -> /dev/pts/51
| | |-- 2 -> /dev/pts/51
| | `-- 3 -> /proc/26668/task/26668/fd
| |-- maps
| |-- mem
| |-- mounts
| |-- root -> /
| |-- stat
| |-- statm
| |-- status
| `-- wchan
`-- wchan
10 directories, 28 files
Need a listing of the system settings?
$ sysctl -a
Need IPC (Shared Memory Segments, Semaphore Arrays, Message Queue) status
etc?
$ ipcs
$ ipcs -l "This gives limits"
Need to "watch" everything a user does? The following watches donkey.
$ watch lsof -u donkey
Or, to see what in going on in directory "/work/junk"
$ watch lsof +D /work/junk
No comments:
Post a Comment