If you just want the
mongo shell, you could install the
mongodb-clients package mentioned in your question. However, note that this includes an older shell version (3.6.3).
The official MongoDB packages are updated with each minor release and you should ideally install a shell version matching your MongoDB server's major version (3.6, 4.0). Significant mismatches in shell versus server versions can result in some subtle errors as well as missing or outdated helpers. For example, the MongoDB 3.6.x shell doesn't have helpers for transactions (which were added in 4.0).
The MongoDB documentation includes information on Installing the official packages on Ubuntu. There is a
mongodb-org-shell package which only includes the MongoDB shell, and you may also want to install
mongodb-org-tools for other command-line tools (
It would be best to follow the instructions in the MongoDB documentation as some details may change in future (such as the signing key), but the general steps to follow for MongoDB 4.0 on Ubuntu 18.04 (Bionic) are:
Import the public key used to sign packages from MongoDB, Inc
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
Create a package list file for MongoDB
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
Update your local package database
sudo apt-get update
Install the desired MongoDB package(s)
sudo apt-get install -y mongodb-org-shell