Thursday 10 January 2013

System Info Commands

System Info Commands


1. dmidecode
dmidecode command reads the system DMI table to display hardware and BIOS information of the server.
Apart from getting current configuration of the system, you can also get information about maximum supported configuration of the system using dmidecode.

Get the total number of records in the DMI table
# dmidecode | grep ^Handle | wc -l

to get all the system baseboard related information

# dmidecode -t baseboard

Get Physical Memory (RAM) information using dmidecode

#dmidecode -t 16
# grep MemTotal /proc/meminfo

How many memory slots are available for expansion?
#dmidecode -t 17

Get BIOS information using dmidecode

# dmidecode -t bios

5. View Manufacturer, Model and Serial number of the equipment using dmidecode

# dmidecode -t system

How To Plan For Memory Expansion On a Linux Host

What is the current total RAM used in the system? 
#free
# grep MemTotal /proc/meminfo

What is the maximum RAM supported by the system?

# dmidecode -t 16


2. dmesg

During system bootup process, kernel gets loaded into the memory and it controls the entire system.

When the system boots up, it prints number of messages on the screen that displays information about the hardware devices that the kernel detects during boot process.

These messages are available in kernel ring buffer and whenever the new message comes the old message gets overwritten. You could see all those messages after the system bootup using the dmesg command.

1. View the Boot Messages - By executing the dmesg command, you can view the hardwares that are detected during bootup process and it’s configuration details.

# dmesg | more

2. View Available System Memory

# dmesg | grep Memory

3. View Ethernet Link Status (UP/DOWN)

# dmesg  | grep eth

4. Change the dmesg Buffer Size in /boot/config- file

Linux allows to you change the default size of the dmesg buffer. The CONFIG_LOG_BUF_SHIFT parameter in the /boot/config-2.6.18-194.el5 file (or similar file on your system) can be changed to modify the dmesg buffer.

#  grep CONFIG_LOG_BUF_SHIFT  /boot/config-`uname -r`
CONFIG_LOG_BUF_SHIFT=18

5. Clear Messages in dmesg Buffer
# dmesg -c

6.dmesg timestamp: Date and Time of Each Boot Message in dmesg

By default the dmesg don’t have the timestamp associated with them. However Linux provides a way to see the date and time for each boot messages in dmesg in the /var/log/kern.log file as shown below.

klogd service should be enabled and configured properly to log the messages in /var/log/kern.log file.

# dmesg | grep "L2 cache"

# grep "L2 cache" kern.log.1


3. who

Get the user name and process of logged in user using who and users command

who command is used to get the list of the usernames who are currently logged in. Output of the who command contains the following columns: user name, tty number, date and time, machine address.

$ who

To get a list of all usernames that are currently logged in, use the following:

$ who | cut -d' ' -f1 | sort | uniq

4. Users Command

users command is used to print the user name who are all currently logged in the current host. It is one of the command don’t have any option other than help and version.

$ users

Get the username you are currently logged in using whoami

whoami command is used to print the loggedin user name.

$ whoami

whoami command gives the same output as id -un as shown below:

$ id -un

Get the user login history at any time

last command will give login history for a specific username. If we don’t give any argument for this command, it will list login history for all users. By default this information will read from /var/log/wtmp file. The output of this command contains the following columns:

    User name
    Tty device number
    Login date and time
    Logout time
    Total working time

$ last jason

Get the running processes of logged-in user using w

w command is used to show logged-in user names and what they are doing. The information will be read from /var/run/utmp file. The output of the w command contains the following columns:

    Name of the user
    User’s machine number or tty number
    Remote machine address
    User’s Login time
    Idle time (not usable time)
    Time used by all processes attached to the tty (JCPU time)
    Time used by the current process (PCPU time)
    Command currently getting executed by the users


Following options can be used for the w command:

    -h Ignore the header information
    -u Display the load average (uptime output)
    -s Remove the JCPU, PCPU, and login time.

5.Which

which command    Show full path name of command

6. modprobe

modprobe utility is used to add loadable modules to the Linux kernel. You can also view and remove modules using modprobe command.

Linux maintains /lib/modules/$(uname-r) directory for modules and its configuration files (except /etc/modprobe.conf and /etc/modprobe.d).

In Linux kernel 2.6, the .ko modules are used instead of .o files since that has additional information that the kernel uses to load the modules.

List Available Kernel Modules
$ modprobe -l | less

List Currently Loaded Modules
While the above modprobe command shows all available modules, lsmod command will display all modules that are currently loaded in the Linux kernel.
$ lsmod | less

Install New modules into Linux Kernel
In order to insert a new module into the kernel, execute the modprobe command with the module name.
$ sudo modprobe vmhgfs

Once a module is loaded, verify it using lsmod command as shown below.

$ lsmod | grep vmhgfs

Load New Modules with the Different Name to Avoid Conflicts

Consider, in some cases you are supposed to load a new module but with the same module name another module got already loaded for different purposes.

If for some strange reasons, the module name you are trying to load into the kernel is getting used (with the same name) by a different module, then you can load the new module using a different name.

To load a module with a different name, use the modprobe option -o as shown below.

#sudo modprobe vmhgfs -o vm_hgfs
$ lsmod  | grep vm_hgfs

Remove the Currently Loaded Module

If you’ve loaded a module to Linux kernel for some testing purpose, you might want to unload (remove) it from the kernel.

Use modprobe -r option to unload a module from the kernel as shown below.

modprobe -r vmhgfs


7. lshw (Hardware Lister)

lshw (Hardware Lister) command gives a comprehensive report about all hardware in your system.
This displays detailed information about manufacturer, serial number of the system, motherboard, CPU, RAM, PCI cards, disks, network card etc.,

Using lshw, you can get information about the hardware without touching a screwdriver to open the server chassis.
This is also very helpful when the server is located in a remote data center, where you don’t have physical access to the server.


sudo lshw -short

sudo lshw -class memory

Get lshw output in multiple formats

$ sudo lshw -html > hardware-info.html

No comments:

Post a Comment