All installed programs linux

How do I list all installed programs?

Hm, I’m interested in Red Hat, Ubuntu, and cygwin. Is there a distribution-free way to list the programs with some command line argument?

4 Answers 4

That depends on your distribution.

  • Aptitude-based distributions (Ubuntu, Debian, etc): dpkg -l
  • RPM-based distributions (Fedora, RHEL, etc): rpm -qa
  • pkg*-based distributions (OpenBSD, FreeBSD, etc): pkg_info
  • Portage-based distributions (Gentoo, etc): equery list or eix -I
  • pacman-based distributions (Arch Linux, etc): pacman -Q
  • Cygwin: cygcheck —check-setup —dump-only *
  • Slackware: slapt-get —installed

All of these will list the packages rather than the programs however. If you truly want to list the programs, you probably want to list the executables in your $PATH , which can be done like so using bash’s compgen :

Or, if you don’t have compgen :

#!/bin/bash IFS=: read -ra dirs_in_path "; do for file in "$dir"/*; do [[ -x $file && -f $file ]] && printf '%s\n' "$" done done 

It would be better to distinguish between package managers instead of «distributions». NetBSD’s pkgsrc runs on any Linux, and some package managers can be used on multiple Uinces.

Answering the second part of the question (nothing really to be added to Chris’ answer for the first part):

There is generally no way of listing manually installed programs and their components. This is not recorded anywhere if you didn’t use a package manager. All you can do is find the binaries in standard locations (like Chris suggested) and in a similar way, guess where some libraries or some manual pages etc. came from. That is why, whenever possible, you should always install programs using your package manager.

Programs should be reachable via the PATH, so just list everything in the path:

Expect a result of about 3k-4k programs.

To exclude a probable minority of false positives, you may refine the approach:

for d in $ ; do for f in $d/* ; do test -x $f && test -f $f && echo $f done done 

It didn’t make a difference for me.

Источник

Showing all installed programs in Ubuntu

In Ubuntu, where to see all programs just like the «program files» in windows, from which I can launch a program from a list of all program installed?

3 Answers 3

Just for fun

Since OP mentioned: from which I can launch a program from a list of all program installed?

Below a small script that lists all (globally) installed GUI applications. Choose one to launch it, or type a few of its characters and press Return to run the application:

enter image description here

To use

  • Copy the script below into an empty file, save it as list_apps.py
  • Test- run it by the command (open a terminal window, type the command and press Return ):
python3 /path/to/list_apps.py 

The script

#!/usr/bin/env python3 import subprocess import os dr = "/usr/share/applications" apps = [] for f in [f for f in os.listdir(dr) if f.endswith(".desktop")]: try: content = open(dr+"/"+f).read() if not "NoDisplay=true" in content: lines = content.splitlines() name = [l for l in lines if l.startswith("Name=")][0].replace("Name=", "") command = [l for l in lines if l.startswith("Exec=")][0].replace("Exec=", "") apps.append([name, command]) except: pass apps.sort(key=lambda x: x[0]); apps = sum(apps, []) displ_list = '"'+'" "'.join(apps)+'"' try: chosen = subprocess.check_output([ "/bin/bash", "-c", 'zenity --list '+\ '--column="Applications" '+\ '--column="commands" '+\ '--hide-column=2 --height 450 '+\ '--width 300 '+\ '--print-column=2 '+displ_list ]).decode("utf-8").split("|")[-1].strip() chosen = chosen[:chosen.rfind(" ")] if "%" in chosen else chosen subprocess.Popen([ "/bin/bash", "-c", chosen ]) except subprocess.CalledProcessError: pass 

How it works

The script lists all .desktop files in /usr/share/applications , and checks if the line NoDisplay=true is in the file (which means it is not meant to be used as a GUI). Then it looks into the files, looks up the application name and the command to run it.

Читайте также:  Change user password with root in linux

The result is listed in a zenity list, to choose from. If you pick one, the corresponding command is executed.

Extended version

If you also would like to have a short description on the application, As mentioned in the Comment= line of its .desktop file, use the version below:

enter image description here

#!/usr/bin/env python3 import subprocess import os dr = "/usr/share/applications" apps = [] for f in [f for f in os.listdir(dr) if f.endswith(".desktop")]: try: content = open(dr+"/"+f).read() if not "NoDisplay=true" in content: lines = content.splitlines() name = [l for l in lines if l.startswith("Name=")][0].replace("Name=", "") command = [l for l in lines if l.startswith("Exec=")][0].replace("Exec=", "") comment = [l for l in lines if l.startswith("Comment=")] comment = comment[0].replace("Comment=", "") if comment else "No description" apps.append([name, command, comment]) except: pass apps.sort(key=lambda x: x[0]); apps = sum(apps, []) displ_list = '"'+'" "'.join(apps)+'"' try: chosen = subprocess.check_output([ "/bin/bash", "-c", 'zenity --list '+\ '--column="Applications" '+\ '--column="commands" '+\ '--column="Description" '+\ '--hide-column=2 --height 450 '+\ '--width 500 '+\ '--print-column=2 '+displ_list ]).decode("utf-8").split("|")[-1].strip() chosen = chosen[:chosen.rfind(" ")] if "%" in chosen else chosen subprocess.Popen([ "/bin/bash", "-c", chosen ]) except subprocess.CalledProcessError: pass 

Источник

How do we know what applications are installed in Linux?

I’m trying to understand the following in Linux. In windows we have the services that run or «startup». When we install an application it could be installed as a service so that it starts automatically. But if an application is not installed as a service we usually can see it in the Start -> Programs menu. So we know what applications are installed. In Linux what is the equivalent? I understand that the equivalent services are in /etc/init where the services start/stop. But I assume that if I install a package it does not necessarily create a startup script in /etc/init right? So how does one know what has been installed and is available in Linux (like we can in Windows from Start -> Programs)? Note: I’m asking about CLI mode. I guess in a desktop version one can see the relevant icons in the various menus (e.g in Kubuntu from Application -> Internet -> Firefox).

Читайте также:  Xps чем открыть astra linux

You can use the package manager to list all installed packages (that the package manager knows about). The details depend on the manager. For Debian-based systems, dpkg -l . For rpm-based systems something like rpm -ql .

You find this out through the package manager. Different distributions use different package managers. Are you using (K)Ubuntu?

5 Answers 5

Many questions. Let’s take a couple and see if we can’t clear things up.

Q1

I understand that the equivalent services are in /etc/init where the services start/stop. But I assume that if I install a package it does not necessarily create a startup script in /etc/init right?

No when you install applications on Linux distros (ones that make use of package managers such as dpkg/APT, RPM/YUM, pacman, etc.), as part of the software being installed the package manager has a scripting «feature» similar to those found in Windows that can add scripts, create scripts, add users to the system, and start services after they’re installed.

Q2

So how does one know what has been installed and is available in Linux (like we can in Windows from Start -> Programs)?

Easy. The same package managers that I mentioned above have commands you can use to query the system to find out what applications have been installed, what files are related to these packages etc. etc.

Example

On Red Hat based distros you can use the command rpm to find out information about the packages installed.

$ rpm -aq | head -5 libgssglue-0.4-2.fc19.x86_64 pygame-1.9.1-13.fc19.x86_64 perl-HTML-Parser-3.71-1.fc19.x86_64 ibus-libs-1.5.4-2.fc19.x86_64 libnl-1.1-17.fc19.x86_64 

To find out what files are part of a package:

$ rpm -ql pygame | head -5 /usr/lib64/python2.7/site-packages/pygame /usr/lib64/python2.7/site-packages/pygame-1.9.1release-py2.7.egg-info /usr/lib64/python2.7/site-packages/pygame/LGPL /usr/lib64/python2.7/site-packages/pygame/__init__.py /usr/lib64/python2.7/site-packages/pygame/__init__.pyc 

How can it show me just the executable pieces to that are included in the package (the applications)? Most of the time executables are installed in certain locations on Linux, /usr/bin or /bin are 2 such directories. I usually search the RPM packages like so for these:

$ rpm -ql pygtk2 | grep "/bin" /usr/bin/pygtk-demo $ rpm -ql httpd | grep -E "bin/|sbin/" | head -10 /usr/sbin/apachectl /usr/sbin/fcgistarter /usr/sbin/htcacheclean /usr/sbin/httpd /usr/sbin/rotatelogs /usr/sbin/suexec 

If you look in /var/log there should be a log of your package manager. For example, arch linux has a log file for pacman and all of the installed, removed, and upgraded programs are listed with a timestamp. This log is a text file.

The specific programs in unix based OSes are saved in /bin, /sbin, /usr/bin, and /usr/sbin; however, they can be saved in a variety of locations.

I do not think there is any CLI equivalent to GUI to discover programs the way they jump at you. It is more exploratory. When I get on to a new linux system, I look at the /opt directory to find what all optional packages are installed other than the standard utilities. If I am looking for a specific utility, I use apropos , locate , which and/or whereis .

Читайте также:  Portable linux на флешку

If admins have already installed certain utilities then I would expect them in my env and system path so I look into these. Additionally, I also look into system-wide aliases if any.

Some large scale systems have modules and/or softenv installed. In such cases, I look into module avail or softenv . On systems with package managers like apt or yum, you can use them to list installed packages: yum list installed and with rpm : rpm -q myfavtool .

/opt is quite specific; different systems have different conventions. Other places to explore are /usr/local and /srv , or more generally any nonstandard directory directly under the root directory.

cat /var/log/dpkg.log | grep -i to see if your desired package name is already installed.

You don’t read the log for that, dpkg -l package tells you the status of a package and you can use a wildcard like dpkg -l ‘docker*’ if you don’t know the exact name. The output shows packages you have not installed, too, so you can learn about interesting packages related to a keyword.

I know this is nearly 9 years old but in case this helps someone.

In windows we have the services that run or «startup».

It is not that simple. In Windows services can be set to start automatically but they can be set to either Manual or Disabled.

Back in the days of DOS there were device drivers that were designed based on Unix (consider Unix here to be the same as Linux but that is an over-simplification) device drivers. In Windows Microsoft renamed them Services. Not all Services are device drivers. All device drivers in Windows are Services.

When we install an application it could be installed as a service so that it starts automatically.

No. Windows Services cannot have a GUI. There were previous versions of Windows that did allow Windows Services to have a GUI but Microsoft has removed that. A Windows Service is different from a Windows application. It might be possible to install a Windows console application without a console as a service but not most Windows applications.

That menu is just a folder with shortcuts and subfolders with shortcuts. Shortcuts can exist in other places or even nowhere (seen by the user) without being in the Start -> Programs menu. In Windows applications can be put somewhere, most anywhere, and if the location of it is in the Path environment then the application can be executed the same as it was installed in some other way, except Windows Applications require more to be done by a setup program.

In Windows applications can execute without a window and then they do not appear as a «Process» in the Task Manager.

Источник

Оцените статью
Adblock
detector