LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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-31-2014, 04:57 AM   #1
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Rep: Reputation: Disabled
How to get install location of all packages on Linux?


Hey Guys,

I am using rpm in redhat linux to get a list of all installed packages. Dumping the output to a file. I also need to get their respective install locations in the same file. However, I understand that to get the install location, I need to use the command rpm -ql "package name".

Can anyone please confirm how can I get this done via a shell script? Some sort of loop needs to be done on the file listing from rpm -qa?

My code snippet to get all package list is:-
rpm -qa -last > $HOME/MyLog/installed_packages_$HOSTNAME.log

Please help.

Regards.
 
Old 10-31-2014, 01:31 PM   #2
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hi,

I tried below but I don't know why the foreach loop is failing. I am trying to write all packages installed to a log and display them one by one. Once this works, I will use rpm -ql $filename to get all installed package locations.

rpm -qa -last > $HOME/MyLog/installed_packages_$HOSTNAME.log
foreach filename ('cat $HOME/MyLog/installed_packages_$HOSTNAME.log')
echo $filename


When I run this, I get below error:-
./packages_installed.sh: line 12: syntax error near unexpected token `('
./packages_installed.sh: line 12: `foreach filename ('cat $HOME/MyLog/installed_packages_$HOSTNAME.log')'

Can anyone please confirm what is the issue here? Is something wrong with the foreach loop? How can I get this working?

Regards,
Vipin Batra
 
Old 10-31-2014, 01:45 PM   #3
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fc-15/ fc-20-live-usb/ aix
Posts: 5,027

Rep: Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845Reputation: 845
i think this is what you are trying to do:
Code:
rpm -qa -last > $HOME/MyLog/installed_packages_$HOSTNAME.log
for filename in $(cat $HOME/MyLog/installed_packages_$HOSTNAME.log)
do
 echo $filename
done
 
Old 10-31-2014, 01:54 PM   #4
Doug G
Member
 
Registered: Jul 2013
Posts: 596

Rep: Reputation: Disabled
If you are looking for the location of all files installed by a package, you can use repoquery -l
 
1 members found this post helpful.
Old 10-31-2014, 02:04 PM   #5
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hi Guys,

Thank you very much for the revert. I have below code snippet now:-

rpm -qa -last > $HOME/MyLog/installed_packages_$HOSTNAME.log
for filename in $(cat $HOME/MyLog/installed_packages_$HOSTNAME.log | awk '{print $1}')
do
rpm -ql $filename > $HOME/MyLog/installed_package_location_$HOSTNAME.log
done

This somehow hangs the terminal. Probably I believe the package install location find command puts a delay at the end - Not sure why.
Is there any better way to solve this problem? I basically want to get a file ready with all installed packages on linux and their install location (preferably in same file).

Kindly advice.

And repoquery doesnt work in my box

Regards.
 
Old 10-31-2014, 02:49 PM   #6
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,168
Blog Entries: 10

Rep: Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979Reputation: 1979
n/m.

rmp -ql <package> did work here.

Last edited by Habitual; 10-31-2014 at 02:51 PM.
 
Old 10-31-2014, 04:52 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
on redhat there is also the YUM command
Code:
yum list installed
Quote:
get their respective install locations
on redhat rpms are all ( almost all ) installed to " /usr "
exceptions are open/libre office
/usr/opt
kde3
/usr/opt

and any rpms built by non redhat people that put them in /usr/local
redhat normally dose not use the "local" folder debian dose
 
Old 11-01-2014, 01:55 AM   #8
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks very much for the revert. I tried command "yum list installed". I get the list of packages but I dont see the package install location.
Is there something which I can use to play around with yum and get the location of installed packages as well.

Kindly confirm. I just need a output file with list of all packages installed on linux box along with their install location.

Regards.
 
Old 11-01-2014, 02:06 AM   #9
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 16,822

Rep: Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408Reputation: 2408
the install location is
/use/bin/"ProgramName"
/usr/share/"ProgramName"
/usr/lib64/
/usr/include


or
do you want a full list of everything in the rpm & rpm-devel and the full path
 
Old 11-01-2014, 02:11 AM   #10
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hi,

You are right.. I need a output file which would have all packages installed in linux + their complete installation path. I need to provide this report.
I tried script in my post above but thats quite not an efficient way. I want something which is more clear - as in which prints all installed packages and corresponding complete install location side by side.

Also, for list of running services on a linux box, is there a way to find the install location as well? I am using below command for list of services.
service --status-all

Thank you very much for prompt response.

Regards.
 
Old 11-01-2014, 07:42 AM   #11
tstaerk
LQ Newbie
 
Registered: Nov 2014
Posts: 3

Rep: Reputation: Disabled
List all packages and list all file locations inside them with the command

rpm -ql $(rpm -qa) >file.txt

Is this what you want? What do you want? Save all files that belong to all packages?
 
1 members found this post helpful.
Old 11-01-2014, 08:27 AM   #12
vipinsqa
Member
 
Registered: Oct 2014
Posts: 40

Original Poster
Rep: Reputation: Disabled
Hi,

Thanks for the revert. What I want is:- A output file which lists all installed packages in linux along with their install locations.
So, this will basically be a report of all installed packages on linux and the location where they are installed.

Regards.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
LXer: Google I/O Android News: Location, Location, Location (Plus Cloud Messaging and Bluetooth) LXer Syndicated Linux News 0 06-05-2013 02:00 PM
Change install location of packages set up by YUM - RHEL 6.4 - How to do? EnderX Linux - Software 1 04-29-2013 10:10 PM
location of downloaded packages avee137 Linux - Newbie 2 10-07-2010 10:33 PM
Find location of packages previously installed with yum on fedora core 5 Tails and Link Linux - Newbie 8 04-30-2006 05:27 AM
Multi location Linux install balajipriya Linux - General 3 04-05-2004 01:59 PM


All times are GMT -5. The time now is 12:21 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration