Friday, 21 July 2017

Bash commands about Hardaware and Network

Bash is a Unix shell and command language written by Brian Fox for the GNU Project as a free software replacement for the Bourne shell. Bash is a command processor that typically runs in a text window, where the user types commands that cause actions. Bash can also read and execute commands from a file, called a script.

Bash commands about Hardware information

Like for every thing, there are plenty of commands to check information about the hardware of your linux system. The following commands are just a subset of it.

lscpu

The lscpu command reports information about the cpu and processing units.
$ lscpu

lshw

The lshw command reports detailed and brief information about multiple different hardware units such as cpu, memory, disk, usb controllers, network adapters etc...
$ lshw
With -short as option you can display a short report.
$ lshw -short

hwinfo

The hwinfo command is another general purpose hardware probing utility that can report information about multiple different hardware components.
$ hwinfo
With --short as option you can display a short report.
$ hwinfo --short

lsusb

The lsusb command shows the USB controllers and details about devices connected to them.
$ lsusb
Use the verbose option (-v) to print detailed information about each usb port 
$ lsusb -v

lsblk

The lsblk command shows the list out information all block devices, which are the hard drive partitions and other storage devices like optical drives and flash drives.
$ lsblk

df

The df command show a report of various partitions, their mount points and the used and available space on each.
$ df
I suggest to use -h (--human-readable) as option for a better report structure.
$ df -h

fdisk

The fdisk command is a utility to modify partitions on hard drives, and can be used to list out the partition information as well. Use -l as option to show the list. This command required "sudo".
$ sudo fdisk -l

mount

The mount command is used to mount/unmount and view mounted file systems. To view the result in table use the following command:
$ mount | column -t

free (Check RAM)

The command free shows the amount of used, free and total amount of RAM on system.
$ free
Use the options -m or -g to print the results in mega or giga.
$ free -m
$ free -g
If you want see the size of physical RAM allocated your system, so use this command:
$ grep MemTotal /proc/meminfo | awk '{print $2}'

Bash commands about Network

The network commands paragraph collects various tools which can be useful when networking with other computers both within the network and accross the internet, obtaining more information about other computers.

netstat

The netstat command displays contents of /proc/net files. It works with the Linux Network Subsystem, it will tell you what the status of ports are ie. open, closed, waiting, masquerade connections. It will also display various other things. It has many different options. For example you want check the status of  port '8080'. 
$ netstat -an | grep 8080

tcpkill

The tcpkill command kills a connection on a specific port. Example: if you want kill the connection with the port 8080 use the following command:
$ tcpkill -i eth0 port 8080

tcpdump

The tcpdump command is a sniffer, a program that captures packets off a network interface and interprets them for you. It understands all basic internet protocols, and can be used to save entire packets for later inspection. This command required "sudo".
$ sudo tcpdump

ping

The ping command sends echo requests to the host you specify on the command line, and lists the responses received their round trip time.
$ ping myhostname

hostname

The hostname command tells the user the host name of the computer they are logged into.
$ hostname

traceroute

The traceroute command shows the route of a packet. It attempts to list the series of hosts through which your packets travel on their way to a given destination. Also have a look at xtraceroute (one of several graphical equivalents of this program).
$ traceroute <ip>

ifconfig

The ifconfig command is used to configure network interfaces, or to display their current configuration. Use only the command withoud parameters to show the configuration.
$ ifconfig

route

The route command is the tool used to display or modify the routing table. To add a gateway as the default you would type:

$ route add default gw some_server

Internal Links

May be of interest to you:

External Links:

No comments:

Post a Comment

Welcome

Hello everybody, Welcome in my blog called "Information technology archive". Obviously the topics will be related to Informatio...