Wednesday, October 15, 2008

Linux commands for System Administrators

Kernel Ring Buffer: dmesg

#dmesg |more

[ 0.000000] Linux version 2.6.24-16-generic (buildd@palmer) (gcc version 4.2.3 (Ubuntu 4.2.3-2ubuntu7)) #1 SMP Thu Apr 10 13:23:42 UTC 2008 (Ubuntu 2.6.24-16.30-generic)
[ 0.000000] BIOS-provided physical RAM map:
[ 0.000000] BIOS-e820: 0000000000000000 - 000000000009e000 (usable)
[ 0.000000] BIOS-e820: 000000007edf4000 - 000000007edff000 (ACPI data)
[ 0.000000] 1134MB HIGHMEM available.
[ 0.000000] 896MB LOWMEM available.
[ 0.000000] found SMP MP-table at 000fe200
[ 0.000000] Entering add_active_range(0, 0, 519680) 0 entries of 256 used
[ 0.000000] Zone PFN ranges:
[ 0.000000] DMA 0 -> 4096
[ 0.000000] Normal 4096 -> 229376
[ 0.000000] HighMem 229376 -> 519680

List of Open Files: lsof
To view a list of all the files open for a particular process

# psof -p 6685 6685 is the process ID for a process (ps -u username will give process ID)

Process Tree: pstree

This will give the list of process in a tree format

# pstree

Interprocess Communication: ipcs
This will produces a list of the IPC resources currently in use:

# ipc

User Accessing Files: fuser
This command is useful to find what processes or users are currently accessing a particular files. Example, suppose you want to unmount a file system mounted at /cdrom. umount gives “device is busy.” The fuser command can help you to find which processes are accessing the device:

vishnu@vishnu-desktop:~$ fuser -v /home/vishnu
USER PID ACCESS COMMAND
/home/vishnu: vishnu 6383 ..c.. gnome-session
vishnu 6445 ..c.. gnome-settings-
vishnu 6499 ..c.. nautilus
vishnu 6575 ..c.. update-notifier
vishnu 6585 ..c.. python
vishnu 6814 ..c.. bash
vishnu 6904 ..c.. bash

Processes List: top
Command for “table of processes,” displays a list of processes that is refreshed every two seconds.

$top

Tasks: 134 total, 1 running, 133 sleeping, 0 stopped, 0 zombie
Cpu(s): 4.8%us, 0.3%sy, 0.0%ni, 93.8%id, 1.1%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 2056640k total, 1642608k used, 414032k free, 24620k buffers
Swap: 3951948k total, 0k used, 3951948k free, 629144k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
6685 vishnu 20 0 764m 652m 23m S 4 32.5 4:15.57 firefox
1 root 20 0 2844 1660 520 S 0 0.1 0:01.02 init
2 root 15 -5 0 0 0 S 0 0.0 0:00.00 kthreadd
3 root RT -5 0 0 0 S 0 0.0 0:00.00 migration/0
4 root 15 -5 0 0 0 S 0 0.0 0:00.02 ksoftirqd/0

Who Is Doing What: w

This will find out who is logged onto the system and what he is doing.

#w



No comments: