Skip to content
Blog Linux commands for System Administrators

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 open files.

# lsof -p 6685

To view a list of all the files open for a particular process

# lsof -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:

$ fuser -v /home/dipin
USER PID ACCESS COMMAND
/home/dipin: dipin 3297 ..c.. x-session-manag
dipin 3349 ..c.. gnome-keyring-d
dipin 3356 ..c.. metacity
dipin 3367 ..c.. gnome-panel
dipin 3369 ..c.. nautilus
dipin 3376 ..c.. vino-session
dipin 3382 ..c.. bluetooth-apple
dipin 3384 ..c.. update-notifier
dipin 3391 ..c.. nm-applet
dipin 3395 ..c.. gnome-cups-icon
dipin 3536 ..c.. firefox-bin
dipin 6516 ..c.. gnome-terminal
dipin 6518 ..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
10:20:55 up 1:06, 2 users, load average: 0.29, 0.22, 0.14
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
dipin :0 – 09:15 ?xdm? 4:24m 0.46s x-session-manag
dipin pts/0 :0.0 10:13 1.00s 0.12s 0.00s w

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.