How to view all installed packages in terminal (Ubuntu) - linux

Need to view all the packages installed on my system through terminal.
I am using ubuntu 16.10

# dpkg -l
From dpkg manual:
dpkg-query actions
See dpkg-query(1) for more information about the following actions.
-l, --list package-name-pattern...
List packages matching given pattern.
-s, --status package-name...
Report status of specified package.
-L, --listfiles package-name...
List files installed to your system from package-name.
-S, --search filename-search-pattern...
Search for a filename from installed packages.
-p, --print-avail package-name...
Display details about package-name, as found in
/var/lib/dpkg/available. Users of APT-based frontends
should use apt-cache show package-name instead.

To list packages installed only by you:
gunzip -c /var/log/apt/history.log.*.gz | grep 'apt-get install' | cut -f4- -d" " | tr ' ' $'\n' | sort -u

Solution: In order to view all installed packages in linux Ubuntu, run on terminal apt --installed list,
Use apt flags and would be able to see available upgrades to some packages ( --upgradeable ) / current installed packages ( --installed ) / all available versions ( --all-versions ).
From Documentation:
DESCRIPTION
apt provides a high-level commandline interface for the package management system.
It is intended as an end user interface and enables some options better suited for interactive usage by
default compared to more specialized APT tools like apt-get(8) and apt-cache(8).
Much like apt itself, its manpage is intended as an end user interface and as such only mentions the most
used commands and options partly to not duplicate information in multiple places and
partly to avoid overwhelming readers with a cornucopia of options and details.
the list flag offers 3 options:
list (work-in-progress)
list is somewhat similar to dpkg-query --list in that it can display a
list of packages satisfying certain criteria. It supports glob(7)
patterns for matching package names as well as
options to list installed (--installed), upgradeable (--upgradeable) or
all available (--all-versions) versions.

command to list all installed packages
sudo apt list --installed
you can add 'grep' to find your service as below:
sudo apt list --installed | grep <my_service_name>

I used the following Three Cmd Syntaxes & tested them to List installed packages on My ubuntu Subsystem machine from VB6 Shell() function and 2 of them Worked fine:
1- Syntax-#1:[ Worked ]
sudo apt list --installed
2- Syntax-#2:[ Worked ]
sudo dpkg -l
Syntax-#3: [ Do not Worked .. for me ]
sudo dpkg -l | grep -i apache
And Here is MY VB6 - Code List:
Private Sub Command1_Click()
Dim Id3 As Variant ' 1- Syntax-#1: Worked fine:
Id3 = Shell(App.Path & "\bash.exe | sudo apt list --installed", vbNormalFocus)
' 2- Syntax-#2: Worked Also: ' Id3 = Shell(App.Path & "\bash.exe
| sudo dpkg -l", vbNormalFocus)
' 3- Syntax-#3: Does not show output ... Why .. Dont know now: '
Id3 = Shell(App.Path & "\bash.exe | sudo dpkg -l | grep -i apache",
vbNormalFocus) End Sub**

Related

wget recursion and file extraction

I'm trying to use wget to elegantly & politely download all the pdfs from a website. The pdfs live in various sub-directories under the starting URL. It appears that the -A pdf option is conflicting with the -r option. But I'm not a wget expert! This command:
wget -nd -np -r site/path
faithfully traverses the entire site downloading everything downstream of path (not polite!). This command:
wget -nd -np -r -A pdf site/path
finishes immediately having downloaded nothing. Running that same command in debug mode:
wget -nd -np -r -A pdf -d site/path
reveals that the sub-directories are ignored with the debug message:
Deciding whether to enqueue "https://site/path/subdir1". https://site/path/subdir1 (subdir1) does not match acc/rej rules. Decided NOT to load it.
I think this means that the sub directories did not satisfy the "pdf" filter and were excluded. Is there a way to get wget to recurse into sub directories (of random depth) and only download pdfs (into a single local dir)? Or does wget need to download everything and then I need to manually filter for pdfs afterward?
UPDATE: thanks to everyone for their ideas. The solution was to use a two step approach including a modified version of this: http://mindspill.net/computing/linux-notes/generate-list-of-urls-using-wget/
UPDATE: thanks to everyone for their ideas. The solution was to use a two step approach including a modified version of this: http://mindspill.net/computing/linux-notes/generate-list-of-urls-using-wget/
Try this
1)the ā€œ-lā€ switch specifies to wget to go one level down from the primary URL specified. You could obviously switch that to how ever many levels down in the links you want to follow.
wget -r -l1 -A.pdf http://www.example.com/page-with-pdfs.htm
refer man wget for more details
if the above doesn't work,try this
verify that the TOS of the web site permit to crawl it. Then, one solution is :
mech-dump --links 'http://example.com' |
grep pdf$ |
sed 's/\s+/%20/g' |
xargs -I% wget http://example.com/%
The mech-dump command comes with Perl's module WWW::Mechanize (libwww-mechanize-perl package on debian & debian likes distros
for installing mech-dump
sudo apt-get update -y
sudo apt-get install -y libwww-mechanize-shell-perl
github repo https://github.com/libwww-perl/WWW-Mechanize
I haven't tested this, but you cans still give a try, what i think is you still need to find a way to get all URLs of a website and pipe to any of the solutions I have given.
You will need to have wget and lynx installed:
sudo apt-get install wget lynx
Prepare a script name it however you want for this example pdflinkextractor
#!/bin/bash
WEBSITE="$1"
echo "Getting link list..."
lynx -cache=0 -dump -listonly "$WEBSITE" | grep ".*\.pdf$" | awk '{print $2}' | tee pdflinks.txt
echo "Downloading..."
wget -P pdflinkextractor_files/ -i pdflinks.txt
to run the file
chmod 700 pdfextractor
$ ./pdflinkextractor http://www.pdfscripting.com/public/Free-Sample-PDF-Files-with-scripts.cfm

Nix shell: How to list the installed Haskell package versions

As a non-nix'er I installed the newest version of https://github.com/reflex-frp/reflex-platform. I think working in this nix-shell is a nice experience.
Now I want to know which Haskell packages in which versions are installed and used in this shell. After some googling I found a nix-env command in the following form:
nix-env -f '<nixpkgs>' -qaPA haskellPackages|grep reflex-dom
This command gives me the version of reflex-dom as reflex-dom-0.3. But I know from here that in my nix shell I use the newest version 0.4 of reflex-dom. So I assume the above command just lists the available Hackage packages.
What is the correct nix-env -q command to get only the installed Haskell packages and its versions?.
(I played with the --installed option, however I never got something back)
You can try to nix-store -q --references $out after you entered the shell. This will, however, mix both haskell and non-haskell dependencies in output.
This is a complete example with filter applied:
$ nix-store -q --references $out \
| while read p; do du -a $p | grep -q ghc && echo $p; done

completely uninstall r linux

I am trying to update my version of R on linux mint, however broken dependencies are stopping me doing this. after trying everything such as adding repos from Cran, sudo apt-get update, I still cannot install the latest version of R.
MY question is how to i completely remove R from my machine, so that I can restart. I have tried :
sudo apt-get remove r-base
however when I run R it still works:
laptop$ R
R version 2.13.1 (2011-07-08)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)
and doesn;t seem to be removed at all.
I want a clean, fresh install, but I don't think I am removing R properly
The R binary (well, front-end script) is part of the r-base-core package which contains the core R system.
The package r-base is a so-called virtual package which exists to just pulls other packages in. Removing it does not remove any parts of the R system --- for which you need to remove r-base-core.
You might want to check on all currently installed R packages.
You can list all packages whose name starts with "r-" like this:
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }'
To uninstall all of them, pipe the output to xargs apt-get remove:
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | xargs apt-get remove --purge
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y
Worked for me on Ubuntu 14.04. Note sudo addition to the previous suggestion by others.
At your Linux command line, try:
dpkg --get-selections | grep "^r\-"
This will list R packages installed on your system. You can then delete them by name.
Hopefully this proves useful.
In addition to running:
sudo apt-get remove r-base
sudo apt-get remove r-base-core
try also:
sudo apt purge r-*
The following does the job especially if you want to update your R version.
sudo apt-get remove r-base-core

Remove packages contain specific word in name

In Linux (Fedora), how I see all the installed packages which contain a certain words in the package name. Then, remove all these packages installed.
Assuming you are using a debian-based Linux (like Ubuntu or Mint, for example), you can do like this to search for mysq:
dpkg -l | grep mysq
and to get only the names
dpkg -l | grep mysq | awk '{print $2}'
if you want remove all packages, containing a specific word, you don't need to pipe lists through grep or whatever. Just type
$ sudo yum remove "*word*"
If you want to review list of such packages before removing, then type
$ rpm -qa "*word*"
That's it.
Fedora is an RPM-based distribution. So you'll want to use the rpm or yum commands.
To list installed: yum list installed | grep <name> or rpm -a | grep <name>
To remove a package: rpm -e <package-name> or yum remove <package-name>
Sources:
Fedora RPM Guide
Fedora yum wiki
in linux, you can install programs in a variety of places. Most of the time, your rpm on your distro is responsible for removing all of the bits and pieces of a program. One solution, although this is fraught with danger, is to grep your usr/bin like this:
ls /usr/bin || grep 'some package name'
and pipe that to an rm-rf ... 'shuddurs'
A safer bet though is to just use apt-get uninstall 'someApp' much safter

Checking for installed package for bash

I need a script that will check whether packages are installed for apache2, mysql and php.
Example output:
apache2 .... ok
mysql .... ok
php ... not installed
Packages are not necessarily named the same on different distributions, and querying for their presence depends on the package manager in use.
Debian (dpkg):
dpkg-query -W -f='${Package}\n' apache2 mysql-server php5 2>/dev/null
Fedora (RPM):
rpm -q --qf '%{NAME}\n' httpd mysql-server php 2>/dev/null
Gentoo (Portage):
equery --quiet list www-servers/apache:2 dev-lang/php dev-db/mysql
Assuming APT:
dpkg -l | grep -i apache2
etc.
For CentOS (will only show the ones that are installed):
yum list installed | egrep -i 'apache|mysql|php'

Resources