How to View Linux System Hardware Information

It is always a good practice to know the hardware components of your Linux system is running on, this helps you to deal with compatibility issues when it comes to installing packages, drivers on your system.

1. How to View Linux System Information

To know only system name, you can use uname command without any switch will print system information or uname -s command will print the kernel name of your system.

tecmint@tecmint ~ $ uname
Linux

To view your network hostname, use ‘-n’ switch with uname command as shown.

tecmint@tecmint ~ $ uname -n
tecmint.com

To get information about kernel-version, use ‘-v’ switch.

tecmint@tecmint ~ $ uname -v
#64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014

To get the information about your kernel release, use ‘-r’ switch.

tecmint@tecmint ~ $ uname -r
3.13.0-37-generic

To print your machine hardware name, use ‘-m’ switch:

tecmint@tecmint ~ $ uname -m
x86_64

All this information can be printed at once by running ‘uname -a’ command as shown below.

tecmint@tecmint ~ $ uname -a
Linux tecmint.com 3.13.0-37-generic #64-Ubuntu SMP Mon Sep 22 21:28:38 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

2. How to View Linux System Hardware Information

Here you can use the lshw tool to gather vast information about your hardware components such as cpu, disks, memory, usb controllers etc.

lshw is a relatively small tool and there are few options that you can use with it while extracting information. The information provided by lshw gathered form different /proc files.

Note: Do remember that the lshw command executed by superuser (root) or sudo user.

Read Also: Difference Between su and sudo User in Linux

To print information about your Linux system hardware, run this command.

tecmint@tecmint ~ $ sudo lshw
tecmint.com               
description: Notebook
product: 20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
vendor: LENOVO
version: Lenovo Z50-70
serial: 1037407803441
width: 64 bits
capabilities: smbios-2.7 dmi-2.7 vsyscall32
configuration: administrator_password=disabled boot=normal chassis=notebook family=IDEAPAD frontpanel_password=disabled keyboard_password=disabled power-on_password=disabled sku=LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70 uuid=E4B1D229-D237-E411-9F6E-28D244EBBD98
*-core
description: Motherboard
product: Lancer 5A5
vendor: LENOVO
physical id: 0
version: 31900059WIN
serial: YB06377069
slot: Type2 - Board Chassis Location
*-firmware
description: BIOS
vendor: LENOVO
physical id: 0
version: 9BCN26WW
date: 07/31/2014
size: 128KiB
capacity: 4032KiB
capabilities: pci upgrade shadowing cdboot bootselect edd int13floppynec int13floppytoshiba int13floppy360 int13floppy1200 int13floppy720 int13floppy2880 int9keyboard int10video acpi usb biosbootspecification uefi
......

You can print a summary of your hardware information by using the -short option.

tecmint@tecmint ~ $ sudo lshw -short
H/W path       Device      Class          Description
=====================================================
system         20354 (LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70)
/0                         bus            Lancer 5A5
/0/0                       memory         128KiB BIOS
/0/4                       processor      Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz
/0/4/b                     memory         32KiB L1 cache
/0/4/c                     memory         256KiB L2 cache
/0/4/d                     memory         3MiB L3 cache
/0/a                       memory         32KiB L1 cache
/0/12                      memory         8GiB System Memory
/0/12/0                    memory         DIMM [empty]
/0/12/1                    memory         DIMM [empty]
/0/12/2                    memory         8GiB SODIMM DDR3 Synchronous 1600 MHz (0.6 ns)
/0/12/3                    memory         DIMM [empty]
/0/100                     bridge         Haswell-ULT DRAM Controller
/0/100/2                   display        Haswell-ULT Integrated Graphics Controller
/0/100/3                   multimedia     Haswell-ULT HD Audio Controller
...

If you wish to generate output as a html file, you can use the option -html.

tecmint@tecmint ~ $ sudo lshw -html > lshw.html

Generate Linux Hardware Information in HTML

3. How to View Linux CPU Information

To view information about your CPU, use the lscpu command as it shows information about your CPU architecture such as number of CPU’s, cores, CPU family model, CPU caches, threads, etc from sysfs and /proc/cpuinfo.

tecmint@tecmint ~ $ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 69
Stepping:              1
CPU MHz:               768.000
BogoMIPS:              4788.72
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0-3

4. How to Collect Linux Block Device Information

Block devices are storage devices such as hard disks, flash drives etc. lsblk command is used to report information about block devices as follows.

tecmint@tecmint ~ $ lsblk
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 931.5G  0 disk 
├─sda1    8:1    0  1000M  0 part 
├─sda2    8:2    0   260M  0 part /boot/efi
├─sda3    8:3    0  1000M  0 part 
├─sda4    8:4    0   128M  0 part 
├─sda5    8:5    0 557.1G  0 part 
├─sda6    8:6    0    25G  0 part 
├─sda7    8:7    0  14.7G  0 part 
├─sda8    8:8    0     1M  0 part 
├─sda9    8:9    0 324.5G  0 part /
└─sda10   8:10   0   7.9G  0 part [SWAP]
sr0      11:0    1  1024M  0 rom  

If you want to view all block devices on your system then include the -a option.

tecmint@tecmint ~ $ lsblk -a
NAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda       8:0    0 931.5G  0 disk 
├─sda1    8:1    0  1000M  0 part 
├─sda2    8:2    0   260M  0 part /boot/efi
├─sda3    8:3    0  1000M  0 part 
├─sda4    8:4    0   128M  0 part 
├─sda5    8:5    0 557.1G  0 part 
├─sda6    8:6    0    25G  0 part 
├─sda7    8:7    0  14.7G  0 part 
├─sda8    8:8    0     1M  0 part 
├─sda9    8:9    0 324.5G  0 part /
└─sda10   8:10   0   7.9G  0 part [SWAP]
sdb       8:16   1         0 disk 
sr0      11:0    1  1024M  0 rom  
ram0      1:0    0    64M  0 disk 
ram1      1:1    0    64M  0 disk 
ram2      1:2    0    64M  0 disk 
ram3      1:3    0    64M  0 disk 
ram4      1:4    0    64M  0 disk 
ram5      1:5    0    64M  0 disk 
ram6      1:6    0    64M  0 disk 
ram7      1:7    0    64M  0 disk 
ram8      1:8    0    64M  0 disk 
ram9      1:9    0    64M  0 disk 
loop0     7:0    0         0 loop 
loop1     7:1    0         0 loop 
loop2     7:2    0         0 loop 
loop3     7:3    0         0 loop 
loop4     7:4    0         0 loop 
loop5     7:5    0         0 loop 
loop6     7:6    0         0 loop 
loop7     7:7    0         0 loop 
ram10     1:10   0    64M  0 disk 
ram11     1:11   0    64M  0 disk 
ram12     1:12   0    64M  0 disk 
ram13     1:13   0    64M  0 disk 
ram14     1:14   0    64M  0 disk 
ram15     1:15   0    64M  0 disk 

5. How to Print USB Controllers Information

The lsusb command is used to report information about USB controllers and all the devices that are connected to them.

tecmint@tecmint ~ $ lsusb
Bus 001 Device 002: ID 8087:8000 Intel Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 005: ID 0bda:b728 Realtek Semiconductor Corp. 
Bus 002 Device 004: ID 5986:0249 Acer, Inc 
Bus 002 Device 003: ID 0bda:0129 Realtek Semiconductor Corp. RTS5129 Card Reader Controller
Bus 002 Device 002: ID 045e:00cb Microsoft Corp. Basic Optical Mouse v2.0
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

You can use the -v option to generate a detailed information about each USB device.

tecmint@tecmint ~ $ lsusb -v

6. How to Print PCI Devices Information

PCI devices may included usb ports, graphics cards, network adapters etc. The lspci tool is used to generate information concerning all PCI controllers on your system plus the devices that are connected to them.

To print information about PCI devices run the following command.

tecmint@tecmint ~ $ lspci
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b)
00:03.0 Audio device: Intel Corporation Haswell-ULT HD Audio Controller (rev 0b)
00:14.0 USB controller: Intel Corporation Lynx Point-LP USB xHCI HC (rev 04)
00:16.0 Communication controller: Intel Corporation Lynx Point-LP HECI #0 (rev 04)
00:1b.0 Audio device: Intel Corporation Lynx Point-LP HD Audio Controller (rev 04)
00:1c.0 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 3 (rev e4)
00:1c.3 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 4 (rev e4)
00:1c.4 PCI bridge: Intel Corporation Lynx Point-LP PCI Express Root Port 5 (rev e4)
00:1d.0 USB controller: Intel Corporation Lynx Point-LP USB EHCI #1 (rev 04)
00:1f.0 ISA bridge: Intel Corporation Lynx Point-LP LPC Controller (rev 04)
00:1f.2 SATA controller: Intel Corporation Lynx Point-LP SATA Controller 1 [AHCI mode] (rev 04)
00:1f.3 SMBus: Intel Corporation Lynx Point-LP SMBus Controller (rev 04)
01:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit
03:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 840M] (rev a2)

Use the -t option to produce output in a tree format.

tecmint@tecmint ~ $ lspci -t
-[0000:00]-+-00.0
+-02.0
+-03.0
+-14.0
+-16.0
+-1b.0
+-1c.0-[01]----00.0
+-1c.3-[02]----00.0
+-1c.4-[03]----00.0
+-1d.0
+-1f.0
+-1f.2
\-1f.3

Use the -v option to produce detailed information about each connected device.

tecmint@tecmint ~ $ lspci -v
00:00.0 Host bridge: Intel Corporation Haswell-ULT DRAM Controller (rev 0b)
Subsystem: Lenovo Device 3978
Flags: bus master, fast devsel, latency 0
Capabilities: 
00:02.0 VGA compatible controller: Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 0b) (prog-if 00 [VGA controller])
Subsystem: Lenovo Device 380d
Flags: bus master, fast devsel, latency 0, IRQ 62
Memory at c3000000 (64-bit, non-prefetchable) [size=4M]
Memory at d0000000 (64-bit, prefetchable) [size=256M]
I/O ports at 6000 [size=64]
Expansion ROM at  [disabled]
Capabilities: 
Kernel driver in use: i915
.....

7. How to Print SCSI Devices Information

To view all your scsi/sata devices, use the lsscsi command as follows. If you do not have lsscsi tool installed, run the following command to install it.

$ sudo apt-get install lsscsi        [on Debian derivatives]
# yum install lsscsi                 [On RedHat based systems]
# dnf install lsscsi                 [On Fedora 21+ Onwards]

After install, run the lsscsi command as shown:

tecmint@tecmint ~ $ lsscsi
[0:0:0:0]    disk    ATA      ST1000LM024 HN-M 2BA3  /dev/sda 
[1:0:0:0]    cd/dvd  PLDS     DVD-RW DA8A5SH   RL61  /dev/sr0 
[4:0:0:0]    disk    Generic- xD/SD/M.S.       1.00  /dev/sdb 

Use the -s option to show device sizes.

tecmint@tecmint ~ $ lsscsi -s
[0:0:0:0]    disk    ATA      ST1000LM024 HN-M 2BA3  /dev/sda   1.00TB
[1:0:0:0]    cd/dvd  PLDS     DVD-RW DA8A5SH   RL61  /dev/sr0        -
[4:0:0:0]    disk    Generic- xD/SD/M.S.       1.00  /dev/sdb        -

8. How to Print Information about SATA Devices

You can find some information about sata devices on your system as follows using the hdparm utility. In the example below, I used the block device /dev/sda1 which the harddisk on my system.

tecmint@tecmint ~ $ sudo hdparm /dev/sda1
/dev/sda1:
multcount     =  0 (off)
IO_support    =  1 (32-bit)
readonly      =  0 (off)
readahead     = 256 (on)
geometry      = 56065/255/63, sectors = 2048000, start = 2048

To print information about device geometry interms of cylinders, heads, sectors, size and the starting offset of the device, use the -g option.

tecmint@tecmint ~ $ sudo hdparm -g /dev/sda1
/dev/sda1:
geometry      = 56065/255/63, sectors = 2048000, start = 2048

9. How to Print Linux File System Information

To gather information about file system partitions, you can use fdisk command. Although the main functionality of fdisk command is to modify file system partitions, it can also be used to view information about the different partitions on your file system.

You can print partition information as follows. Remember to run the command as a superuser or else you may not see any output.

tecmint@tecmint ~ $ sudo fdisk -l
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0xcee8ad92
Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1  1953525167   976762583+  ee  GPT
Partition 1 does not start on physical sector boundary.

10. How to Extract Information about Hardware Components

You can also use the dmidecode utility to extract hardware information by reading data from the DMI tables.

To print information about memory, run this command as a superuser.

tecmint@tecmint ~ $ sudo dmidecode -t memory
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0005, DMI type 5, 24 bytes
Memory Controller Information
Error Detecting Method: None
Error Correcting Capabilities:
None
Supported Interleave: One-way Interleave
Current Interleave: One-way Interleave
Maximum Memory Module Size: 8192 MB
Maximum Total Memory Size: 32768 MB
Supported Speeds:
Other
Supported Memory Types:
Other
Memory Module Voltage: Unknown
Associated Memory Slots: 4
0x0006
0x0007
0x0008
0x0009
Enabled Error Correcting Capabilities:
None
...

To print information about system, run this command.

tecmint@tecmint ~ $ sudo dmidecode -t system
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0001, DMI type 1, 27 bytes
System Information
Manufacturer: LENOVO
Product Name: 20354
Version: Lenovo Z50-70
Serial Number: 1037407803441
UUID: 29D2B1E4-37D2-11E4-9F6E-28D244EBBD98
Wake-up Type: Power Switch
SKU Number: LENOVO_MT_20354_BU_idea_FM_Lenovo Z50-70
Family: IDEAPAD
...

To print information about BIOS, run this command.

tecmint@tecmint ~ $ sudo dmidecode -t bios
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0000, DMI type 0, 24 bytes
BIOS Information
Vendor: LENOVO
Version: 9BCN26WW
Release Date: 07/31/2014
Address: 0xE0000
Runtime Size: 128 kB
ROM Size: 4096 kB
Characteristics:
PCI is supported
BIOS is upgradeable
BIOS shadowing is allowed
Boot from CD is supported
Selectable boot is supported
EDD is supported
Japanese floppy for NEC 9800 1.2 MB is supported (int 13h)
Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
5.25"/360 kB floppy services are supported (int 13h)
5.25"/1.2 MB floppy services are supported (int 13h)
3.5"/720 kB floppy services are supported (int 13h)
3.5"/2.88 MB floppy services are supported (int 13h)
8042 keyboard services are supported (int 9h)
CGA/mono video services are supported (int 10h)
ACPI is supported
USB legacy is supported
BIOS boot specification is supported
Targeted content distribution is supported
UEFI is supported
BIOS Revision: 0.26
Firmware Revision: 0.26
...

To print information about processor, run this command.

tecmint@tecmint ~ $ sudo dmidecode -t processor
# dmidecode 2.12
# SMBIOS entry point at 0xaaebef98
SMBIOS 2.7 present.
Handle 0x0004, DMI type 4, 42 bytes
Processor Information
Socket Designation: U3E1
Type: Central Processor
Family: Core i5
Manufacturer: Intel(R) Corporation
ID: 51 06 04 00 FF FB EB BF
Signature: Type 0, Family 6, Model 69, Stepping 1
Flags:
...

Summary

There are many other ways you can use to obtain information about your system hardware components. Most of these commands use files in the /proc directory to extract system information.

 

Advertisements

Linux Delete / Uninstall Software

Different Linux distributions comes with different tools to remove the software installed under Linux.

First, open terminal (bash prompt).

You must be login as root user to run any one of the following command.

Remove Software under Red Hat / RHEL / Fedora / CentOS Linux

Use rpm or yum command to delete the software.

To list the installed software type

rpm -qa | less
rpm -qa {software-name}
yum list | less
yum list {software-name}

To get information about httpd package, enter:

rpm -qa httpd
yum list httpd

To remove a software use rpm or yum command as follows

rpm -e {software-name}
yum remove {software-name}

To delete a package called httpd, enter:

rpm -e httpd
yum remove httpd

Delete / Uninstall Software Under Debian / Ubuntu Linux

To list installed software type:

dpkg --list
dpkg --list | less
dpkg --list | grep apache

To delete the software, enter:

sudo apt-get remove {package-name}
sudo apt-get remove apache

How to use “tree command” on linux

Tree is a program available for Unix and Unix-like systems. tree is a recursive directory listing program that produces a depth-indented listing of files.
With no arguments, tree lists the files in the current directory. When directory arguments are given, tree listsall the files and/or directories found in the given directories each in turn. Upon completion of listing all files/directories found, tree returns the total number of files and/or directories listed.

In this article we will show at how to list contents in a directory as the the title implies in a tree format.

Install tree command

By default the tree command is not installed. Type following command to install tree command on RHEL/CentOS and Fedora linux:

# yum install tree -y

If you are using Debian/Ubuntu, Mint Linux type following command in your terminal:

$ sudo apt-get install tree -y

Using tree command

To view directory structure of a directory in tree format, use tree command as

$ tree

By default, if no argument is provided to tree command, it prints tree of current directory.

Tree example output

Tree example output

Show only the directories:

$ tree -d
Show only directory tree

Show only directory tree

Show all files including hidden dot files:

$ tree -a

Limit the level or depth of recursion:

$ tree -L 2
Limit the level or depth of recursion

Limit the level or depth of recursion

Forward use tree on a directory:

$ tree
Forward use tree on a directory

Forward use tree on a directory

Run man tree for more on how to use tree.

$ man tree

“ls” Command

The listing command in UNIX and UNIX like operating System ‘ls‘ is one of the most basic and widely used utility in command-line. It is POSIX compliant utility available for GNU coreutils and BSD variants.

ls syntax

$ ls [options] [file|dir]  or

$ [file dir] ls comand

ls command options

ls command main options:

option description
ls -a list all files including hidden file starting with ‘.’
ls –color colored list [=always/never/auto]
ls -d list directories – with ‘ */’
ls -F add one char of */=>@| to enteries
ls -i list file’s inode index number
ls -l list with long format – show permissions
ls -la list long format including hidden files
ls -lh list long format with readable file size
ls -ls list with long format with file size
ls -r list in reverse order
ls -R list recursively directory tree
ls -s list file size
ls -S sort by file size
ls -t sort by time & date
ls -X sort by extension name

ls command examples

You can press the tab button to auto complete the file or folder names.

List directory Documents/Books with relative path:

$ ls Documents/Books

 

List directory /home/user/Documents/Books with absolute path.

$ ls /home/user/Documents/Books

 

List root directory:

$ ls /

 

List parent directory:

$ ls ..

 

List user’s home directory (e.g: /home/user):

$ ls ~

 

List with long format:

$ ls -l

 

Show hidden files:

$ ls -a

 

List with long format and show hidden files:

$ ls -la

 

Sort by date/time:

$ ls -t

 

Sort by file size:

$ ls -S

 

List all subdirectories:

$ ls *

 

Recursive directory tree list:

$ ls -R

 

List only text files with wildcard:

$ ls *.txt

 

ls redirection to output file:

$ ls > out.txt

 

List directories only:

$ ls -d */

 

List files and directories with full path:

$ ls -d $PWD/*

ls code generator

15 Useful “ifconfig” Commands to Configure Network Interface

ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage and query network interface parameters via command line interface or in a system configuration scripts.

The “ifconfig” command is used for displaying current network configuration information, setting up an ip address, netmask or broadcast address to an network interface, creating an alias for network interface, setting up hardware address and enable or disable network interfaces.

 

1. View All Network Setting

The “ifconfig” command with no arguments will display all the active interfaces details. The ifconfig command also used to check the assigned IP address of an server.

[root@tecmint ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:2341604 errors:0 dropped:0 overruns:0 frame:0
TX packets:2217673 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:293460932 (279.8 MiB)  TX bytes:1042006549 (993.7 MiB)
Interrupt:185 Memory:f7fe0000-f7ff0000
lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:5019066 errors:0 dropped:0 overruns:0 frame:0
TX packets:5019066 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2174522634 (2.0 GiB)  TX bytes:2174522634 (2.0 GiB)
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

2. Display Information of All Network Interfaces

The following ifconfig command with -a argument will display information of all active or inactive network interfaces on server. It displays the results for eth0, lo, sit0 and tun0.

[root@tecmint ~]# ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0
TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:293839516 (280.2 MiB)  TX bytes:1043722206 (995.3 MiB)
Interrupt:185 Memory:f7fe0000-f7ff0000
lo        Link encap:Local Loopback
inet addr:127.0.0.1  Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING  MTU:16436  Metric:1
RX packets:5022927 errors:0 dropped:0 overruns:0 frame:0
TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:2175739488 (2.0 GiB)  TX bytes:2175739488 (2.0 GiB)
sit0      Link encap:IPv6-in-IPv4
NOARP  MTU:1480  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.1.1.1  P-t-P:10.1.1.2  Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

3. View Network Settings of Specific Interface

Using interface name (eth0) as an argument with “ifconfig” command will display details of specific network interface.

[root@tecmint ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126  Bcast:172.16.25.63  Mask:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
RX packets:2345583 errors:0 dropped:0 overruns:0 frame:0
TX packets:2221421 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:293912265 (280.2 MiB)  TX bytes:1044100408 (995.7 MiB)
Interrupt:185 Memory:f7fe0000-f7ff0000

4. How to Enable an Network Interface

The “up” or “ifup” flag with interface name (eth0) activates an network interface, if it is not in active state and allowing to send and receive information. For example, “ifconfig eth0 up” or “ifup eth0” will activate the eth0 interface.

[root@tecmint ~]# ifconfig eth0 up
OR
[root@tecmint ~]# ifup eth0

5. How to Disable an Network Interface

The “down” or “ifdown” flag with interface name (eth0) deactivates the specified network interface. For example, “ifconfig eth0 down” or “ifdown eth0” command deactivates the eth0 interface, if it is in active state.

[root@tecmint ~]# ifconfig eth0 down
OR
[root@tecmint ~]# ifdown eth0

6. How to Assign a IP Address to Network Interface

To assign an IP address to an specific interface, use the following command with an interface name (eth0) and ip address that you want to set. For example, “ifconfig eth0 172.16.25.125” will set the IP address to interface eth0.

[root@tecmint ~]# ifconfig eth0 172.16.25.125

7. How to Assign a Netmask to Network Interface

Using the “ifconfig” command with “netmask” argument and interface name as (eth0) allows you to define an netmask to an given interface. For example, “ifconfig eth0 netmask 255.255.255.224” will set the network mask to an given interface eth0.

[root@tecmint ~]# ifconfig eth0 netmask 255.255.255.224

8. How to Assign a Broadcast to Network Interface

Using the “broadcast” argument with an interface name will set the broadcast address for the given interface. For example, “ifconfig eth0 broadcast 172.16.25.63” command sets the broadcast address to an interface eth0.

[root@tecmint ~]# ifconfig eth0 broadcast 172.16.25.63

9. How to Assign a IP, Netmask and Broadcast to Network Interface

To assign an IP address, Netmask address and Broadcast address all at once using “ifconfig” command with all arguments as given below.

[root@tecmint ~]# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63

10. How to Change MTU for an Network Interface

The “mtu” argument set the maximum transmission unit to an interface. The MTU allows you to set the limit size of packets that are transmitted on an interface. The MTU able to handle maximum number of octets to an interface in one single transaction. For example, “ifconfig eth0 mtu 1000” will set the maximum transmission unit to given set (i.e. 1000). Not all network interfaces supports MTU settings.

[root@tecmint ~]# ifconfig eth0 mtu 1000

11. How to Enable Promiscuous Mode

What happens in normal mode, when a packet received by a network card, it verifies that the packet belongs to itself. If not, it drops the packet normally, but in the promiscuous mode is used to accept all the packets that flows through the network card.

Most of the today’s network tools uses the promiscuous mode to capture and analyze the packets that flows through the network interface. To set the promiscuous mode, use the following command.

[root@tecmint ~]# ifconfig eth0 promisc

12. How to Disable Promiscuous Mode

To disable promiscuous mode, use the “-promisc” switch that drops back the network interface in normal mode.

[root@tecmint ~]# ifconfig eth0 -promisc

13. How to Add New Alias to Network Interface

The ifconfig utility allows you to configure additional network interfaces using alias feature. To add alias network interface of eth0, use the following command. Please note that alias network address in same sub-net mask. For example, if your eth0 network ip address is 172.16.25.125, then alias ip address must be 172.16.25.127.

[root@tecmint ~]# ifconfig eth0:0 172.16.25.127

Next, verify the newly created alias network interface address, by using “ifconfig eth0:0” command.

[root@tecmint ~]# ifconfig eth0:0
eth0:0    Link encap:Ethernet  HWaddr 00:01:6C:99:14:68
inet addr:172.16.25.123  Bcast:172.16.25.63  Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
Interrupt:17

14. How to Remove Alias to Network Interface

If you no longer required an alias network interface or you incorrectly configured it, you can remove it by using the following command.

[root@tecmint ~]# ifconfig eth0:0 down

15. How to Change the MAC address of Network Interface

To change the MAC (Media Access Control) address of an eth0 network interface, use the following command with argument “hw ether“. For example, see below.

[root@tecmint ~]# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF

These are the most useful commands for configuring network interfaces in Linux, for more information and usage of ifconfig command use the manpages like “man ifconfig” at the terminal. Check out some other networking utilities below.

How do I set or change Linux system password for any user account?

The passwd changes passwords for user and group accounts. A normal user may only change the password for his/her own account, the super user (or root) may change the password for any account. The administrator of a group may change the password for the group. passwd also changes account information, such as the full name of the user, user’s login shell, or password expiry date and interval.

Task: Set or Change User Password

Type passwd command as follows to change your own password:

$ passwd username

Output:

Changing password for vivek
(current) UNIX password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

The user is first prompted for his/her old password, if one is present. This password is then encrypted and compared against the stored password. The user has only one chance to enter the correct password. The super user is permitted to bypass this step so that forgotten passwords may be changed.

A new password is tested for complexity. As a general guideline, passwords should consist of 6 to 8 characters including one or more from each of following sets:

  1. Lower case alphabetics
  2. Upper case alphabetics
  3. Digits 0 thru 9
  4. Punctuation marks

Task: Change Password For Other User Account

You must login as root user, type the following command to change password for user vivek:
# passwd vivek
Output:

Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

Where,

  • vivek – is username or account name.

Task: Change Group Password

When the -g option is used, the password for the named group is changed. In this example, change password for group sales:
# passwd -g sales

The current group password is not prompted for. The -r option is used with the -g option to remove the current password from the named group. This allows group access to all members. The -R option is used with the -g option to restrict the named group for all users.

Install vsFTP server on CentOS 6.5

Install vsFTP server on CentOS 6.5

Easy Samba server installation on CentOS 6.5

Easy Samba server installation on CentOS 6.5

Security issue
# vim /etc/sysconfig/selinux

Show All Users on your samba server
    [root@localhost ~]# tail /etc/passwd

Block certain file extensions on samba linux

comment = vishalvyas
Path = /home/vishal
public = yes
writable = yes
browseable = yes
read only = no
valid user = vishal
create mask = 0775
Veto files = /*.exe/*.com/*.dll/*.bat/*.vbs/*.tmp/*.mp3/*.avi/*.mp4/*.wmv/*.wma/