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.

Display the system’s host name:

$ hostname

Display the system’s DNS domain name:

$ dnshostname

 

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:

# lshw | more
$ sudo lshw -short

Display information about installed hardware

$ sudo lsdev

Find the system CPU info

$ cat /proc/cpuinfo

Find the system main memory (RAM) info. Show statistics about memory usage on the system including total installed and used RAM:

$ less /proc/meminfo

Find the Ubuntu Linux distribution version and related information:

$ lsb_release -a

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

$ uname -m
$ getconf LONG_BIT
$ arch

Show all installed disks and size:

# fdisk -l | grep '^Disk /dev'

Display SCSI devices (or hosts) and their attributes on Linux:

$ lsscsi

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 audio devices information:

$ lspci | grep -i audio

Display the system drivers (modules):

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

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

 

mtr utility

Traditionally the traceroute (print the route packets take to network host) and ping (send ICMP ECHO_REQUEST to network hosts) programs are used as diagnostic tool to solve and isolate networking errors. It may take some time to use both tools to diagnose network issues. However, you can use the mtr program instead of ping and traceroute. It is a network diagnostic tool and it is the combination of traceroute and ping programs (in terms of functionality) and works as a single network diagnostic tool.

Once mtr invoked it starts investigates the network connection between the hosts (workstation) mtr runs on and HOSTNAME by sending packets with purposely low TTLs (time to live). It will continue to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME.

During this run if you notice a sudden increase in packet-loss or response time is an indication of overloaded link or a bad link.

Examples:

mtr -c 5 -r -w ausinfotech.net

http://www.cyberciti.biz/tips/finding-out-a-bad-or-simply-overloaded-network-link-with-linuxunix-oses.html

ShellCheck

Automatically detects problems with sh/bash scripts and commands!

ShellCheck is a static analysis and linting tool for sh/bash scripts. It’s mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures.

http://www.shellcheck.net

 

Creating NGINX Rewrite Rules

How to create NGINX rewrite rules (the same methods work for both NGINX Plus and the open source NGINX software). Rewrite rules change part or all of the URL in a client request, usually for one of two purposes:

  • To inform clients that the resource they’re requesting now resides at a different location. Example use cases are when your website’s domain name has changed, when you want clients to use a canonical URL format (either with or without the www prefix), and when you want to catch and correct common misspellings of your domain name. The return and rewrite directives are suitable for these purposes.
  • To control the flow of processing within NGINX and NGINX Plus, for example to forward requests to an application server when content needs to be generated dynamically. The try_files directive is often used for this purpose.

Example of a redirect to a new domain name:

<code>server { listen 80; listen 443 ssl; server_name www.old-name.com; return 301 $scheme://www.new-name.com$request_uri; }

Read more details and examples from the Nginx blog post: https://www.nginx.com/blog/creating-nginx-rewrite-rules/

 

Linux Dash

A simple web dashboard to monitor your linux systems.

Features:

  • A beautiful, simple web-based dashboard for monitoring a linux server
  • Only ~1MB on disk! (.git removed)
  • Live graphs, refresh-able widgets, and a growing # of supported modules
  • Drop-in installation for PHP, Node.js, Python, and Go

More details and downloads:
http://linuxdash.afaqtariq.com/
https://github.com/afaqurk/linux-dash

 

Email Checker

Email Checker is a simple tool for verifying an email address. It’s free and quite easy to use. Just enter the email address and hit check button. Then it tells you whether the email address is real or not. It extracts the MX records from the email address and connect to mail server (over SMTP and also simulates sending a message) to make sure the mailbox really exist for that user/address. Some mail servers do not co-operate in the process, in such cases, the result of this email verification tool may not be accurate as expected.

http://email-checker.net/

 

Boot-Repair Utility and Methods

Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Ubuntu like when you can’t boot Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

Boot-Repair lets you fix these issues with a simple click, which (generally reinstalls GRUB and) restores access to the operating systems you had installed before the issue.

Boot-Repair also has advanced options to back up table partitions, back up bootsectors, create a Boot-Info (to get help by email or forum), or change the default repair parameters: configure GRUB, add kernel options (acpi=off …), purge GRUB, change the default OS, restore a Windows-compatible MBR, repair a broken filesystem, specify the disk where GRUB should be installed, etc.

More Information and link:
https://help.ubuntu.com/community/Boot-Repair

 

Linux – Copy file to multiple dir

How an I copy a file into multiple directories? You could write a script or just use these commands from the terminal in bash.

Copy test.txt into dir1,dir2,an dir3 dirs:

 echo dir1 dir2 dir3 | xargs -n 1 cp -v test.txt 

Copy test.txt into /dir/d1, /dir/d2, and /dir/d3 dirs:

 echo /dir/d{1,2,3} | xargs -n 1 cp -v test.txt