Operating System - Linux
1829149 Members
2319 Online
109986 Solutions
New Discussion

Re: NIC speed and mode of communication

 
SOLVED
Go to solution
Ankit Madan
New Member

NIC speed and mode of communication

Can anyone tell me how to calculate the ethernet card speed and mode of communication(Full Duplex/Half Duplex) and collision rate if I am not the root user. I know about ethtool and mii-tool but they can't run as a normal user.
2 REPLIES 2
Steven E. Protter
Exalted Contributor

Re: NIC speed and mode of communication

Shalom,

Always helps to know the distribution of Linux.

You need to look into a tool called sudo, which will let you authorize these two tools for non-root users.

Here you go:
[root@prottervm ~]# mii-tool eth0
eth0: negotiated 100baseTx-FD, link ok
[root@prottervm ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Current message level: 0x00000007 (7)
Link detected: yes

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Matti_Kurkela
Honored Contributor
Solution

Re: NIC speed and mode of communication

You can get the number of collisions by reading the appropriate sysfs file for your NIC. For example, eth0:

cat /sys/class/net/eth0/statistics/collisions

If your system uses a 2.4.xx or older kernel, the /sys virtual filesystem does not exist in it. In that case, you can run the ifconfig command with no options as a regular user, specifying an absolute path:

/sbin/ifconfig eth0

As far as I know, there is no way to get the speed/duplex information without root privileges.

However, if the number of collisions is exactly 0 and the system has been running for a while, the system is either in a _very_ low-traffic network or has been configured for full duplex. (Full duplex = the "transmit" and "receive" wires are completely independent, so the collision detection is switched off.)

MK
MK