Install software and build production environment under linux non-root users

Keywords: Linux brew curl Anaconda

Previous lab servers, for some reason, used users without root privileges. linux non-root users many software can not be installed, very inconvenient. My approach is to use brew instead of the package management tool of the system. Brew is the first package management tool to be used on mac, which can host all packages in user local environment. When running in the following document, remember to change the user name to your own.

1. Install anaconda

Download the official anaconda python installation package (minicondo, too), and add conda to the system variable ~/. bashrc (you will be prompted to run conda init in the installation, and point yes will be directly copied to ~/. bashrc). The goal of this step is to install curl, which is a necessary tool for downloading and installing brew, which is installed in / home/username/anaconda3/bin.

conda install curl --use-local

It is suggested to install another vim here to facilitate text editing.

2. Install brew

Use curl command to download and install brew. There are some errors in the process. If you enter brew and return after the installation, it will show that the installation is successful.

sh -c "$(curl -fsSL https://raw.githubusercontent.com/Linuxbrew/install/master/install.sh)"

Then add a brew to ~/. bashrc

export HOMEBREW_PREFIX="/home/username/.linuxbrew";
export HOMEBREW_CELLAR="/home/username/.linuxbrew/Cellar";
export HOMEBREW_REPOSITORY="/home/username/.linuxbrew/Homebrew";
export PATH="/home/username/.linuxbrew/bin:/home/username/.linuxbrew/sbin:$PATH";
export MANPATH="/home/username/.linuxbrew/share/man:$MANPATH";
export INFOPATH="/home/username/.linuxbrew/share/info:$INFOPATH";

At this point, ensuring that brew is already a call that can be made at the terminal, the next key step is

Add a line to / home/username/.linuxbrew/Homebrew/Library/Homebrew/brew.sh#L200

if [[ -n "$HOMEBREW_FORCE_BREWED_CURL" &&
      -x "$HOMEBREW_PREFIX/opt/curl/bin/curl" ]] &&
         "$HOMEBREW_PREFIX/opt/curl/bin/curl" --version >/dev/null
then
  HOMEBREW_CURL="$HOMEBREW_PREFIX/opt/curl/bin/curl"
elif [[ -n "$HOMEBREW_DEVELOPER" && -x "$HOMEBREW_CURL_PATH" ]]
then
  HOMEBREW_CURL="$HOMEBREW_CURL_PATH"
else
  HOMEBREW_CURL="curl"
fi
HOMEBREW_CURL="/home/username/anaconda/bin/curl" # Add this line!

Then enter brew install curl

After loading, brew.sh will automatically erase its previous modifications:), and brew will be officially available.

For example, brew install tmux, brew install htop, only some packages of BREW can be packed (reference package list) https://formulae.brew.sh/formula/)

3. Compile and install software package manually

If there is no package in brew and it needs to be compiled by itself, general linux packages are compiled by make. It is good to modify configure and then make & make install. The following three lines of command are as follows:

./configure --prefix=/home/username/.local
make
make install
# If you want to uninstall, run make uninstall

Finally, I share my ~/. bashrc, where ~/. local/bin and ~/. local/lib are added to PATH to compile and install for myself.

export PATH=~/.local/bin:$PATH
export C_INCLUDE_PATH=$C_INCLUDE_PATH:~/.local/include
export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:~/.local/include
export LD_LIBRARY_PATH=~/.local/lib:$LD_LIBRARY_PATH


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/home/username/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/home/username/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/home/username/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/home/username/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

export HOMEBREW_PREFIX="/home/username/.linuxbrew";
export HOMEBREW_CELLAR="/home/username/.linuxbrew/Cellar";
export HOMEBREW_REPOSITORY="/home/username/.linuxbrew/Homebrew";
export PATH="/home/username/.linuxbrew/bin:/home/username/.linuxbrew/sbin:$PATH";
export MANPATH="/home/username/.linuxbrew/share/man:$MANPATH";
export INFOPATH="/home/username/.linuxbrew/share/info:$INFOPATH";

Posted by insight on Tue, 17 Sep 2019 03:51:46 -0700