{"id":17130,"date":"2025-12-15T12:38:22","date_gmt":"2025-12-15T07:08:22","guid":{"rendered":"https:\/\/www.skynats.com\/?p=17130"},"modified":"2025-12-16T12:22:13","modified_gmt":"2025-12-16T06:52:13","slug":"how-to-install-mongodb-shell-on-ubuntu","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/how-to-install-mongodb-shell-on-ubuntu\/","title":{"rendered":"How to Install MongoDB Shell on Ubuntu"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MongoDB Shell, commonly known as mongosh, is the modern command-line interface for interacting with MongoDB databases. It replaces the legacy mongo shell and provides improved usability, scripting support, and security features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this guide, you\u2019ll learn how to install mongosh on Ubuntu (Noble and compatible versions) using MongoDB\u2019s official APT repository. We\u2019ll walk through each step in detail, explain what each command does, and help you verify a successful installation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This step-by-step tutorial will help you Install MongoDB Shell on Ubuntu quickly and correctly using official and supported methods.<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-nbsp-import-the-mongodb-public-gpg-key\"><strong>&nbsp;Import the MongoDB Public GPG Key<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">APT uses GPG keys to verify that the software packages you install come from a trusted source. <a href=\"https:\/\/www.mongodb.com\/\" target=\"_blank\" rel=\"noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-secondary-color\">MongoDB<\/mark><\/a> signs its packages with a public GPG key, which must be added to your system before installation.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -qO- https:\/\/www.mongodb.org\/static\/pgp\/server-8.0.asc | sudo tee \/etc\/apt\/trusted.gpg.d\/server-8.0.asc<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li>wget -qO- downloads the MongoDB GPG key silently<br><\/li>\n\n\n\n<li>The pipe (|) sends the key directly to the next command<br><\/li>\n\n\n\n<li>sudo tee writes the key to \/etc\/apt\/trusted.gpg.d\/<br><\/li>\n\n\n\n<li>The key is also displayed in the terminal (no need to copy or save it manually)<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Once this command completes successfully, your system will trust MongoDB\u2019s official packages.<\/p>\n\n\n\n<h3 class=\"wp-block-heading has-small-font-size\"><strong>If gnupg Not Installed<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you see an error indicating that gnupg is missing, install it first:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> apt-get update\napt-get install gnupg -y<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After installing gnupg, retry importing the MongoDB GPG key:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>wget -qO- https:\/\/www.mongodb.org\/static\/pgp\/server-8.0.asc | sudo tee \/etc\/apt\/trusted.gpg.d\/server-8.0.asc<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\" id=\"h-add-the-mongodb-repository-to-apt-sources\"><strong>Add the MongoDB Repository to APT Sources<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Ubuntu\u2019s default repositories do not include MongoDB packages. By adding MongoDB\u2019s official repository, APT can download and install the latest MongoDB tools, including mongosh.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Create the MongoDB list file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>echo \"deb &#91; arch=amd64,arm64 ] https:\/\/repo.mongodb.org\/apt\/ubuntu noble\/mongodb-org\/8.0 multiverse\" | sudo tee \/etc\/apt\/sources.list.d\/mongodb-org-8.0.list<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command creates a new APT source file,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> \/etc\/apt\/sources.list.d\/mongodb-org-8.0.list<\/code><\/pre>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\"><strong>Reload the Local Package Database<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After adding a new repository, you must refresh APT\u2019s package index so it recognizes the MongoDB packages.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get update<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This command fetches the latest package information from all configured repositories, including MongoDB\u2019s<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-small-font-size\"><strong>Install MongoDB Shell&nbsp;<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>mongosh is MongoDB\u2019s modern shell<br><\/li>\n\n\n\n<li>Supports JavaScript, Node.js APIs, and OpenSSL<br><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Can use bundled OpenSSL or your system\u2019s OpenSSL installation<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>apt-get install -y mongodb-mongosh<\/code><\/pre>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\"><strong>&nbsp;Verify the Installation<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To confirm that mongosh installed correctly,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mongosh --version<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This confirms that mongosh is installed and ready to use.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">MongoDB Shell is a powerful tool that enhances productivity and security when working with MongoDB databases.\u00a0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you need expert help to Install MongoDB Shell on Ubuntu or face issues during setup, our <a href=\"https:\/\/www.skynats.com\/server-management\/\">Server Management Services<\/a> and <a href=\"https:\/\/www.skynats.com\/linux-server-management\/\">Linux Server Support Services<\/a> team is here to help. Contact us today for secure, reliable, and hassle-free server support.<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MongoDB Shell, commonly known as mongosh, is the modern command-line interface for interacting with MongoDB databases. It replaces the legacy mongo shell and provides improved usability, scripting support, and security features. In this guide, you\u2019ll learn how to install mongosh on Ubuntu (Noble and compatible versions) using MongoDB\u2019s official APT repository. We\u2019ll walk through each [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[1189,1188,1190,1160,1191,302,236],"class_list":["post-17130","post","type-post","status-publish","format-standard","hentry","category-blog","tag-install-mongodb","tag-install-mongodb-shell","tag-install-mongodb-shell-on-ubuntu","tag-linux-server-support-services","tag-mongodb-shell","tag-server-management-services","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=17130"}],"version-history":[{"count":1,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17130\/revisions"}],"predecessor-version":[{"id":17133,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/17130\/revisions\/17133"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=17130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=17130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=17130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}