completely uninstall r linux - 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

Related

How to copy bash commands from snippet without $ sign?

In most of the websites, I can see snippet with a bunch of bash commands ( With a Click to Copy Button), The problem with that button is this copy $ sign too.
Just like the image about, if I click copy, it will copy complete command INCLUDING $ Sign
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install gnome-shell
$ sudo apt-get install ubuntu-gnome-desktop
$ sudo apt-get install autocutsel
$ sudo apt-get install gnome-core
$ sudo apt-get install gnome-panel
$ sudo apt-get install gnome-themes-standard
We, programmers, are lazy in terms of doing this one by one, If I copy and paste this directly on bash it will show error since it will NOT recognize what is "$" as the command is starting with $ sign, is there a simple hack to let bash skip the first $ sign if command starts with it? If not any solution? I am tired of getting a response from the server and then pasting next commands
P.S This question is asked before I guess but that isn't EXACTLY what I have asked so moderators please understand my point.
Just cut it
while read -r line; do
$(echo "$line"|cut -d' ' -s -f2-)
done
After that, you'll just have to copy it to stdin(and end it witg Contr+D
As requested, here is a function that trims it:
function trimDollar(){
echo "$*"cut -d' ' -s -f2-
}

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

apt-get update error due to armhf

While installing CUDA on Ubuntu, I ran the following command in the terminal:
sudo sh -c 'echo "foreign-architecture armhf" >> /etc/dpkg/dpkg.cfg.d/multiarch'
The command failed and when I do sudo apt-get update, it gives me a whole bunch of failed to fetcherrors. My CUDA installation however, succeeded. How can I revert it back, so that I don't get errors when I update?
In my case,
sudo dpkg --remove-architecture armhf
If you have annoying dpkg: error: cannot remove architecture 'armhf' currently in use by the database, consider remove armhf packages which you'll get from dpkg -l | grep armhf command
you need to delete the entry "foreign-architecture armhf" from "/etc/dpkg/dpkg.cfg.d/multiarch" file.
first:
sudo apt-get remove --purge `dpkg --get-selections | grep armhf | awk '{print $1}'`
then
sudo dpkg --remove-architecture armhf

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