It’s a straightforward process to install brew on centos9. Here is how. First you will want to create a user with sudo.
adduser github
visudo
Then you will want to add something like;
github ALL=(ALL) NOPASSWD: ALL
If you want to authenticate maunally when running sudo commands, which might be important in stricter security setups remove the NOPASSWD: section.
On the brew official site you’ll usually find the oneliner install for brew;
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
If you are like me, you will want to inspect something before piping it to bash, or better wget the file yourself to do so;
curl https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh
bash: brew: command not found…
Simply create an alias for the brew binary or alternatively append the new path for brew to your existing shell $PATH variable like so;
echo >> /home/github/.bashrc
echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"' >> /home/github/.bashrc
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
The .bashrc file is used to execute commands on user login, and is triggered by the su switch or sshd/pamd. you can check your linuxbrew binary path has been added afterwards by typing ‘brew’.
Of course you can add the PATH the old fashioned way in .bash_profile instead if you don’t want to use eval to alias the brew binary; remember adding the whole path means any binaries can be executed there so be mindful of whether you need really need a path export.
export PATH="/home/linuxbrew/.linuxbrew/bin/:$PATH"<br>
It’s pretty simple, in my case I’m installing brew so I can access the github api, which allows a lot more flexibility of the commands I can run compared to the traditional github binary most people use.
Lets install the ‘github gh’ tool for github api like so;
brew install gh
For a successful installation of brew and its toolsets you may also require the development tools group package available on centos9 stream;
sudo yum groupinstall 'Development Tools'
Pretty simples. But handy if your are using an operating system like centos 9 stream which simply doesn’t have a safe official repo like redhat or debian operating systems.