Collecting Ubuntu Linux System Information

For new computer or Laptop or server, I need to collect the information about its hardware. This is also useful when you need to replace a disk or memory with a vendor. In order to replace hardware you need all information in advance. In this post, I’m going to list commands that you can use to collect the hardware information.Ubuntu Linux Server Collecting System InformationAll of the following commands are tested on Ubuntu Linux LTS 14.04, but should work with any modern distro too such as Debian or Fedora Linux.

Find the system host name

Display the system’s host name:

$ hostname$ cat /etc/hostnameserver1

<p dir=”ltr”>Display the system’s DNS domain name:

$ dnsdomainnamecyberciti.biz

<p dir=”ltr”>Display the system’s Fully Qualified Domain Name (FQDN):

$ hostname -fserver1.cyberciti.biz

 

Find the system serial number, manufacturer of the system and model name

$ sudo dmidecode -s system-serial-number$ sudo dmidecode -s system-manufacturer$ sudo dmidecode -s system-product-name$ sudo dmidecode | more

 

OR use the lshw command:

 <p dir=”ltr”># lshw | more$ sudo lshw -short

<p dir=”ltr”>Display information about installed hardware

$ sudo lsdev

 

Find the system CPU info

$ cat /proc/cpuinfo

<p dir=”ltr”>OR

$ lscpu

<p dir=”ltr”>Display CPU (processors) related statistics

$ sudo mpstat$ sudo mpstat 1$ sudo mpstat -A

 

Find the system main memory (RAM) info

<p dir=”ltr”>Show statistics about memory usage on the system including total installed and used RAM:

$ less /proc/meminfo

 

Show amount of free and used memory in the system:

free -g

 

<p dir=”ltr”>Show the system virtual memory statistics

$ sudo vmstat$ sudo vmstat 1$ sudo vmstat 2

 

Find the Ubuntu Linux distribution version and related information

$ lsb_release -a

 

Find the system kernel version number

$ uname -r

<p dir=”ltr”>OR

$ uname -a

 

Find the system kernel parameters

$ cat /proc/cmdline$ sysctl -a | more

 

Find the system kernel architecture (32 bit or 64 bit)

$ uname -m$ getconf LONG_BIT$ arch

 

Find the system disk information

<p dir=”ltr”>Show all installed disks and size:

# fdisk -l | grep ‘^Disk /dev’

<p dir=”ltr”>List all partitions of /dev/sda disk:<p dir=”ltr”>To read a disk label for /dev/sda:

# fdisk -l /dev/sda

<p dir=”ltr”>To label a disk:

$ sudo fdisk /dev/sda$ sudo e2label /dev/sda1$ sudo cfdisk /dev/sda

<p dir=”ltr”>Show block device attributes:

# blkid

<p dir=”ltr”>List all block devices:

# lsblk

<p dir=”ltr”>Display file system disk space usage:

$ df$ df -H$ df -HT

<p dir=”ltr”>Estimate file space usage:

$ du$ du /home

<p dir=”ltr”>Display mounted file system:

$ cat /proc/mount$ mount

<p dir=”ltr”>Display SCSI devices (or hosts) and their attributes on Linux:

$ lsscsi

<p dir=”ltr”>Display I/O statistics

$ sudo iostat$ sudo iostat 2

 

Find the system PCI devices information

$ lspci$ lspci -vt$ lspci | grep -i ‘something’$ lspci -vvvn| less

 

Find the system USB devices information

$ lsusb$ lsusb -vt

 

Find the system Wireless devices information

$ iwconfig$ watch -n 1 cat /proc/net/wireless$ wavemon

 

Find the system VGA/Graphics devices information

$ lspci | grep -i vga$ lspci -vvnn | grep VGA

<p dir=”ltr”>OR

$ sudo lshw -class display

<p dir=”ltr”>Find the system NVIDIA Graphics devices informationThe following commands only works with Nvidia’s binary Linux driver:

$ nvidia-smi

<p dir=”ltr”>OR

$ nvidia-settings

<p dir=”ltr”>Find the system AMD/ATI Graphics devices informationThe following command only works with AMD’s binary Linux driver called catalyst:

$ fglrxinfo

Which version of Unity am I running?

$ unity –version

 

Find the system audio devices information

$ lspci | grep -i audio

<p dir=”ltr”>OR

$ cat /proc/asound/cards

<p dir=”ltr”>OR

$ arecord -l

 

Display the system/laptop battery status & thermal temperature

$ upower -i /org/freedesktop/UPower/devices/battery_BAT0$ acpi -V

Find out how long the system has been running

$ uptime$ who$ w

<p dir=”ltr”>Find the system load

$ uptime$ cat /proc/loadavg$ sudo top$ sudo htop$ sudo atop

<p dir=”ltr”>Show the system reboot and shutdown history

$ last reboot$ last shutdown

<p dir=”ltr”>Show runlevel

$ runlevel$ who -r

 

Display kernel ring buffer (boot time) messages

Use the following command to see boot time message including hardware configuration

$ sudo less /var/log/dmesg$ sudo grep ‘regx’ /var/log/dmesg$ sudo grep ‘[h|s]d’ /var/log/dmesg

Display the system drivers (modules)

$ sudo lsmod$ sudo modinfo {driver_name}$ sudo modinfo kvm

 

Find the system IP address and related information

You need to use the ip command:

## Info about all interfaces. Must be run as root via sudo command ##sudo ip asudo ipsudo ip link ls upsudo ifconfig -a

## Only show eth1 interface info ##sudo ip a show eth0sudo ifconfig eth0Display the system routing table## You can use any one of the following command #### Must be run as root ##sudo ip rsudo route -nsudo netstat -nrDisplay the system ethernet bridge$ sudo brctl show$ sudo bridge link

Display the system DNS server and related information

Display the system name server IP address (ISP or your dns server IP should be listed here):

# cat /etc/resolv.conf

Display the system resolver configuration file. This is useful to find out how host lookups are to be performed:

# cat /etc/host.conf

 

Use above two files to configure name resolution.

Display information about the system ports and socket

sudo ss -t -a

 

## List all open fileslsof | morelsof | grep somethinglsof /dev/sda2lsof /path/to/file

Display the list of running services

### SYS V ###$ sudo service –status-all

 

OR

## UPSTART ##$ sudo initctl list

Find out if service is enabled:

## UPSTART ##$ sudo initctl status service-name$ sudo initctl status smbd

OR

## SYS V$ sudo service serviceName status$ sudo service nginx status

View log files

$ cd /var/log$ ls -l$ tail -f /var/log/fileName$ grep ‘something’ /var/log/fileNameHere

Find file by name

$ locate fileName$ locate htpasswd$ locate passwd$ locate my.resume.doc

Find file by given condition

$ find {/dir/to/search} -name {file-to-search} -print$ find /etc/ -name /etc/passwd -print$ find $HOME -name ‘*.doc’ -print

 

View user account details

$ less /etc/passwd$ grep userName /etc/passwd$ getent passwd

View group account details

$ less /etc/group$ getent group$ grep group-name /etc/group$ groups userName

View password policy

$ chage -l userName$ chage -l root$ chage -l vivek

View system usage

$ sudo top$ sudo htop$ sudo atop$ sudo ps auxwww$ sudo netstat [options]$ sudo iostat$ sudo mpstat 1$ sudo sar [options]

Trace system call

$ strace -o output.txt /bin/foo$ strace -p 22254 -s 80 -o debug.nginx.txt

 

Trace library call

$ sudo ltrace /usr/sbin/httpd$ sudo ltrace /sbin/chroot /usr/sbin/httpd

 

View process info

$ sudo pstree$ sudo pstree | less$ sudo ps auxwwwm$ ps alxwww$ ps auxwww$ lsof -b M -n -l

 

Change process priority

$ sudo /bin/nice -n -1 command-name-here$ sudo /bin/nice -n -1 pid$ sudo renice {priority} pid

<p dir=”ltr”>View process’s CPU affinity

$ sudo taskset -p {pid-here}$ sudo taskset -p 42

 

Display the system listing of all package installed

$ dpkg -l$ dpkg -l | less$ dpkg -l nginx

 

Display the system listing of all patches installed

$ sudo apt-show-versions -a | grep -i “security”

Display the list of needed runtime libraries to run file

$ ldd file

 

Find what package a file belongs to

$ dpkg -S /path/to/file$ dpkg -S /bin/ls

 

Create a backup list of all installed software

$ sudo dpkg –get-selections > /root/installed.pkgs.txt

<p dir=”ltr”>Want to restore it again?

$ sudo dpkg –set-selections < /root/installed.pkgs.txt

 

Display the system firewall configuration

$ sudo iptables -L -n -v$ sudo ufw status numbered$ sudo ufw status verbose$ sudo ufw app list

<p dir=”ltr”>Do not forget to read man pages featured in this post:

$ man dpkg$ man htop$ man …

 

Finally, make a backup – it cannot be stressed enough how important it is to make a backup of your system. A good backup plan allow you to recover from disk failure, accidental file deletion, file corruption, or complete server destruction, including destruction of on-site backups.

Autor: VIVEK GITE on SEPTEMBER 1, 2015 last updated SEPTEMBER 2, 2015

Anuncios

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s