{"id":3445,"date":"2022-07-25T10:33:33","date_gmt":"2022-07-25T05:03:33","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3445"},"modified":"2023-01-23T16:09:48","modified_gmt":"2023-01-23T10:39:48","slug":"how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/","title":{"rendered":"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc"},"content":{"rendered":"\n<p>No matter what you\u2019re doing on your computer, you need to do so with an eye to security \u2014 that means using strong passwords, storing files in safe locations, and in some cases encrypting files. Fortunately, for nearly every usage, there are tools to enable you to encrypt your data\u2026from transferring data online to storing data on a locally attached storage, even encrypting your entire drive.<\/p>\n\n\n\n<p>Since gpg is built into almost every Linux system, you won\u2019t have to install anything to get this working from the command line. I\u2019ll also show how to gain this functionality within the Nautilus (GNOME Files) file manager tool.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">From the command line<\/h2>\n\n\n\n<p>Let\u2019s say you have a file,&nbsp;<em>\/home\/user\/test.txt<\/em>, that you want to password protect. Using gpg, you would do the following.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open a terminal window.<\/li>\n\n\n\n<li>Change to the&nbsp;<em>\/home\/user\/<\/em>&nbsp;directory with the command&nbsp;<em>cd&nbsp;\/home\/user\/<\/em><\/li>\n\n\n\n<li>Encrypt the file with the command&nbsp;<em>gpg -c test.txt.<\/em><\/li>\n\n\n\n<li>Enter a unique password for the file and hit Enter.<\/li>\n\n\n\n<li>Verify the newly typed password by typing it again and hitting Enter.<\/li>\n<\/ol>\n\n\n\n<p>You should now see the file test.txt.gpg in the \/home\/user folder. To decrypt that file, do the following.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open a terminal window.<\/li>\n\n\n\n<li>Change to the \/home\/user directory with the command&nbsp;<em>cd \/home\/user.<\/em><\/li>\n\n\n\n<li>Decrypt the file with the command&nbsp;<em>gpg important.dox.gpg.<\/em><\/li>\n\n\n\n<li>When prompted, enter the decryption password you created when encrypting the file.<\/li>\n<\/ol>\n\n\n\n<p>You could send that file to a recipient and, as long as they have gpg installed, they can decrypt the file with the password you used for encryption. If they are a Windows user, they can always install&nbsp;<a href=\"https:\/\/www.gpg4win.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Gpg4win<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The GUI way<\/h2>\n\n\n\n<p>If you happen to be a GNOME 3 user (or any Linux desktop that makes use of either Nautilus or GNOME Files), you can add a contextual menu entry to the file manager for encryption. Here\u2019s how (I\u2019ll demonstrate it on Ubuntu GNOME 16.04).<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open a terminal window.<\/li>\n\n\n\n<li>Issue the command&nbsp;<em>sudo apt-get install seahorse-nautilus.<\/em><\/li>\n\n\n\n<li>Type your sudo password and hit Enter.<\/li>\n\n\n\n<li>If prompted, type&nbsp;<em>y<\/em>&nbsp;and hit Enter.<\/li>\n\n\n\n<li>Allow the installation to complete.<\/li>\n<\/ol>\n\n\n\n<p>Open the file manager and navigate to the \/home\/user directory. Right-click the test.text file and then click the Encrypt\u2026 entry. You will be prompted to enter and then verify an encryption password. Once you\u2019ve verified the password, the test.txt.gpg file will appear in<\/p>\n\n\n\n<p>The decryption process is the same.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the file manager.<\/li>\n\n\n\n<li>Navigate to the encrypted file.<\/li>\n\n\n\n<li>Right-click the encrypted file.<\/li>\n\n\n\n<li>Click Open with Decrypt File.<\/li>\n\n\n\n<li>When prompted, give the new file a name and click Enter.<\/li>\n\n\n\n<li>When prompted, enter the decryption password and click Enter.<\/li>\n<\/ol>\n\n\n\n<p>The encrypted file will now be decrypted and ready to use.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>No matter what you\u2019re doing on your computer, you need to do so with an eye to security \u2014 that means using strong passwords, storing files in safe locations, and in some cases encrypting files. Fortunately, for nearly every usage, there are tools to enable you to encrypt your data\u2026from transferring data online to storing [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3469,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[1],"tags":[],"class_list":["post-3445","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog<\/title>\n<meta name=\"description\" content=\"How to easily encrypt\/decrypt a file in Linux with gpg\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"How to easily encrypt\/decrypt a file in Linux with gpg\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-25T05:03:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-23T10:39:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/\",\"name\":\"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1\",\"datePublished\":\"2022-07-25T05:03:33+00:00\",\"dateModified\":\"2023-01-23T10:39:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"description\":\"How to easily encrypt\/decrypt a file in Linux with gpg\",\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1\",\"width\":1920,\"height\":1080,\"caption\":\"encrypt & decrypt a file Linux\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog","description":"How to easily encrypt\/decrypt a file in Linux with gpg","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/","og_locale":"en_US","og_type":"article","og_title":"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog","og_description":"How to easily encrypt\/decrypt a file in Linux with gpg","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/","og_site_name":"24x7serversupport Blog","article_published_time":"2022-07-25T05:03:33+00:00","article_modified_time":"2023-01-23T10:39:48+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp","type":"image\/webp"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/","name":"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1","datePublished":"2022-07-25T05:03:33+00:00","dateModified":"2023-01-23T10:39:48+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"description":"How to easily encrypt\/decrypt a file in Linux with gpg","breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#primaryimage","url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1","width":1920,"height":1080,"caption":"encrypt & decrypt a file Linux"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-easily-encrypt-decrypt-a-file-in-linux-with-gpg\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to easily encrypt\/decrypt a file in Linux with gpg\ufffc"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2022\/07\/encrpt.webp?fit=1920%2C1080&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3445","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3445"}],"version-history":[{"count":2,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3445\/revisions"}],"predecessor-version":[{"id":3475,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3445\/revisions\/3475"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media\/3469"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3445"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3445"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3445"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}