http://www.cyberciti.biz/hardware/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.

All 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.
Display the system's DNS domain name:
Display the system's Fully Qualified Domain Name (FQDN):
OR use the lshw command:
OR
Show amount of free and used memory in the system:
OR
To label a disk:
OR
OR
OR
OR
Display the system resolver configuration file. This is useful to find out how host lookups are to be performed:
Use above two files to configure name resolution.
OR
OR
Want to restore it again?
Do not forget to read man pages featured in this post:
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.
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.
All 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/hostname
server1Display the system's DNS domain name:
$ dnsdomainname
cyberciti.bizDisplay the system's Fully Qualified Domain Name (FQDN):
$ hostname -f
server1.cyberciti.bizFind 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 | moreOR use the lshw command:
# lshw | more
$ sudo lshw -shortDisplay information about installed hardware
$ sudo lsdevFind the system CPU info
$ cat /proc/cpuinfoOR
$ lscpuDisplay CPU (processors) related statistics
$ sudo mpstat
$ sudo mpstat 1
$ sudo mpstat -AFind the system main memory (RAM) info
Show statistics about memory usage on the system including total installed and used RAM:$ less /proc/meminfoShow amount of free and used memory in the system:
free ## Display the amount of memory in megabytes ## free -m ## Display the amount of memory in gigabytes ## free -g ## Display the amount of memory in terabytes ## free --tera ## Display human readable output ## free -h
Show the system swap space usage
$ swapon -s
$ cat /proc/swaps
$ cat /proc/meminfo
$ top
$ vmstat
$ for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less
$ smemShow the system virtual memory statistics
$ sudo vmstat
$ sudo vmstat 1
$ sudo vmstat 2Find the Ubuntu Linux distribution version and related information
$ lsb_release -aFind the system kernel version number
$ uname -rOR
$ uname -aFind the system kernel parameters
$ cat /proc/cmdline
$ sysctl -a | moreFind the system kernel architecture (32 bit or 64 bit)
$ uname -m
$ getconf LONG_BIT
$ archFind the system disk information
Show all installed disks and size:# fdisk -l | grep '^Disk /dev'List all partitions of /dev/sda disk:
To read a disk label for /dev/sda:# fdisk -l /dev/sdaTo label a disk:
$ sudo fdisk /dev/sda
$ sudo e2label /dev/sda1
$ sudo cfdisk /dev/sdaShow block device attributes:
# blkidList all block devices:
# lsblkDisplay file system disk space usage:
$ df
$ df -H
$ df -HTEstimate file space usage:
$ du
$ du /homeDisplay mounted file system:
$ cat /proc/mount
$ mountDisplay SCSI devices (or hosts) and their attributes on Linux:
$ lsscsiDisplay I/O statistics
$ sudo iostat
$ sudo iostat 2Find the system PCI devices information
$ lspci
$ lspci -vt
$ lspci | grep -i 'something'
$ lspci -vvvn| lessFind the system USB devices information
$ lsusb
$ lsusb -vtFind the system Wireless devices information
$ iwconfig
$ watch -n 1 cat /proc/net/wireless
$ wavemonFind the system VGA/Graphics devices information
$ lspci | grep -i vga
$ lspci -vvnn | grep VGAOR
$ sudo lshw -class displayFind the system NVIDIA Graphics devices information
The following commands only works with Nvidia's binary Linux driver:$ nvidia-smiOR
$ nvidia-settingsFind the system AMD/ATI Graphics devices information
The following command only works with AMD's binary Linux driver called catalyst:$ fglrxinfoWhich version of Unity am I running?
$ unity --versionFind the system audio devices information
$ lspci | grep -i audioOR
$ cat /proc/asound/cardsOR
$ arecord -lDisplay the system/laptop battery status & thermal temperature
$ upower -i /org/freedesktop/UPower/devices/battery_BAT0
$ acpi -VFind out how long the system has been running
$ uptime
$ who
$ wFind the system load
$ uptime
$ cat /proc/loadavg
$ sudo top
$ sudo htop
$ sudo atopShow the system reboot and shutdown history
$ last reboot
$ last shutdownShow runlevel
$ runlevel
$ who -rDisplay 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/dmesgDisplay the system drivers (modules)
$ sudo lsmod
$ sudo modinfo {driver_name}
$ sudo modinfo kvmFind 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 a sudo ip sudo ip link ls up sudo ifconfig -a ## Only show eth1 interface info ## sudo ip a show eth0 sudo ifconfig eth0
Display the system routing table
## You can use any one of the following command ## ## Must be run as root ## sudo ip r sudo route -n sudo netstat -nr
Display the system ethernet bridge
$ sudo brctl show
$ sudo bridge linkDisplay 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.confDisplay the system resolver configuration file. This is useful to find out how host lookups are to be performed:
# cat /etc/host.confUse above two files to configure name resolution.
Display information about the system ports and socket
## Must run as root via sudo ## sudo ss ## Display all listing ports ## sudo ss -l sudo netstat -tulpn sudo netstat -tulpn | grep LISTEN ## Display all TCP sockets sudo ss -t -a ## Display all UDP sockets. sudo ss -u -a ## List all open files lsof | more lsof | grep something lsof /dev/sda2 lsof /path/to/file
Display the list of running services
### SYS V ###
$ sudo service --status-allOR
## UPSTART ##
$ sudo initctl listFind out if service is enabled:
## UPSTART ##
$ sudo initctl status service-name
$ sudo initctl status smbdOR
## SYS V
$ sudo service serviceName status
$ sudo service nginx statusView log files
$ cd /var/log
$ ls -l
$ tail -f /var/log/fileName
$ grep 'something' /var/log/fileNameHereFind file by name
$ locate fileName
$ locate htpasswd
$ locate passwd
$ locate my.resume.docFind file by given condition
$ find {/dir/to/search} -name {file-to-search} -print
$ find /etc/ -name /etc/passwd -print
$ find $HOME -name '*.doc' -printView user account details
$ less /etc/passwd
$ grep userName /etc/passwd
$ getent passwdView group account details
$ less /etc/group
$ getent group
$ grep group-name /etc/group
$ groups userNameView password policy
$ chage -l userName
$ chage -l root
$ chage -l vivekView 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.txtTrace library call
$ sudo ltrace /usr/sbin/httpd
$ sudo ltrace /sbin/chroot /usr/sbin/httpdView process info
$ sudo pstree
$ sudo pstree | less
$ sudo ps auxwwwm
$ ps alxwww
$ ps auxwww
$ lsof -b M -n -lChange process priority
$ sudo /bin/nice -n -1 command-name-here
$ sudo /bin/nice -n -1 pid
$ sudo renice {priority} pidView process's CPU affinity
$ sudo taskset -p {pid-here}
$ sudo taskset -p 42Display the system listing of all package installed
$ dpkg -l
$ dpkg -l | less
$ dpkg -l nginxDisplay 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 fileFind what package a file belongs to
$ dpkg -S /path/to/file
$ dpkg -S /bin/lsCreate a backup list of all installed software
$ sudo dpkg --get-selections > /root/installed.pkgs.txtWant to restore it again?
$ sudo dpkg --set-selections < /root/installed.pkgs.txtDisplay the system firewall configuration
$ sudo iptables -L -n -v
$ sudo ufw status numbered
$ sudo ufw status verbose
$ sudo ufw app listDo 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.

No comments:
Post a Comment