| 0 comments ]

System Information Commands

Basic commands used by intermediate users from the command line. Many of these tools can be accomplished graphically, this document is aimed at augmenting GUI tools such as gnome-system-monitor.

information
This is by no means a full list of commands or switches.
Users requiring a list of switches or further explanation of command should consult the man pages.
There is a wealth of knowledge on how to use and what commands do can be obtained from www.google.com/linux
Some commands will need to be performed by root, type su - which will give you root status.

System Command Example(s) Details
whoami whoami Prints the user name associated with the current effective user ID
who who Print information about users who are currently logged in
id id print real and effective user and group IDs
last last shows previously logged in users
date date 123123572000 sets or views the date
time time times a function on a system.
history history provides a history of command line commands issues by users.
uptime uptime shows uptime of the system.
ps ps Reports a snapshot of the current processes.
top top displays Linux tasks in a realtime text menu tool
uname uname -a Print certain system kernel information etc.
free free Prints free memory in system
df df -h Prints the disk partitions and available spave
du du -h Prints the sizes of files and folders
proc info cat /proc/ Gives raw proc information for resources
cat /proc/cpuinfo Gives CPU count and details recognized by system
cat /proc/interrupts Gives interrupts used
cat /proc/meminfo Provides RAM memory details.
cat /proc/version Provides system information, kernel, etc.
lsmod lsmod |more list the loaded modules for devices etc. (i.e. is networking card driver loaded?)
PATH echo $PATH Gives folders in a path for a particular user.
dmesg dmesg |more Give detailed log messages.
System Commands

whoami

Print my login name.

[thesmartguy@wifitest]$ whoami
thesmartguy


who

Determine the users logged on the machine.

[root@wifitest]# who
thesmartguy pts/1 2007-11-19 09:34 (:0.0)


id

Print user id (uid) and his/her group id (gid), effective id (if different than the real id) and the supplementary groups.

[thesmartguy@wifitest]$ id thesmartguy
uid=500(thesmartguy) gid=501(thesmartguy) groups=501(thesmartguy)

last

Show listing of users last logged-in on your system.

[root@wifitest]# last
thesmart pts/1 :0.0 Mon Nov 19 09:34 still logged in
thesmart :0 Mon Nov 19 09:33 still logged in
reboot 2.6.18-53.el5 Mon Nov 19 09:31 (00:31)


date

Print or change the operating system date and time. E.g., I could change the date and time to 2000-12-31 23:57 using this command:

date 123123572000

To set the hardware (BIOS) clock from the system (Linux) clock, use the command (as root) setclock

time

Determine the amount of time that it takes for a process to complete + other info. Don't confuse it with the date command. E.g. I can find out how long it takes to display a directory content using: time ls

[root@wifitest]# time ls
anaconda-ks.cfg cds install.log install.log.syslog jimmit scsrun.log
real 0m0.007s
user 0m0.003s
sys 0m0.004s


history | more

Show the last (1000 or so) commands executed from the command line on the current account. The "| more" causes the display to stop after each screenful.

[root@wifitest]# history
1 lpc
2 lpc ?
3 lpc ?
4 lpc \-s
5 lpc status
6 ps axu
7 man pid


uptime

Show the amount of time since the last reboot.

[root@wifitest]# uptime
10:05:45 up 34 min, 1 user, load average: 1.01, 0.47, 0.48


ps

(=print status) List the processes currently run by the current user.

[thesmartguy@wifitest]$ ps
PID TTY TIME CMD
20216 pts/1 00:00:00 bash
20658 pts/1 00:00:00 ps

ps axu | more

List all the processes currently running, even those without the controlling terminal, together with the name of the user that owns each process.
(List to large for example.)


top

Keep listing the currently running processes, sorted by cpu usage (top users first).
List to large for example.


uname -a

(= Unix name with option "all") Info on your (local) server.

[root@wifitest]# uname -a
Linux wifitest.uk.ibm.com 2.6.18-53.el5 #1 SMP Wed Oct 10 16:34:02 EDT 2007 i686 i686 i386 GNU/Linux

uname -r

Kernel only reported.

[root@wifitest]# uname -r
2.6.18-53.el5


free

Memory info (in kilobytes).

[root@wifitest ]# free
total used free shared buffers cached
Mem: 1026108 1010252 15856 0 27768 485084

- + buffers/cache: 497400 528708
Swap: 1052248 0 1052248


df -h

(=disk free) Print disk info about all the filesystems (in human-readable form)

[root@wifitest ]# df -h
Size Used Avail Use% Mounted on
/dev/hda1 36G 4.5G 29G 14% /
tmpfs 502M 0 502M 0% /dev/shm

du / -bh | more

(=disk usage) Print detailed disk usage for each subdirectory starting at the "/" (root) directory (in human legible form).
Careful this will list all directory's under / (everything on machine)


cat /proc/cpuinfo

Cpu info - it show the content of the file cpuinfo. Note that the files in the /proc directory are not real files - they are hooks to look at information available to the kernel.

[root@wifitest]# cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 6
model : 13
model name : Intel(R) Pentium(R) M processor 1.40GHz
stepping : 6
cpu MHz : 600.000
cache size : 2048 KB
bogomips : 1196.52

cat /proc/interrupts

List the interrupts in use.

[root@wifitest ]# cat /proc/interrupts
0: 983295 IO-APIC-edge timer
1: 1106 IO-APIC-edge i8042
7: 1 IO-APIC-edge parport0
8: 1 IO-APIC-edge rtc
9: 2414 IO-APIC-level acpi
12: 78970 IO-APIC-edge i8042
14: 45698 IO-APIC-edge ide0
15: 25704 IO-APIC-edge ide1

cat /proc/meminfo

list the memory in a system

MemTotal:        2539180 kB
MemFree: 376988 kB
Buffers: 53488 kB
Cached: 1706536 kB

cat /proc/version

Linux version and other info

[root@wifitest]# cat /proc/version
Linux version 2.6.18-53.el5 (brewbuilder@hs20-bc2-3.build.redhat.com) (gcc version 4.1.2 20070626 (Red Hat 4.1.2-14)) #1 SMP Wed Oct 10 16:34:02 EDT 2007

cat /proc/filesystems

Show the types of filesystems currently in use.

[root@wifitest]# cat /proc/filesystems
nodev sysfs
nodev rootfs
nodev proc
nodev cpuset
nodev securityfs
nodev sockfs
nodev usbfs
nodev tmpfs
nodev ext2
nodev iso9660
nodev ext3
nodev autofs


lsmod

(As root. Use /sbin/lsmod to execute this command when you are a non-root user.) Show the kernel modules currently loaded.

[root@wifitest]# /sbin/lsmod
Module Size Used by
wlan_tkip 15872 2
drm 65493 3 i915
lt_hotswap 14856 0
tun 14657 1
autofs4 24389 2
hidp 23105 2
rfcomm 42457 0
l2cap 29633 10 hidp,rfcomm
bluetooth 53925 5 hidp,rfcomm,l2cap

(List continues to large for example.)


echo $PATH

Show the content of the environment variable "PATH". This command can be used to show other environment variables as well. Use "set" to see the full environment.

[root@wifitest]# echo $PATH
/usr/kerberos/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/ibm/c4eb/bin:/usr/kerberos/bin:/root/bin


dmesg | less

Print kernel messages (the content of the so-called kernel ring buffer). Press "q" to quit "less". Use less /var/log/dmesg to see what "dmesg" dumped into this file right after the last system bootup.

(List to large for Example.)

0 comments

Post a Comment