Hey guys, I'm fairly new to using linux however I need to know a few things. (I'm very aware there are examples on the web for most of these, but I want to know how you guys personally prefer to go about these)

1) Find hard drive serial (SCSI) without the use of sdparm
2) Find Ip Address of the current machine
3) Find the machine name of the current machine
4) Find the operating system of the current machine


My findings for this are:
1) (unsure)
2) ifconfig | grep "inet addr"
3) hostname
4) uname -a


Do you guys have better ways of finding these things? Also are my findings correct?

Dani AI

Generated

Brief, practical alternatives and notes that fill the gaps in the thread (referring to 's original questions and 's suggestions about hdparm/scsi_id).

For SCSI/SAS/RAID disks (serial/ID)

  • Prefer device-info tools that read sysfs/udev or SCSI VPD pages instead of sdparm. Examples:
    lsblk -d -o NAME,SERIAL,MODEL
    udevadm info --query=property --name=/dev/sdX
    sudo sg_inq --page=0x80 /dev/sgN
    sudo smartctl -i /dev/sdX
    ls -l /dev/disk/by-id
  • Notes: lsblk and udevadm show udev-provided ID_SERIAL/WWN; sg_inq reads SCSI VPD (unit serial) when present; smartctl prints the drive's SMART/serial info. Hardware RAID or controller presentation can hide physical serials — in that case use the RAID vendor tool (megacli/storcli, etc.) or map by-path/by-id entries. (linux.org)

For IP address and outbound address selection

  • Use modern iproute2 commands rather than parsing old ifconfig output:
    ip -4 addr show     # list IPv4 addresses
    ip route get 8.8.8.8    # shows which source address the kernel would use to reach the Internet
  • ip is the recommended tool for scripted and reliable address/routing queries. (manpages.debian.org)

For the machine name (more clarity than the plain hostname utility)

  • On systemd systems prefer hostnamectl status to see static/transient/pretty hostnames and related info; older or non-systemd systems still use the kernel//etc/hostname values. (manpages.ubuntu.com)

For the OS/distribution identity

  • Read the vendor-supplied file or use the LSB helper:
    cat /etc/os-release
    lsb_release -a
  • /etc/os-release is the distro-provided canonical place for name/version fields; lsb_release is a portable helper when available. (linux.org)

Troubleshooting tips (bridging what was tried in the thread)

  • If a serial is missing, check whether the controller exposes WWN/ID instead of a vendor serial and try /dev/disk/by-path or controller management utilities.
  • For scripts prefer explicit lsblk --output=... columns or udevadm --query=property parsing rather than grepping tool defaults (stable output is easier to script).

Recommended Answers

All 4 Replies

Alternativs:
3) uname -n
4) uname -s

grep is a command that returns a string with the desired text.
In my case the command ifconfig | grep "inet addr" gives me the same result as ifconfig | grep "inet" but ifconfig | grep "addr" gives an other result.

As long as you are not logged in as root or uses the sudo command you can play around and look at what you get for result.

Look in man pages to learn more.

for example ifconfig man
gives you information about ifconfig

and man man
gives you information about man pages

Quite from man pages with the Q key.

Use -help to show you more.
for example ifconfig -help
shows you available parameters like -a, -v, -s and what they stand for

Good luck :D

Thanks bud I'll check out the man pages, anyone know anything about question #1?

I am not sure this will work with SCSI but you could try.
It is a big i not a small L after hdparm -
sudo hdparm -I /dev/sda

( -I gives you detailed/current information directly from drive)

You can also search for scsi_id commands but they do not work on my computer so I can not help you with them.

I am not sure this will work with SCSI but you could try.
It is a big i not a small L after hdparm -
sudo hdparm -I /dev/sda

( -I gives you detailed/current information directly from drive)

You can also search for scsi_id commands but they do not work on my computer so I can not help you with them.

Yeah I had tried hdparm at the time that I had tried sdparm as well. Also scsi_id didn't work either. I had tried all three and was searching for alternatives, but after numerous pages through google I couldn't find much about it.

Thanks for your help sneaker, for now I think I'll have to find a way of installing sdparm.

I'll mark this solved for the time being

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.