Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

System information command. 7

Status
Not open for further replies.

logicacmg000

Technical User
Sep 30, 2004
75
0
0
US
I wanted to know what is the command to run which would display the system information, like CPU, memory, total disk space, etc.

Thanks.
 
df" = disk free space

"w" shows uptime

"free" shows RAM and pagefile usage

"uname -a" shows CPU and some distribution data

"cat /proc/cpuinfo" shows CPU(s) detail

"top" shows running processes, utilization, RAM use and is sortable.

D.E.R. Management - IT Project Management Consulting
 
How do I find out total disk space on this Linux machine?
Do I have to add the result of 'df'?

How about number of processor?
cat /proc/cpuinfo, show me processor 0, processor 1, processor 2 and processor 3. This means I have 4 processors on the machine I am assuming? Is that correct?

I also found another helpful command courtesy of google.
cat /proc/meminfo

Thanks.
 
>>>> How do I find out total disk space on this Linux
machine?

df -k /

As for your 4 processors - depending on the kernel - but i suspect you have two actual CPU's, but they are hyperthreaded.

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
df -k / will only show you the amount blocks on the "filesystem" that is mounted on /. *nix's deal in filesystem space not physical disks.

I am not good with awk syntax but something that would do the following:

take the output of df -Pkl and skip the the first line and then output the total of the forth field (total available) and the total of the second field (total filesystem space)

the -l would be optional to show only local filesystems
and note that this could include ramdisks and any mounted r/o media.
 
I may well be thinking Solaris here, but df -whatever wouldn't show any available, but unused, disks or unmounted filesystems would it? Again in Solaris, format would be the way to see available disks as opposed to those being used.
 
>>> df -k / will only show you the amount blocks on the "filesystem" that is mounted on /

I'm failing to see how that would not show you how much of your physical drive is in use (not networked or remotely mounted drivers) ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Well, what I am trying to get it is to order another machine exactly the same. I am Windows guy.

I need to know the exact Physical hard disk Capacity.

The output from df -Pkl is printed out below. If I add all the 1024-blocks would that give me the total disk capacity?

1024-blocks Used Available
600832 149504 420808
600832 149504 420808
147778 9173 130975
1541680 342488 1120880
1027564 0 1027564
1541680 253724 1209644
62413156 662992 58579740


Thanks.
 
sedj
df -k / will only show you the root filesystem, which in many cases is not the entire disk (and shouldn't be). There will also be swap space as well as your user or data partitions (which should be separate so that if they fill up you don't potentially crash the system).

logicacmg000
adding the 1024-blocks of the same physical device will give you the capacity of the "mounted" filesystems and in most cases is a pretty good guesstimite of disk size.

ie devices that start /dev/hda are the first physical ide device, /dev/hdb is the second. /dev/hda1 is the first partition and /dev/hda2 is the second
scsi and raid devices will look different
(example HP proliant with a scsi raid controller, /dev/cciss/c0d0p2 is the second partition of the first logical disk on the first raid controller)

you may need to look at /etc/fstab to see all the partitions and their sizes

actually a good listing would be:
fdisk -l | grep "^Disk"
 
stanhubble :

I agree that, yes, technically swap, and user space, is going to be not revealed by "df -k /".

However, most user-friendly distros do not partition space for each user off a different partition. If the OP us running a server config where that IS the case, then I admit, my suggestion is certainly not going to be the case - but seeing as the OP is actually asking how to find disk usuage, then I've been guessing that they have not partitioned off space for each user :)

For example, here is my Kubuntu info :

Code:
$ df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda1             36969672   9581744  25509932  28% /
tmpfs                   258244         0    258244   0% /dev/shm
tmpfs                   258244     12588    245656   5% /lib/modules/2.6.12-9-386/volatile
$

And here is my Suse 9 box :

Code:
linux:~ # df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda2             19237244  13087456   6149788  69% /
tmpfs                   127908         0    127908   0% /dev/shm
linux:~ #

And I'm pretty sure my FC4 box at work is the same ...

As you can see, given that todays hard disks are counted in Gb's, and swap is in the Mb range (usually), an overall view of disk usuage could easily, though perhaps not technically be obtained by using "df - k /" .


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Technically I believe if you do
"cat /proc/partitions"
and examine every "minor" value of "0" you would conclude that there are "devices" with that much storage.

Problem is that RAID drives/devices fall into that report with aggregated information, which is misleading when trying to inspect RAID for component drives.

So.....

Use the above tip for drives where you know there are no RAID'd drives or if you know the physical components composing the array and the RAID type.

Beyond that I think you'd need to use the RAID tools themselves to reveal information about the RAID. If you're working remotely from the box and it uses a hardware RAID card, you're going to need some vendor-specific software to query the RAID card to reveal its secrets.



D.E.R. Management - IT Project Management Consulting
 
While it may not be the most "correct" way, can't you use something like

Code:
computer ~ # df -lh | grep ^/dev/[hs]d[a-z][1-99]

to list local drives? That should grab only IDE/SATA and SCSI devices and output them.
 
Hmm, it seems I misunderstood... you are trying to get the physical disk size? I used dmesg for this in the past, as usually the kernel reports it. This is what I used (although I haven't tested it on other distros, but it should work):

Code:
computer ~ # dmesg | grep "^[sh]d[a-z]: [0-9]"
hda: 20044080 sectors (10262 MB) w/418KiB Cache, CHS=19885/16/63, UDMA(33)
hdb: 20044080 sectors (10262 MB) w/418KiB Cache, CHS=19885/16/63, UDMA(33)

In this case there are two 10GB drives installed in this machine.
 
Sedj:

Not wanting to be picky, but also not wanting misleading information left on the forum. df -k / will only work when the filesystems are 'badly' set up (lets not start a flame war on filesystem layouts). The standard way to partition a filesystem is to have seperate partitions for /, /usr, /boot, /var, or any combination of these. A lot of distro's these days don't bother for ease of use on desktop systems. However, if the machine is a server that has been installed by a competent admin, then the filesystems should be seperate. In this case df -k / will only produce the filesystem size for the / partition.

As for the correct answer, I'd prefer to go with the dmesg solution above, seeing as this is what the kernel reads from the drive itself.

Darren.
 

Ok, the only proper way to check a disk size is

emil:~# cat /proc/ide/hdc/capacity
320173056

which displays number of 512 byte blocks.
 
I tend to use df -H|sed -e '1d' but thats just me :)

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Might be a silly idea, but if your are trying to duplicate the hardware, why use software to find out what you have? Why not open a case and look?



BocaBurger
<===========================||////////////////|0
The pen is mightier than the sword, but the sword hurts more!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top