{"id":2646,"date":"2016-09-07T14:09:12","date_gmt":"2016-09-07T18:09:12","guid":{"rendered":"https:\/\/www.globo.tech\/learning-center\/?p=2646"},"modified":"2017-11-24T16:37:18","modified_gmt":"2017-11-24T21:37:18","slug":"generate-random-password-linux","status":"publish","type":"post","link":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/","title":{"rendered":"How to generate random password on Linux"},"content":{"rendered":"<h1>How to generate random password on Linux<\/h1>\n<div class=\"row\">\n<div class=\"col-lg-10\">\n<p>Being able to generate a random password is an easy to do process on all <a rel=\"nofollow\" href=\"https:\/\/www.linux.com\/what-is-linux\" target=\"_blank\">Linux systems<\/a> that allow users to enhance their security in a very simple way. Stronger than the average family member name, pet name, or hobby password, randomly generated passwords also prove themselves handy when needing to create multiple new passwords and are extremely easily customizable. Such passwords can include special characters and be any length you need, and multiple passwords can even be generated at once for system administration convenience.<\/p>\n<\/div>\n<div class=\"col-lg-2\">\n<img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"678\" src=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg\" alt=\"random password\" class=\"alignright size-full wp-image-3871\" \/>\n<\/div>\n<\/div>\n<p>This guide will show how you can generate a random password for yourself on any Linux\/Unix system.<\/p>\n<h2>Getting Started<\/h2>\n<p>In order to complete this tutorial, you need the following:<br \/>\n\u2022 1 Server (<a href=\"https:\/\/www.globo.tech\/cloud-server-pricing\" target=\"_blank\"><b>Cloud Server<\/b><\/a> or <a href=\"http:\/\/www.globo.tech\/dedicated-server-hosting\" target=\"_blank\"><b>Dedicated Server<\/b><\/a>) running Linux.<\/p>\n<h2>Tutorial<\/h2>\n<p>We start off simple with a method that can be used on any Linux\/Unix system in order to generate a random string. The below command uses \/dev\/urandom, which is a special file that uses the internal random number generator to produce pseudo-random bits. Note that this is different than the popular \/dev\/random that you likely know already, which is a true random number generator unlike the pseudo-randomness of \/dev\/urandom. We can use \/dev\/urandom to generate a password that is eight characters long and is made up of random uppercase and lowercase letters and numbers (you may need to use sudo):<\/p>\n<p><code>head \/dev\/urandom | tr -dc A-Za-z0-9 | head -c 8<\/code><\/p>\n<p>The above command, broken down, uses the head to get the first few lines of the dev\/urandom file, then pipes the output to the command tr. This command translates the input string into a new one based on the options given to it. We used the options -dc to delete and use the complement of the given set with A-Za-z0-9 to get uppercase, lowercase, and numerical characters. The final pipe again uses head to cut the output into eight characters. To get a password that is longer than eight characters, simply change the value of -c 8 in the above command to your desired length, for example the following for a ten-character long password:<\/p>\n<p><code>head \/dev\/urandom | tr -dc A-Za-z0-9 | head -c 10<\/code><\/p>\n<h2>Using pwgen<\/h2>\n<p>While \/dev\/urandom can be used anywhere and comes built-in, you can also use pwgen to generate a random password. pwgen is more than a random password generator however, it is a professional password generating tool that can create classical cryptographically-secure passwords, pattern-based passwords, list-based passwords, and more, all using the random pool technique to generate random data. It is open-source, free to use, and works on many systems. To install pwgen for yourself, execute one of the following commands for your respective system (you may need root privileges, use sudo if needed):<\/p>\n<p><strong>CentOS<\/strong><\/p>\n<p><code>yum install pwgen -y<\/code><\/p>\n<p><strong>Debian\/Ubuntu<\/strong><\/p>\n<p><code>apt-get install pwgen -y<\/code><\/p>\n<p>When using pwgen, the basic structure of the command is as following:<\/p>\n<p><code class=\"gris\">pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]<\/code><\/p>\n<p>To create a single random password that is ten characters (uppercase\/lowercase letters and numbers), execute this command. The -s flag ensures that the password created is truly random, the value 10 states how many characters long the password should be, and the value 1 represents the number of passwords we want to output:<\/p>\n<p><code>pwgen 10 -s 1<\/code><\/p>\n<p>This command results in a password that looks like this:<\/p>\n<p><code class=\"gris\">RUFv7fxA3o<\/code><\/p>\n<p>To make your passwords more secure, you can add special characters using the flag -y as part of the above command such as this:<\/p>\n<p><code>pwgen 10 -sy 1<\/code><\/p>\n<p>Adding the special character flag creates passwords like this instead of the above. Note the inclusion of special characters suchas # or +:<\/p>\n<p><code class=\"gris\">N+`I#ZDK4V<\/code><\/p>\n<p>In the case that you want a password that is a different amount of characters, such as rather 20 (or any other number), you can modify the amount of characters output such as in this example to output a 20-character long random password:<\/p>\n<p><code>pwgen 20 -s 1<\/code><\/p>\n<p>The result will now be a single password that has 20 characters:<\/p>\n<p><code class=\"gris\">E502JHiybGi7dvsQGbWS<\/code><\/p>\n<p>In the case that you want to output more than one password, simple change the value 1 to any other number, for example 3, to receive three generated passwords:<\/p>\n<p><code>pwgen 10 -sy 3<\/code><\/p>\n<p>The output respectively will change to show the three passwords:<\/p>\n<p><code class=\"gris\">LG]8*;9L.z BT3|NAEM5z 4i*GQ}CL`V<\/code><\/p>\n<p>More information about the command-line options for pwgen can be found in its man page either online or accessible via:<\/p>\n<p><code>man pwgen<\/code><\/p>\n<h2>Conclusion<\/h2>\n<p>Having completed this guide, you are now able to generate random passwords using both the tool pwgen as well as the built-in Linux\/Unix file \/dev\/urandom. Enjoy playing around with the different command-line options to generate passwords that suit your needs, and share with your friends! <\/p>\n<!-- AddThis Advanced Settings generic via filter on the_content --><!-- AddThis Share Buttons generic via filter on the_content -->","protected":false},"excerpt":{"rendered":"<p>How to generate random password on Linux Being able to generate a random password is an easy to do process on all Linux systems that allow users to enhance their security in a very simple way. Stronger than the average family member name, pet name, or hobby password, randomly generated passwords also prove themselves handy<!-- AddThis Advanced Settings generic via filter on get_the_excerpt --><!-- AddThis Share Buttons generic via filter on get_the_excerpt --><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[],"class_list":["post-2646","post","type-post","status-publish","format-standard","hentry","category-applications","operating_system-centos-7"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to generate random password on Linux - Globo.Tech<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to generate random password on your Linux server. Read now &amp; Enhance their security in a very simple way.\" \/>\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.globo.tech\/learning-center\/generate-random-password-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to generate random password on Linux - Globo.Tech\" \/>\n<meta property=\"og:description\" content=\"This tutorial will show you how to generate random password on your Linux server. Read now &amp; Enhance their security in a very simple way.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"Globo.Tech\" \/>\n<meta property=\"article:published_time\" content=\"2016-09-07T18:09:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-11-24T21:37:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg\" \/>\n<meta name=\"author\" content=\"GloboTech Communications\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"GloboTech Communications\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/\",\"name\":\"How to generate random password on Linux - Globo.Tech\",\"isPartOf\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg\",\"datePublished\":\"2016-09-07T18:09:12+00:00\",\"dateModified\":\"2017-11-24T21:37:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\"},\"description\":\"This tutorial will show you how to generate random password on your Linux server. Read now & Enhance their security in a very simple way.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg\",\"contentUrl\":\"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg\",\"width\":960,\"height\":678},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.globo.tech\/learning-center\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to generate random password on Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#website\",\"url\":\"https:\/\/www.globo.tech\/learning-center\/\",\"name\":\"Globo.Tech\",\"description\":\"Welcome to the Official Globo.Tech Learning Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87\",\"name\":\"GloboTech Communications\",\"sameAs\":[\"http:\/\/www.gtcomm.net\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to generate random password on Linux - Globo.Tech","description":"This tutorial will show you how to generate random password on your Linux server. Read now & Enhance their security in a very simple way.","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.globo.tech\/learning-center\/generate-random-password-linux\/","og_locale":"en_US","og_type":"article","og_title":"How to generate random password on Linux - Globo.Tech","og_description":"This tutorial will show you how to generate random password on your Linux server. Read now & Enhance their security in a very simple way.","og_url":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/","og_site_name":"Globo.Tech","article_published_time":"2016-09-07T18:09:12+00:00","article_modified_time":"2017-11-24T21:37:18+00:00","og_image":[{"url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg","type":"","width":"","height":""}],"author":"GloboTech Communications","twitter_misc":{"Written by":"GloboTech Communications","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/","url":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/","name":"How to generate random password on Linux - Globo.Tech","isPartOf":{"@id":"https:\/\/www.globo.tech\/learning-center\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage"},"image":{"@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg","datePublished":"2016-09-07T18:09:12+00:00","dateModified":"2017-11-24T21:37:18+00:00","author":{"@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87"},"description":"This tutorial will show you how to generate random password on your Linux server. Read now & Enhance their security in a very simple way.","breadcrumb":{"@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#primaryimage","url":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg","contentUrl":"https:\/\/www.globo.tech\/learning-center\/wp-content\/uploads\/2016\/09\/password-866977_960_720.jpg","width":960,"height":678},{"@type":"BreadcrumbList","@id":"https:\/\/www.globo.tech\/learning-center\/generate-random-password-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.globo.tech\/learning-center\/"},{"@type":"ListItem","position":2,"name":"How to generate random password on Linux"}]},{"@type":"WebSite","@id":"https:\/\/www.globo.tech\/learning-center\/#website","url":"https:\/\/www.globo.tech\/learning-center\/","name":"Globo.Tech","description":"Welcome to the Official Globo.Tech Learning Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.globo.tech\/learning-center\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.globo.tech\/learning-center\/#\/schema\/person\/e17784b37f4a4f49b7bc611847912e87","name":"GloboTech Communications","sameAs":["http:\/\/www.gtcomm.net"]}]}},"_links":{"self":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/comments?post=2646"}],"version-history":[{"count":5,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2646\/revisions"}],"predecessor-version":[{"id":3063,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/posts\/2646\/revisions\/3063"}],"wp:attachment":[{"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/media?parent=2646"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/categories?post=2646"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.globo.tech\/learning-center\/wp-json\/wp\/v2\/tags?post=2646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}