LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-12-2012, 05:37 AM   #1
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Rep: Reputation: 12
How to find size of an rpm


Hello everyone,
I want to know the size of an rpm file in redhat.
I have used the following commands and getting confusing results.
kindly tell me,
I used

1.rpm -qip xyz.rpm
this command shows size field with some value.
2.du -sb xyz.rpm
This showing some thing different.
3.ls -l
this showing as the du command result for the corresponding rpm file.
but why the rpm command showing something different.
what is actually the size

kindly tell me it is required for my project.
Thanks
 
Old 04-12-2012, 05:45 AM   #2
linuxlover.chaitanya
Senior Member
 
Registered: Apr 2008
Location: Gurgaon, India
Distribution: Cent OS 6/7
Posts: 4,631

Rep: Reputation: Disabled
I do not get what size are you looking at. rpm is a package installer. When rpm file is installed, it may installed and configure package in various location instead of one. For example it may have its configuration files in /etc and binary files in /usr/bin. If you are looking for the file size of rpm itself, then you may use du -sh <file.rpm>
 
Old 04-12-2012, 06:27 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,804

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
what do you want to know? the size of the package itself (that is the size of the *.rpm file) - du or ls will tell you,
or you need the size of the installed package (how much space is occupied by the package). You can see the man page of rpm about the meaning of -qip.
 
Old 04-12-2012, 06:42 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
To retrieve the size in bytes of the installed package:
Code:
rpm --queryformat='%12{SIZE}  %{NAME}\n' -q package-name
To retrieve the size in bytes of a downloaded (not installed) package (this is the disk space the package will require once installed):
Code:
rpm --queryformat='%12{SIZE}  %{NAME}\n' -qp package-name.rpm
To retrieve (roughly) the size in bytes of the installed OS:
Code:
rpm --queryformat='%12{SIZE}  %{NAME}\n' -qa | awk '{size += $1} END{print size}'
Hope this helps.

Last edited by colucix; 04-12-2012 at 06:51 AM. Reason: Added info
 
Old 04-12-2012, 07:03 AM   #5
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
Thanks ,
Every one for the quick response
I have not installed any rpm,
Actually I am having one rpm file not installed only copied from pen drive to system.
I want to retrive the size using one shell scripting so i need the command ,there are many possible command .
I want to use the rpm command ,but it not giving the size properly,It showing in bytes but this is not correct.

"rpm -qip xyz.rpm | grep Size"

I came to know that it is giving the size from the header of the rpm file.where tags are there to give information about the rpm and from the size tag it is giving the result.
so my doubt is why the size is not matching with other command results.What is actually the concept behind this.
Thanks

Last edited by pradiptart; 04-12-2012 at 07:09 AM.
 
Old 04-12-2012, 10:12 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
It works for me. The suggested commands give the same result as reported by the Size field in the summary. Maybe a mistake in the RPM header? Which package gives the wrong result? Where did you downloaded it from?
 
Old 04-12-2012, 11:32 AM   #7
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
'ls -l' and 'du -sb' will show the package size = compressed size.


'rpm -qip' will get the information about "installed size",
i.e. the size of the uncompressed files in the package.

.
 
1 members found this post helpful.
Old 04-12-2012, 11:42 AM   #8
TedHornsby84
Member
 
Registered: Mar 2010
Location: Dallas, TX
Posts: 40

Rep: Reputation: 2
Just wanted to add that adding '-h' to the 'ls -l' command, as in

Code:
ls -lh
The file sizes will be given in a human-readable format instead of in bytes. I've found it's much easier to read something like "34.6M" instead of "34602128"
 
Old 04-16-2012, 02:24 AM   #9
pradiptart
Member
 
Registered: Sep 2007
Posts: 102

Original Poster
Rep: Reputation: 12
Thanks all,for your valuable reply

knudfl - Thanks for your reply,It is helpful for me.but can u say how to check it is correct or not,
I have uncompresed using the following command but not able to find out the exact size.

rpm2cpio xyz.rpm | cpio -ivd

I have used this command and uncompressed the rpm file,and then use the ls command to see the size but it also not giving the size mentioned in the Size attribute of rpm file.so can u say how check it the size after uncommpress the rpm file.
Thanks
 
Old 04-16-2012, 04:56 AM   #10
Satyaveer Arya
Senior Member
 
Registered: May 2010
Location: Palm Island
Distribution: RHEL, CentOS, Debian, Oracle Solaris 10
Posts: 1,420

Rep: Reputation: 305Reputation: 305Reputation: 305Reputation: 305
Quote:
I have used this command and uncompressed the rpm file,and then use the ls command to see the size but it also not giving the size mentioned in the Size attribute of rpm file.so can u say how check it the size after uncommpress the rpm file.
You mean to say you want to check the size of each and every file of that uncompressed rpm, right? If it is so, then execute
du -sh * command, will give you size of each and every file of uncompressed rpm.
 
Old 04-16-2012, 05:54 AM   #11
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
man du : http://www.manpagez.com/man/1/du/


cd <folder-with-uncompressed-files>/ && du -k
... Displays block counts in 1024-byte (1-Kbyte) blocks.

Or : Highlight / 'Select all' in your File Manager : kB will be shown.

Or : tar -cf files.tar <folder-with-uncompressed-files>/
→ The size of the tar package is the total of all the files.

.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php module size, build vs rpm sopiaz57 Linux - Server 3 10-09-2011 08:24 AM
How to find the size of RPM in CentOS? your_shadow03 Linux - Newbie 1 01-08-2010 06:25 AM
find the file size jadeddog Programming 6 07-07-2008 07:01 PM
how does pixel aspect relate to frame size in mplayer/how do you find vid frame size? BrianK Linux - General 3 10-31-2007 01:08 PM
rpm query size? lf412 Linux - Newbie 3 03-04-2003 12:52 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration