I use an installation script and here's two of my installation commands:
function InstallChrome()
{
if ( which google-chrome 1>/dev/null ); then
echo "Chrome is installed"
return
fi
echo "Installing Google Chrome ..."
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O chrome
sudo dpkg -i chrome
echo "Installed Google Chrome"
}
So basically I search for the program installed by apt
and if it exists, I won't run the apt
commands.
The reason is that it's way faster than letting the apt
check.
However, this code does not work:
function InstallSshServer()
{
if ( which openssh-server 1>/dev/null ); then
echo "SSH Server is installed"
return;
fi
echo "Installing SSH Server ..."
sudo apt install openssh-server -y
echo "Installed SSH Server"
}
What is the name of the program openssh-server
installs on my machine? How can I check if it's already installed or not?
apt-install
command would not fail if it was installed. – Kusalananda Nov 15 '22 at 17:13apt install
once with all the packages in the same invocation? You would not need to callapt install
20 times. – Kusalananda Nov 16 '22 at 09:21