Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

-i.e - how to get a full list of hardware components in command line (on a machine with no window system)

Thank you.

share|improve this question

12 Answers 12

up vote 31 down vote accepted

lspci for pci cards, lsusb for usb, lshw works on debian based distros, here's a list of ways to get other hardware specs,

share|improve this answer
    
thanks for the link. I admit that I could have googled it, but google is a mess man. –  Evgeny Jul 31 '09 at 18:28

If available, dmidecode comes in handy. Particularly on Dell, HP, IBM hardware, where they bother to program relevant hardware information into the various registers.

share|improve this answer
7  
dmidecode is nice. One day when I was using it to look at memory details I realized you could find out the Dell service tag too: dmidecode | grep -i serial | egrep -o '[0-9A-Z]{7}$' | head -n1 –  Kyle Brandt Jul 31 '09 at 18:30
1  
Agreed, you can run dmidecode and just grep for the info you want. –  barfoon Aug 20 '09 at 19:02
1  
Also works great on apple hardware. –  Matt3o12 Sep 9 at 12:18

lspci is a great utility for listing the system hardware. (Anything on the PCI bus, anyway.)

cat /proc/cpuinfo - Displays CPU info

cat /proc/meminfo - Displays memory info

dmesg (or cat /var/log/dmesg) contains some info, not necessarily everything.

If you have a RedHat/CentOS system, you can use sosreport to collect a good bit of information, though I don't know if it has all the hardware info listed in it.

Those are some good places to start to find the info you're looking for.

share|improve this answer

The /proc filesystem will give you the information that you want... BUT i don't know how you will get it is one easy place.

'cat /proc/cpuinfo' will tell you about your CPU 'cat /proc/devices' will tell you some limited information about block devices. 'ifconfig -a' will tell you about network connections

Others will be able to tell you about more devices. Are you troubleshooting a particular device? If so, you will get better help asking a specific question.

share|improve this answer
    
thanks no, I'm trying to move from host to host and would like to see what is the difference in hardware in general - to see if I can move by re-imaging. –  Evgeny Jul 31 '09 at 18:26
1  
As long as the initial parts of the boot work, most distributions will just detect the hardware changes and adapt. If you have problems with the boot part, install the same distribution as you are moving onto the new hardware, update it to the same kernel as you are moving and then copy the mkintrd file onto the image file system and that should solve your boot problems. If it really goes wrong, you still have all your data on the old machine. –  Ptolemy Jul 31 '09 at 18:45
    
If you already have Linux on the second machine and it is working, assuming the Kernel is a generic build and just as recent, it will load all the modules (modules are kind of analogous to Windows Drivers) it needs. Linux installations are not really hardware specific in that way. –  Kyle Brandt Jul 31 '09 at 18:55
    
The /boot/initrd-2.6.*.img file is not quite so generic. It is used by the kernel when its passed control by grub. It needs to have all the settings and modules to load your root file system. This file is made in a generic way be running mkinitrd, however you need to have booted the system first... –  Ptolemy Jul 31 '09 at 21:53

to summarize that, I'd say here is good start to get information about your system:

  1. dmesg - print or control the kernel ring buffer
  2. lspci - list all PCI devices
  3. lsusb - list USB devices
  4. /proc - process information pseudo-file system
share|improve this answer

I recommend checking out facter which outputs a lot of information in a form that is easy to use in scripts.

http://www.puppetlabs.com/puppet/related-projects/facter/

share|improve this answer

I really enjoy using "Facter". Gives a nice list of very useful information.

share|improve this answer
# tree -d /sys/devices
share|improve this answer

The easiest thing is to type "dmesg | more" on the command line, which allows you to see all the boot output that occurs during the last system startup.

share|improve this answer

For hard disks I use a custom script which massages into one list the outputs of:

cat /proc/partitions
cat /proc/mounts

parted -m /dev/sdX unit MB print # need to be root for parted
# or
parted -m -l unit MB print

blkid /dev/sdXN
share|improve this answer

below code u can copy using vi

#!/bin/bash

a=1; c=0
a=1; c=0
# Gather system information, can e.g. be sent to | mail in a cronjob
f_() { while read l; do echo $l; done < $f ; }
#
f_() { while read l; do echo $l; done < $f ; }
# TODO
# ----
# * Netstat output
# * Memory/swap information
# * ifconfig information
# * Make output dependent on argv
# * md5sum checks                               (done)
# * Keep previeous values and compare
# * How to
# * chmod a+x sysinfo.sh
# * ./sysinfo.sh
####################### DO NOT EDIT UNDER THIS LINE ###########################

siheader() {
        echo "================================================================"
        echo -e "* System statistics for: \t`hostname`.`dnsdomainname`"
        echo -e "* Generated on: \t\t`date`"
        echo -e "* Running as: \t\t\t`whoami`"
        echo
}

fuptime() {
        upSeconds=$(cat /proc/uptime | tr "." " " | awk '{print $1}')
        secs=$((${upSeconds}%60))
        mins=$((${upSeconds}/60%60))
        hours=$((${upSeconds}/3600/24))
        days=$((${upSeconds}/86400))
        if [ "${days}" -ne "0" ]
        then
                echo -n "${days} days, "
        fi
        echo "`printf '%02d' ${hours}`:`printf '%02d' ${mins}`:`printf '%02d' ${secs}`"
}

siuptime() {
        echo "=================== Uptime ====================================="
        echo -e "* Uptime: \t\t\t`fuptime`"
        if [ -x /usr/bin/uprecords ];
        then
                echo -e "* High score: \t\t\t`uprecords | tail -n1 | cut -d'|' -f1 | cut -d'n' -f3 | sed 's/^[[:blank:]]*//'`"
        fi
        echo -e "* Load average: \t\t`cat /proc/loadavg | head -c14`"
        echo
}

fw () {
        OFS=${IFS}
        IFS=$'\n'
        CNT=$(echo `w | wc -l`-1 | bc)

        w | tail -n ${CNT} | while read -r a;
        do
                echo -e "\t${a}"
        done

        IFS=${OFS}
}

siusers() {
        echo "=================== Users ======================================"
        echo -e "* Active users: \t\t`who | wc -l`"
        echo "* User information"
        fw
        echo
}

fpstree() {
        OFS=${IFS}
        IFS=$'\n'
        pstree | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
}

fcomms() {
        ps -eo comm | sort | uniq | grep -v ^COMMAND | column
        echo

        IFS=${OFS}
}

fprocs() {
        echo `TERM=Linux top -n1 -b | grep "Tasks" | awk '{print $4,$6,$8,$10}'`
        echo -e "==================================Tasks process and memory utilization=============================\n"
    echo "`top -n1 -b`"
}


sitasks() {
        echo "=================== Tasks ======================================"
        echo -e "* Number of running tasks: \t$(echo `ps ax | wc -l` - 1 | bc)"
        #This screws up the email
        #echo "* PS Tree:"
        #fpstree
        echo "* Running programs:"
        fcomms
        echo -e "* CPU load: \t\t\t`TERM=linux top -n2 -b | grep 'Cpu' | tail -n1 | awk '{print $2+$4+$6}'`%"
        PROCS=`fprocs`
        echo "* Process state:"
        echo -e "\tRunning: \t\t`echo ${PROCS} | awk '{print $1}'`"
        echo -e "\tSleeping: \t\t`echo ${PROCS} | awk '{print $2}'`"
        echo -e "\tZombie: \t\t`echo ${PROCS} | awk '{print $3}'`"
        echo -e "\tStopped: \t\t`echo ${PROCS} | awk '{print $4}'`"
        echo
}

froute() {
        OFS=${IFS}
        IFS=$'\n'

        CNT=$(echo `/sbin/route | wc -l` - 1 | bc)
        /sbin/route | tail -n ${CNT} | while read -r a;
        do
                echo -e "\t${a}"
        done

        IFS=${OFS}
}

sinetwork() {
        echo "=================== Networking ================================"
        echo "* Routing table:"
        froute
        echo
}

simemory() {
        echo "=================== Memory ===================================="
        RAMTOTAL=`echo $(($(cat /proc/meminfo | grep MemTotal | awk '{print $2}')/1024))`
        echo "* Ram:\t\t\t free of ${RAMTOTAL}Mb"
}

sidiskstats() {
        echo "=================== Hard Disc ================================="
        echo "* Disk Information:"
        OFS=${IFS}
        IFS=$'\n'
        df -h | grep -v ^none | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
        echo
        echo "* Mounts:"
        OFS=${IFS}
        IFS=$'\n'
        mount | while read -r a;
        do
                echo -e "\t${a}"
        done
        IFS=${OFS}
        echo
}

simd5() {
        if [ ! -e md5sums.lst ];
        then
                return
        fi

        echo "=================== MD5Sum Check =============================="

        OFS=${IFS}
        IFS=$'\n'

        echo "* Checking MD5 Sums"

        cat md5sums.lst | grep "^/" | while read -r a;
        do
                F=`echo ${a} | cut -d':' -f1`
                S=`echo ${a} | cut -d':' -f2`
                S2=`md5sum ${F} | cut -d' ' -f1`
                echo -n -e "\t${F}: \t\t\t\t"
                if [ "${S}" = "${S2}" ];
                then
                        echo "[OK]"
                else
                        echo "[INVALID]"
                fi                        
        done

        IFS=${OFS}
        echo
}


##For finding CPU model, cores and 
cpuinfo() {
    echo "=================== CPU Details for Xen =============================="
    echo -e "CPU Details: \n`cat /proc/cpuinfo | sed -n '1,/^$/p'`"
    echo -e "No of Cores: \n`cat /proc/cpuinfo | grep processor | wc -l`"
    if [ "egrep '(vmx|svm)' /proc/cpuinfo >/dev/null 2>/dev/null" ];
    then
        echo -e "\n===============================================================\nServer supports Full-virtualization"
    else
        echo -e "\n===============================================================\nEither server does not support Full-virtualization or it is turned off in BIOS"
    fi

    if [ "egrep 'pae' /proc/cpuinfo >/dev/null 2>/dev/null" ];
    then
        echo -e "\n===============================================================\nServer supports Para-virtualization"
    else
        echo -e "\n===============================================================\nServer does not support Para-virtualization"
    fi
}

##For disk info
diskinfo() {
        echo "=================== Disk usage =============================="
        echo -e "Disk Usage details: \n`df -h`"
}   
##Distro info
distroinfo() {
        echo "=================== Distro Info =============================="
        echo -e "Distro details: \n`lsb_release -a`"
        echo -e "Kernel details: \n`uname -a`"
}   

##Distro info
deviceinfo() {
        echo "=================== Device Info =============================="
        echo -e "Device details: \n`lspci -v`"
        echo -e "Kernel details: \n`uname -a`"
}   
summary() {
        siheader
        siuptime
        siusers
        sitasks
        sinetwork

        simemory
        sidiskstats
    fprocs
        simd5
    deviceinfo
    cpuinfo
    distroinfo
        echo "==============================================================="
        echo "* Brought to you by Taashee- http://www.taashee.com"
}

summary
share|improve this answer
    
You need to make that all in a code block so it doesn't look damaged. –  Bill Weiss Aug 20 '09 at 21:32
    
Thanks Bill sorry ask u such questions how do i do that pls let me next time i'll do it pls ignore my English –  Rajat Aug 21 '09 at 4:30

inxi will show just about everything, run with no arguments for short form, the options are many however, run inxi -h to see them

inxi is a 'full featured information script' as described by the project home page: https://code.google.com/p/inxi/

Here is information about how you can install it on Ubuntu: http://askubuntu.com/questions/284635/inxi-installation-on-ubuntu

share|improve this answer
    
Inxi is a relatively new tool and not one you'll find on most distributions. You should add some more information and links. –  itsbruce Oct 24 '12 at 22:16

protected by sysadmin1138 May 17 '12 at 20:07

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.