LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to get install location of all packages on Linux? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-install-location-of-all-packages-on-linux-4175523874/)

vipinsqa 10-31-2014 03:57 AM

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.

vipinsqa 10-31-2014 12:31 PM

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

schneidz 10-31-2014 12:45 PM

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


Doug G 10-31-2014 12:54 PM

If you are looking for the location of all files installed by a package, you can use repoquery -l

vipinsqa 10-31-2014 01:04 PM

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.

Habitual 10-31-2014 01:49 PM

n/m.

rmp -ql <package> did work here.

John VV 10-31-2014 03:52 PM

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

vipinsqa 11-01-2014 12:55 AM

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.

John VV 11-01-2014 01:06 AM

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

vipinsqa 11-01-2014 01:11 AM

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.

tstaerk 11-01-2014 06:42 AM

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?

vipinsqa 11-01-2014 07:27 AM

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.


All times are GMT -5. The time now is 07:47 AM.