Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What does Linux know about your hardware?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming
View previous topic :: View next topic  
Author Message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Jul 24, 2008 3:02 am    Post subject: What does Linux know about your hardware? Reply with quote

On a regular basis (new) members ask help to 'troubleshoot' their system. In most cases it's pretty simple, but sometimes we'd need to know more about your system. I've created a little script you can use to do the 'dirty' work for you. Note that it currently only works on Debian based systems (next to Debian itself also any Ubuntu variant, Xandros and Knoppix) with the lshw package installed. Contributions to make the script distro-independent and a check of wether the required package(s) is/are installed are welcome Smile

Code:
#! /bin/bash
#
# script to collect hardware and software data on your system
# you'll need to be root to get proper results
# currently only works in Debian based systems, with the lshw package installed

# what kernel are you running?
echo uname -a: `uname -a` > mysystem.txt
echo ========= >> mysystem.txt
# find out all you want from your hardware with lshw
lshw >> mysystem.txt
echo ========= >> mysystem.txt
chmod 755 mysystem.txt
echo "done! read the file mysystem.txt in the current directory"
echo "use the cat and grep commands to select sections of interest if you're on the commandline"

exit 0
Save the above text in a text file named "mysystem.sh" or click the link Wink
Make it executable with
Code:
chmod+x mysystem.sh
and run it with
Code:
./mysystem.sh
The resulting text file "mysystem.txt" tells you all Linux knows about your hardware.

That simple? Yes, even 1sf (troll) could use it (although as Mandriva user he won't be able to run it, for now Wink)

Anyway, this text file can be used to copy the relevant parts from in your reply (or even the original question!)

Frankly, I hope you won't need it, but if you do, let me know if it worked for you (it works on my system (pun intended Razz))
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8450
Location: Warrington, UK

PostPosted: Thu Jul 24, 2008 9:25 am    Post subject: RE: What does Linux know about your hardware? Reply with quote

Change

Code:
echo uname -a: `uname -a` > mysystem.txt

to
Code:
echo uname -a: $(uname -a) >|mysystem.txt


or it will fail if someone has the noclobber option set in their shell, or even

Code:
echo "uname -a:" >|mysystem.txt
uname -a >>mysystem.txt


which saves spawning another shell process.

Note that some distros install lshw into /usr/sbin, which may cause problems if you try to make the script distro-agnostic. Anyway, you should check that it is installed before trying to run it.

Code:

if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!
fi


Why do you make the output file executable?
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Thu Jul 24, 2008 12:02 pm    Post subject: RE: What does Linux know about your hardware? Reply with quote

After installing lshw (and dependencies) the script works fine on my Asus Eee PC running the default Xandros (updated) and my self built Intel Q6600 running Ubuntu 8.04.1. The output to text is well presented and easy to search through.

Great work DM, this should be included on the LXF DVD! Very Happy Exclamation Idea
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Jul 24, 2008 1:02 pm    Post subject: RE: What does Linux know about your hardware? Reply with quote

Nelz, thanks for the suggestions, I've incorporated them in the script. The reason I've put in the chmod line is because the file is created by root and may not be readable as normal user. Changed the permissions to 644, 'cause that does the trick as well Smile

Ollie, glad you liked it. Not sure it's mature enough to be on the LXF dvd's though Wink
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Thu Jul 24, 2008 1:48 pm    Post subject: RE: What does Linux know about your hardware? Reply with quote

I'm sure it is!

I'd add:
Code:
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt


at the start of the script just so you can check if the script was run before or after changes have been made.
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Thu Jul 24, 2008 2:35 pm    Post subject: Reply with quote

erm, nelz

i think your missing an "

Quote:

if which lshw &>/dev/null; then
lshw >> mysystem.txt
else
echo "You need to install lshw to use this script!
fi

should be
Code:

if which lshw &>/dev/null; then
   lshw >> mysystem.txt
else
   echo "You need to install lshw to use this script!"
fi



I spent ages trying to get the script to work after i added your code!

Good idea though


Last edited by bobthebob1234 on Thu Jul 24, 2008 2:44 pm; edited 1 time in total
Back to top
View user's profile Send private message
bobthebob1234
LXF regular


Joined: Thu Jan 03, 2008 9:38 pm
Posts: 1369
Location: A hole in a field

PostPosted: Thu Jul 24, 2008 2:42 pm    Post subject: Reply with quote

Quote:

'd add:
Code:
echo ========= >> mysystem.txt
echo "System info at:" `date` >> mysystem.txt
echo ========= >> mysystem.txt


at the start of the script just so you can check if the script was run before or after changes have been made.


Prehaps having the file as

mysystem date +%D .txt

might be better?


(PS, i don't know the exact syntax... Rolling Eyes )
Back to top
View user's profile Send private message
pwbrum61
LXF regular


Joined: Fri Sep 29, 2006 10:02 am
Posts: 308
Location: Worcestershire

PostPosted: Thu Jul 24, 2008 3:07 pm    Post subject: Reply with quote

For those of you who might dabble with Solaris, similar information to that from lshw can be obtained with

prtconf -v

Smile
_________________
Where's the Kaboom? There's supposed to be an Earth-shattering kaboom! Very Happy

.
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Fri Jul 25, 2008 12:00 am    Post subject: Reply with quote

That's a very reasonable addition Ollie, you're in Smile Had to change some bits though Wink Bob, thx for getting the typo, fixed it. Solaris, however tempting and interesting, is a step too far for now pwbrum61, first get some distro-independence on Linux Wink But I'll keep it warm for later use! Smile
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Fri Jul 25, 2008 12:25 am    Post subject: Reply with quote

Thanks Very Happy
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Tue Jul 29, 2008 11:39 pm    Post subject: Reply with quote

Quick note to let you know that:
1) althought the script quoted above does work, it's version 0.001 and the link offers version 0.003 for 'download'. That is, the link always has the latest version available.
2) I'm downloading Fedora 9 ATM and will install it in a VirtualBox environment when done. Basic extention for rpm based distro's is therefor in progress. (but not yet available!) Don't hold your breath for it! Wink
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Sep 18, 2008 1:07 am    Post subject: Reply with quote

Update 2:

Getting Fedora to work on a virtual machine turns out to be a PITA. Slow, slugish, not responsive at all. I instantly knew again why I chose Debian in the first place Razz Tried OpenSuse too, same results Sad Any rpm based distro you guys would recommend that runs acceptable on a virtual machine?
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Thu Sep 18, 2008 3:10 am    Post subject: Reply with quote

With current distros you will have problems if they are configured by default to use Compiz, which requires 3D acceleration, which means that openSUSE with KDE4 would definitely have issues. You may also have to give the virtual machine more RAM if it is running very slowly. That's the big advantage of having a 64-bit OS as the base OS, you can install and use plenty of RAM Very Happy
Back to top
View user's profile Send private message
Dutch_Master
LXF regular


Joined: Tue Mar 27, 2007 2:49 am
Posts: 2430

PostPosted: Thu Sep 18, 2008 3:21 am    Post subject: Reply with quote

Thanks for the warning Ollie, but as Gnomy I wouldn't choose KDE anyway Wink

The host has 2 GB RAM onboard, and 512 MB for a guest, and runs 64 bit Debian. Should suffice, shouldn't it? Frankly, any (modern) Linux distro that needs more then 512 MB RAM would be just as bad as M$ Vi$ta Evil or Very Mad

Hmmm, would CentOS do, RH-based as it is? I'll see if I can get some .iso tomorrow Wink
Back to top
View user's profile Send private message
ollie
Moderator


Joined: Mon Jul 25, 2005 12:26 pm
Posts: 2749
Location: Bathurst NSW Australia

PostPosted: Thu Sep 18, 2008 7:25 am    Post subject: Reply with quote

Dutch_Master wrote:
Thanks for the warning Ollie, but as Gnomy I wouldn't choose KDE anyway Wink

The host has 2 GB RAM onboard, and 512 MB for a guest, and runs 64 bit Debian. Should suffice, shouldn't it? Frankly, any (modern) Linux distro that needs more then 512 MB RAM would be just as bad as M$ Vi$ta Evil or Very Mad

Hmmm, would CentOS do, RH-based as it is? I'll see if I can get some .iso tomorrow Wink


Laughing Gnomey still has Compiz.

I think CentOS would be closer to RHEL than Fedora.

I'm flat out with Software Freedom Day at the moment, but I'll see if I can do some testing on different distros after I have a week off.

Cool No computers, no mobile phone reception - just fishing, sailing and pulling kids around behind my speedboat at Windamere Dam. Very Happy
Back to top
View user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Programming All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast