Announcement

Collapse
No announcement yet.

Browsing your Hardware in Linux

Collapse
X
Collapse
  •  

  • Browsing your Hardware in Linux

    Sometimes it can be quite a challenge to find out what hardware you have but it is actually quite easy.
    Here are a few commands and some sample output for you.

    USB devices are usually easy to identify because you can just pick them up and look at them.
    Below will help you out with the few that just say NoName on it. Often those noname ones are the same as the named ones just with another wrapping. Below display a list of detected USB devices.

    # lsusb
    Bus 004 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 003: ID 0461:4d03 Primax Electronics, Ltd Kensington Mouse-in-a-box
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

    The PCMCIA port is not that common anymore or at least not commonly used.
    But this is how you list the detected PCMCIA devices. I dont have anything plugged in so this example might not hand you the big picture.

    # lspcmcia
    Socket 0 Bridge: [yenta_cardbus] (bus ID: 0000:00:08.0)

    Below will display the loaded modules and what is using it. I cut away some of the entries to make it readable.
    The output will differ on your system anyway.

    # lsmod
    Module Size Used by
    binfmt_misc 7560 1
    ipv6 235396 14
    dm_snapshot 14340 0
    dm_mirror 15136 0
    dm_log 8452 1 dm_mirror
    dm_mod 46216 3 dm_snapshot,dm_mirror,dm_log
    i2c_dev 5256 0
    eeprom 5232 0
    ...

    The next one is a listing of the Hardware Abstraction Layer. I can actually be quite handy but you definently want to use grep with this one. It has a lot of output depending on how many HAL objects you have in the device database.
    I did the lshal with no filters because I wanted to show what you can find here.
    Try out something like "lshal |grep cdrom" on your systen to see what information you get.

    # lshal
    ...
    info.product = 'IDE device (master)' (string)
    info.subsystem = 'ide' (string)
    ...
    pci.product = '65x/M650/740 PCI/AGP VGA Display Adapter' (string)
    pci.product_id = 25381 (0x6325) (int)
    pci.subsys_product_id = 4127 (0x101f) (int)
    pci.subsys_vendor = 'Fujitsu Siemens Computers' (string)
    ...
    pci.vendor = 'Silicon Integrated Systems [SiS]' (string)
    pci.vendor_id = 4153 (0x1039) (int)


    Dumped 87 device(s) from the Global Device List.
    ------------------------------------------------

    Yes I admit it. The next one is only included because of the fun of it. I guess it is only usable if you are in the shell already and what to see what you have in your DVD drive and dont want to bend down and eject your DVD..
    I cut away some of the output here also. This will give a brief rapport on what is in your DVD drive.

    # lsdvd
    Disc Title: IP_MAN_DISC_1
    Title: 01, Length: 00:00:21.140 Chapters: 03, Cells: 03, Audio streams: 01, Subpictures: 00
    Title: 02, Length: 01:46:20.210 Chapters: 23, Cells: 24, Audio streams: 02, Subpictures: 01
    ...
    Title: 17, Length: 00:01:38.040 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
    Title: 18, Length: 00:01:25.240 Chapters: 01, Cells: 01, Audio streams: 01, Subpictures: 01
    Longest track: 02

    The next one is one of the most useful ones. This will display the detected devices attached to the PCI bus to help you load the matching module.

    # lspci
    00:00.0 Host bridge: Silicon Integrated Systems [SiS] 650/M650 Host (rev 11)
    00:01.0 PCI bridge: Silicon Integrated Systems [SiS] Virtual PCI-to-PCI bridge (AGP)
    00:02.0 ISA bridge: Silicon Integrated Systems [SiS] SiS962 [MuTIOL Media IO] (rev 04)
    00:02.1 SMBus: Silicon Integrated Systems [SiS] SiS961/2 SMBus Controller
    00:02.3 FireWire (IEEE 1394): Silicon Integrated Systems [SiS] FireWire Controller
    00:02.5 IDE interface: Silicon Integrated Systems [SiS] 5513 [IDE]
    00:02.6 Modem: Silicon Integrated Systems [SiS] AC'97 Modem Controller (rev a0)
    00:02.7 Multimedia audio controller: Silicon Integrated Systems [SiS] AC'97 Sound Controller (rev a0)
    00:03.0 USB Controller: Silicon Integrated Systems [SiS] USB 1.1 Controller (rev 0f)
    00:03.1 USB Controller: Silicon Integrated Systems [SiS] USB 1.1 Controller (rev 0f)
    00:03.2 USB Controller: Silicon Integrated Systems [SiS] USB 1.1 Controller (rev 0f)
    00:03.3 USB Controller: Silicon Integrated Systems [SiS] USB 2.0 Controller
    00:04.0 Ethernet controller: Silicon Integrated Systems [SiS] SiS900 PCI Fast Ethernet (rev 91)
    00:08.0 CardBus bridge: O2 Micro, Inc. OZ601/6912/711E0 CardBus/SmartCardBus Controller
    01:00.0 VGA compatible controller: Silicon Integrated Systems [SiS] 65x/M650/740 PCI/AGP VGA Display Adapter

    One way of using this could be as below.

    # lspci |grep audio
    00:02.7 Multimedia audio controller: Silicon Integrated Systems [SiS] AC'97 Sound Controller (rev a0)

    The last one I will present is kind of off topic but it comes in handy now and then. It is in the "ls-family" so I might just as well sneak it in. This command will display all open files on your running host. At least all visible to you and me.
    I do not show you a full listing with no filters because it is trivial and quite long. Instead Ill show you how I use it.
    I am a big fan of Google and ofcourse I use Chrome on my Linux boxes. For the most part at least. If I want to know which files, which includes sockets as they also figure as files, I would do as below.
    Here I also cut out some of the output. You will be surpriced when you learn how many file handles Chrome will open.

    testbox:~# lsof |grep chrome
    chrome 5335 root cwd DIR 3,1 4096 741889 /root
    chrome 5335 root rtd DIR 3,1 4096 2 /
    chrome 5335 root txt REG 3,1 34523900 81894 /opt/google/chrome/chrome
    chrome 5335 root 7r FIFO 0,6 90387 pipe
    chrome 5335 root 10u unix 0xdcbea480 91241 socket
    chrome 5335 root 14w FIFO 0,6 91244 pipe
    chrome 5335 root 15u 0000 0,7 0 13 anon_inode
    chrome 5335 root 16u unix 0xda565280 91245 socket
    chrome 5335 root 19w FIFO 0,6 91247 pipe
    chrome 5335 root 20u 0000 0,7 0 13 anon_inode
    chrome 5335 root 23u unix 0xda565680 91275 socket
    chrome 5335 root 25r FIFO 0,6 91277 pipe
    chrome 5335 root 27u unix 0xdcf1a900 91280 /root/.config/google-chrome/SingletonSocket
    chrome 5335 root 28r CHR 1,9 1078 /dev/urandom
    chrome 5335 root 31u REG 3,1 598016 763191 /root/.cache/google-chrome/Cache/data_0
    ...
    chrome 5340 root 7u unix 0xdcf2c500 90390 socket
    chrome 5340 root 8w FIFO 0,6 90410 pipe
    chrome 5340 root 9r REG 3,1 1391223 82124 /opt/google/chrome/chrome.pak
    chrome 5340 root 10r REG 3,1 132294 82087 /opt/google/chrome/locales/en-US.pak
    chrome 5340 root 11r CHR 1,9 1078 /dev/urandom
    chrome 5409 root cwd DIR 3,1 0 792348 /tmp/chrome-sandbox-chroot-b8Y67N (deleted)
    chrome 5409 root 9r REG 3,1 1391223 82124 /opt/google/chrome/chrome.pak
    chrome 5409 root 10r REG 3,1 132294 82087 /opt/google/chrome/locales/en-US.pak
    chrome 5409 root 11r CHR 1,9 1078 /dev/urandom
    chrome 5409 root 15u unix 0xdcb70780 91942 socket
    chrome 5409 root 16r FIFO 0,6 91943 pipe
    chrome 5409 root 17w FIFO 0,6 91943 pipe
    chrome 5409 root 20u REG 0,16 262148 91403 /dev/shm/com.google.chrome.zdBQER (deleted)
    chrome 5409 root 21u REG 0,16 8 91282 /dev/shm/com.google.chrome.MvCFoG (deleted)

    Did you notice that Chrome actually use the /dev/urandom device?
      Posting comments is disabled.

    Categories

    Collapse

    Article Tags

    Collapse

    Latest Articles

    Collapse

    • Testing your Mail Server
      by Resheph
      Telnet to your smtp server using the following:
      "telnet example.com 25". The number "25" is the default portnumber for outging mail, defined by IANA.
      Substitute the address with your own address or ip number.
      Even though this might very well be possible to do on your ISP mail server, dont!!
      This will give you the SMTP server banner. I hope this has been changed or spoofed to protect from banner grabbing.
      In my example, it gives me "220 example.com...
      08-06-2016, 10:38 PM
    • Knowing your System Performance and State
      by Resheph
      Here are a few command line tools that will help you estimate your system usage and performance.
      There is a lot more information on this in the man pages so take a look there also. If you dont know your average system load you will not be able to determine if the load is in a peaking state or if the host is able to handle more load.
      Note that some commands might require installation of a few packages.

      Below gives a nice simple performance view of a HDU. Ofcourse running...
      08-06-2016, 10:35 PM
    • Browsing your Hardware in Linux
      by Resheph
      Sometimes it can be quite a challenge to find out what hardware you have but it is actually quite easy.
      Here are a few commands and some sample output for you.

      USB devices are usually easy to identify because you can just pick them up and look at them.
      Below will help you out with the few that just say NoName on it. Often those noname ones are the same as the named ones just with another wrapping. Below display a list of detected USB devices.

      # lsusb
      Bus...
      08-06-2016, 10:34 PM
    • Keeping an Eye on Logfiles
      by Resheph
      If you want to watch a log file and have it update when ever new content is added the "tail" command is an easy on-the-fly tool to use.
      Ofcourse for long term use other implementations of log file analyzers or syslog services would be better.
      Here is a short example and some sample output showing a failed root login attempt.

      # tail -n 20 -f -s 5 /var/log/auth.log
      Feb 17 04:11:09 testbox login[4822]: pam_unix(login:auth): authentication failure; logname=LOGIN...
      08-06-2016, 10:31 PM
    • Learn which Libraries Programs Call
      by Resheph
      Sometimes it comes in handy to know what libraries and what versions of those libraries some software is depending on.
      This is quite easy and is done with the "ldd" command.

      Here are the dependencies that the "ls" command has. Remark that you have to use the absolute path as ldd does not support the use of the search path stated in the environment variable PATH.

      # ldd /bin/ls
      linux-gate.so.1 => (0xb7fd4000)
      librt.so.1 => /lib/i686/cmov/librt.so.1...
      08-06-2016, 10:29 PM
    Working...
    X