Remove packages contain specific word in name - linux

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

Related

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

How to view all installed packages in terminal (Ubuntu)

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**

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

How can I check if ncurses is installed?

How can I check if ncurses is installed in a Red-Hat Linux OS? One solution is to use
dpkg -l '*ncurses*' | grep '^ii'
But I don't even have the dpkg package in my system, and since I don't have the administrative rights, I can't install it.
On RedHat based systems there is (mostly) no dpkg but you can use rpm -qa | grep ncurse
on mac:
prompt> ls -la /usr/include/ncurses.h
lrwxr-xr-x 1 root wheel 8 11 jul 14:24 /usr/include/ncurses.h -> curses.h
The second line being not empty, this means ncurses is installed.

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