Linux trivia

What is the difference between .bash_profile and .bashrc?

stackexchange ref: https://apple.stackexchange.com/questions/51036/what-is-the-difference-between-bash-profile-and-bashrc

edited Jan 18 '15 at 11:40 by jherran (https://apple.stackexchange.com/users/96174/jherran)
answered May 10 '12 at 21:46 by Alex (https://apple.stackexchange.com/users/669/alex)

.bash_profile is executed for login shells, while .bashrc is executed for interactive non-login shells.

When you login (type username and password) via console, either sitting at the machine, or remotely via ssh: .bash_profile is executed to configure your shell before the initial command prompt.

But, if you’ve already logged into your machine and open a new terminal window (xterm) then .bashrc is executed before the window command prompt. .bashrc is also run when you start a new bash instance by typing /bin/bash in a terminal.

On OS X, Terminal by default runs a login shell every time, so this is a little different to most other systems, but you can configure that in the preferences.

How to check whether R is already installed in Ubuntu?

stackoverflow ref: https://stackoverflow.com/questions/25939976/how-to-check-whether-r-is-already-installed-in-ubuntu

answered Sep 19 '14 at 21:48 by Alex (https://stackoverflow.com/users/1690692/jdharrison)

On ubuntu I would typically use the which command to check for existence of a program. which is a Unix command used to identify the location of executable. If the R executable is somewhere in the PATH then it should return its location:

john@ubuntu:~$ which R
/usr/bin/R

Alternatively you can use the type command:

type is a Unix command that describes how its arguments would be interpreted if used as command names.

john@ubuntu:~$ type R
R is /usr/bin/R

failing R being on the PATH you could resort to locate which would be faster than find however it will most likely give you a large number of returns for R so some filtering would be required:

john@ubuntu:~$ locate -b R | fgrep -w R/bin
/usr/lib/R/bin/R
/usr/lib/R/bin/REMOVE
/usr/lib/R/bin/Rcmd
/usr/lib/R/bin/Rd2pdf
/usr/lib/R/bin/Rdconv
/usr/lib/R/bin/Rdiff
/usr/lib/R/bin/Rprof
/usr/lib/R/bin/Rscript
/usr/lib/R/bin/exec/R