Re: 20 basic Linux newbie commands to identify the system - Redhat

This is a discussion on Re: 20 basic Linux newbie commands to identify the system - Redhat ; On Wed, 31 Mar 2004 at 21:29 GMT, Ellen Spelling wrote: > What are the 20 basic newbie Redhat Linux commands I should send to my > users so they can identify the key particulars about any Redhat system? > ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Re: 20 basic Linux newbie commands to identify the system

  1. Re: 20 basic Linux newbie commands to identify the system

    On Wed, 31 Mar 2004 at 21:29 GMT, Ellen Spelling wrote:
    > What are the 20 basic newbie Redhat Linux commands I should send to my
    > users so they can identify the key particulars about any Redhat system?
    >
    > Here is what I've compiled so far for our very very very Sun centric crowd.
    >
    > Please improve for all the USENET to benefit.
    >
    > Ellen
    >
    > ************************************************** **************************
    > How best to determine important stuff about a Linux machine
    > ************************************************** **************************
    > ----------------------------------------------------------------------------
    > 0. To determine the Linux kernel:
    > tcsh% cat /proc/sys/kernel/osrelease


    Use bash instead of tcsh; it has all the features of tcsh and
    much more, as well as a much greater user base for getting help.

    All the examples below run in bash; put them in a file with
    "#!/bin/bash" as the first line.

    > EXAMPLE: 2.4.21-9.ELsmp
    >
    > tcsh% uname -r|sed s/smp//
    > EXAMPLE: 2.4.21-9.EL


    I don't know why you would want to get rid of "smp"; it is part of
    the name of the kernel you are running.

    kernel=`< /proc/sys/kernel/osrelease`
    echo ${kernel%smp}

    > ----------------------------------------------------------------------------
    > 1. To determine the Redhat release:
    > tcsh% cat /etc/redhat-release
    > EXAMPLE: Red Hat Enterprise Linux WS release 3 (Taroon Update 1)
    >
    > Note: There must be a better way than to rely on a text file?


    What can be better than a text file?

    > ----------------------------------------------------------------------------
    > 2. To determine just the number of processors:
    > tcsh% cat /proc/cpuinfo | grep "processor" | wc -l
    > EXAMPLE: 4


    Unnecessary use of cat and wc.

    grep -c "processor" /proc/cpuinfo

    > To determine the number & type of processors:
    > tcsh% cat /proc/cpuinfo | egrep "processor|vendor_id|model name|cpu MHz"
    > EXAMPLE: processor : 0
    > vendor_id : GenuineIntel
    > model name : Intel(R) Xeon(TM) CPU 3.06GHz
    > cpu MHz : 3056.620
    > processor : 1
    > vendor_id : GenuineIntel
    > model name : Intel(R) Xeon(TM) CPU 3.06GHz
    > cpu MHz : 3056.620
    > processor : 2
    > vendor_id : GenuineIntel
    > model name : Intel(R) Xeon(TM) CPU 3.06GHz
    > cpu MHz : 3056.620
    > processor : 3
    > vendor_id : GenuineIntel
    > model name : Intel(R) Xeon(TM) CPU 3.06GHz
    > cpu MHz : 3056.620


    To produce one line per cpu:

    awk -F: '/^processor/ { ++pr }
    /^vendor_id/ { vid[pr] = $2 }
    /^model/ { model[pr] = $2 }
    /^cpu/ { mhz[pr]=$2 }
    END { for ( cpu in vid ) print vid[cpu], model[cpu], mhz[cpu] }' /proc/cpuinfo

    > ----------------------------------------------------------------------------
    > 3. To determine installed RAM in megabytes:
    > tcsh% free -m |grep "Mem"|awk -F: '{print $2}' |awk '{print $1" MB"}'
    > EXAMPLE: 8 MB
    > ----------------------------------------------------------------------------
    > 4. To determine swap (in megabytes):
    > tcsh% free -m |grep "Swap"|awk -F: '{print $2}'|awk '{print $1" MB"}'
    > EXAMPLE: 24,568 MB


    Where did the comma come from? (A shell function for adding commas
    is at the end of the post).

    No need for grep or awk, and only one call to free:

    free -m | {
    while read a b c
    do
    case $a in
    Mem: ) mem=$b ;;
    Swap: ) swap=$b ;;
    esac
    done
    [ $mem -gt $swap ] && w=${#mem} || w=${#swap}
    printf "Memory: %${w}d MB\n" ${mem}
    printf " Swap: %${w}d MB\n" ${swap}
    }

    > ----------------------------------------------------------------------------
    > 5. To determine the X Server (only works from the console):
    > tcsh% /usr/X11R6/bin/XFree86 -version|grep Version |awk -F/ '{print $1}'`
    > EXAMPLE: ?


    On my system (Mandrake 9.0, executed in an xterm window), the
    information is sent to stderr, so you will have to redirect that
    (no need for grep or awk):

    xv=`/usr/X11R6/bin/XFree86 -version 2>&1`
    echo ${xv%%/*}

    > ----------------------------------------------------------------------------
    > 6. To determine the platform type:
    > tcsh% uname -m
    > EXAMPLE: i686
    > ----------------------------------------------------------------------------
    > 7. To determine the most important colormap information:
    > tcsh% xdpyinfo | sed -n -e '/TrueColor/p' -e '/24 planes/p'\
    > | sort -u | grep -v "window:"


    What if it's not 24 planes?

    > tcsh% xdpyinfo | sed -n -e '/PseudoColor/p' -e '/8 planes/p'\
    > | sort -u | grep -v "window:"


    What if it's not 8 planes?

    >
    > EXAMPLE: class: TrueColor
    > depth: 24 planes
    >
    > class: PseudoColor
    > depth: 8 planes


    What if you have more than one screen open?

    The output of xdpyinfo is not designed very well for extracting
    the data. This might be better:

    xdpyinfo | awk '/class:/ || /depth:/ {if ( ! x[$0]++ ) print}'

    But it's not perfect, and I'd have to understand the output of
    xdpyinfo better before going any further.


    > ----------------------------------------------------------------------------
    > 8. To determine the hostname & IP address:
    > tcsh% hostname -v -i
    > EXAMPLE: foobar.Domain.COM foobar 111.122.100.101


    echo $HOSTNAME `hostname -i`

    > ----------------------------------------------------------------------------
    > 9. To determine the hostid:
    > tcsh% hostid
    > EXAMPLE: 8c9ec81a
    > ----------------------------------------------------------------------------
    > 10. What else can & should a new Linux user run to determine key information?
    > ----------------------------------------------------------------------------


    Other possibly useful commands:

    uptime
    w
    who


    commas () ## USAGE: commas NNNNN[.NNN]
    {
    _COMMAS=;
    local left num decimal;
    case $1 in
    *.*)
    num=${1%.*};
    decimal=${1#.}
    ;;
    *)
    num=$1;
    decimal=
    ;;
    esac;
    while :
    do
    case $num in
    "") break ;;
    ??? | ?? | ?)
    _COMMAS=${num}${_COMMAS:+,$_COMMAS};
    break
    ;;
    *)
    left=${num%???};
    _COMMAS=${num#${left}}${_COMMAS:+,$_COMMAS};
    num=$left
    ;;
    esac;
    done;
    _COMMAS=${_COMMAS}${decimal:+.$decimal};
    [ ${SILENT_FUNCS:-0} -eq 1 ] || echo "$_COMMAS"
    }

    --
    Chris F.A. Johnson http://cfaj.freeshell.org/shell
    ================================================== =================
    My code (if any) in this post is copyright 2004, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License

  2. Re: 20 basic Linux newbie commands to identify the system

    In comp.os.linux.advocacy Chris F.A. Johnson wrote:
    > Other possibly useful commands:


    > uptime
    > w
    > who


    hardware identification
    lspci
    hard disk/removable media identification
    cat /proc/ide/hd*/model
    cat /proc/scsi/scsi

    and for usb devices...
    lsusb

  3. Re: 20 basic Linux newbie commands to identify the system


    wrote in message news:j43h4c.psa.ln@freenet.co.uk...
    > In comp.os.linux.advocacy Chris F.A. Johnson

    wrote:
    > > Other possibly useful commands:

    >
    > > uptime
    > > w
    > > who

    >
    > hardware identification
    > lspci
    > hard disk/removable media identification
    > cat /proc/ide/hd*/model
    > cat /proc/scsi/scsi
    >
    > and for usb devices...
    > lsusb


    info: for that GNU documentation which does not use man pages but uses
    texinfo pages instead.

    rpm, apt, or whatever the package manager is for your most commonly used
    Linux. After the Sun "pkg" whackiness, they should dance for joy when
    dealing with it.

    tar: The GNU version of tar has a lot of options not available on the old
    Sun tar versions.

    gzip: Sun was still insisting on using compress and uncompress at last
    check, but gzip is much faster and mor commonly used.

    mtools: The entire constellation of lovely, lovely little tools for very
    easily building DOS floppies for their Windows friends.



  4. Re: 20 basic Linux newbie commands to identify the system

    spike1@freenet.co.uk writes:


    >hardware identification
    >lspci
    >hard disk/removable media identification
    >cat /proc/ide/hd*/model
    >cat /proc/scsi/scsi


    Partition Information:
    fdisk -l

    Show USB things:
    lsusb

    Greetings, Holger

+ Reply to Thread