LinuxQuestions.org
Visit Jeremy's Blog.
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 10-28-2007, 01:48 AM   #1
nmansour
Member
 
Registered: Sep 2006
Location: Chicago
Distribution: Ubuntu 8.04 - Fedora 9 on an AMD 64bit Machine
Posts: 101

Rep: Reputation: 15
listing the installed Packages


Hi,

Is there a command which I can use to list all the packages I have on my system with their sizes? "The sizes which they occupy on my HDD".

Noha

Last edited by nmansour; 10-28-2007 at 01:55 AM.
 
Old 10-28-2007, 02:07 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You can use "rpm -qa" to list all packages. To list the total size of the files in the package, I think you will need to use the --dump option to give you the block size of each file, and then use something like awk to give you the total.

Code:
rpm -q --dump kdeutils3 | awk '{size+=$2}END{print size}'
 
Old 10-28-2007, 02:18 AM   #3
nmansour
Member
 
Registered: Sep 2006
Location: Chicago
Distribution: Ubuntu 8.04 - Fedora 9 on an AMD 64bit Machine
Posts: 101

Original Poster
Rep: Reputation: 15
Thanks,

Here is the output:
Code:
[noha@hep-ex ~]$ rpm -q --dump kdeutils3 | awk '{size+=$5}END{print size}'
0
[noha@hep-ex ~]$
Did I do it right?

Noha
 
Old 10-28-2007, 02:29 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You probably don't have the kdeutils3 package installed.

This will list all of the packages and their sizes:
Code:
function packsize { rpm -q --dump $1 | awk '{size+=$2}END{print size}'; }
for package in $(rpm -qa); do 
  echo -ne "$package\t"
  packsize "$package"
done
 
Old 10-28-2007, 02:16 PM   #5
nmansour
Member
 
Registered: Sep 2006
Location: Chicago
Distribution: Ubuntu 8.04 - Fedora 9 on an AMD 64bit Machine
Posts: 101

Original Poster
Rep: Reputation: 15
It worked like a charm! Thank you

but how may I display the sizes in KB?


Also, was this a bash script (with an awk one)?


Noha
 
  


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
listing installed packages using rpm metallica1973 Linux - Software 4 08-21-2007 01:01 PM
Listing of packages installed on system kushalkoolwal Debian 12 06-22-2006 02:59 AM
Sort installed packages by # of dependant packages installed brianez21 Debian 1 01-18-2006 05:06 PM
Listing installed packages in Gentoo ? Builder Linux - Distributions 1 07-08-2004 05:09 PM
Listing my installed Kernel Modules. mudelf Linux - General 1 11-06-2003 06:58 AM

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

All times are GMT -5. The time now is 07:26 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