


What are the methods for generating random passwords in Linux?
1. Use the sha algorithm to encrypt the date and output the first 32 characters of the result:
date %s |sha256sum |base64 |head -c 32 ;echo
The generated results are as follows:
ztnimgm0ndi5ogzjmwmxndlhzmjmngm4
2. Use the embedded /dev/urandom and filter out those characters that are not commonly used in daily life . Only the first 32 characters of the result are output here:
< /dev/urandom tr -dc _a-z-a-z-0-9 |head -c${1:-32};echo
The generated results are as follows:
pdj0xwz7exd_qb5b27bwwsm1hrf3a7cj
3. Use openssl’s random function
openssl rand - base64 32
The generated result is as follows:
ryjwqjltlayex3j7ncbir20h1k/0cnqlneunytscfko=
4. This method is similar to the previous urandom, but it It works in reverse
tr -cd '[:alnum:]' < /dev/urandom | fold -w32 | head -n1;echo
generated The result is as follows:
tpgudzf7sqtu4yyw2lvhmuqoziqi87
5. Use the string command, which outputs a printable string from a file
strings / dev/urandom | grep -o '[[:alnum:]]' | head -n 32 | tr -d '\n'; echo
The generated results are as follows:
w4v1iqtkmq8sidd9jxdqnpg8hpmoz8
6. This is a simpler version using urandom
< /dev/urandom tr -dc _a-z-a-z-0-9 | head -c32;echo
The generated result is as follows:
rmdlgspn_bm-izvfwz9bei0rf-jiy6gs
7. Use the very useful dd command
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev
The generated results are as follows:
9 0rud4u3hmsdmlgd7j0sf/r09mzfdvbs28w po2wca
8. You can even generate a password that can be entered with only your left hand
The generated results are as follows:
vtg3 #tr4sagxg3z%##wzg4zq@gz$wdqf
9. If you use one of the above methods every time, a better way is to save it as a function. If you do this, you can generate random passwords at any time after running the command for the first time using just randpw. Maybe you can save it to your ~/.bashrc file
randpw(){ < /dev/urandom tr -dc _a-z-a-z-0-9 | head -c${ 1:-16};echo;}
The generated results are as follows:
vgbx8cno950riykzrppya4bvbavzby_x
10. The last way to generate random passwords The method is the simplest. It can also be run under windows with cygwin installed. It can also run under mac os x. I'm sure there will be complaints that the passwords generated this way are less random than other methods. But in fact if you use all the strings it generates as the password, then the password is random enough
#date | md5sum
The generated result is as follows:
e0d057b46a9a78346cbd94b25e574e79 -
date | base64
The generated results are as follows:
##mjaxnow5tcawn acicazmeaxpsdmmj/mnj/lm5sgmtc6mda6mzygq1nucg==ifconfig | md5sum
The generated results are as follows:
7c4243742aa515d45c12deca31428a95 -You can even generate a nuclear bomb launch password. The following is an example of generating a long password; ifconfig | base64The generated results are as follows:##zw0xicagicagiexpbmsgzw5jyxa6rxrozxjuzxqgiehxywrkcia3odoyqjpdqjoyqjpcmdo5ncag
ciagicagicagicbpbmv0igfkzhi6mtkylje2oc4zljugiejjyxn 0oje5mi4xnjgumy4yntugie1hc2s6mju1lji1ns4yntuumaogicagicagicagaw5lddygywrkcjogzmu4mdo6n2eyyjpjymzmomzl
mmi6yja5nc82ncbty29wztpmaw5rciagicagicagicbvucbcuk9brenbu1qgulvotklorybnvuxu
sunbu1qgie1uvtoxntawicbnzxryawm6mqogicagicagicagulggcgfja2v0czoymdy3nty0igvy
cm9yczowigryb3bwzwq6mcbvdmvycnvuczowigzyyw1lojakicagicagicagifryihbhy2tldhm6
odg2ndugzxjyb3jzojagzhjvchblzdowig92zxjydw5zojagy2fycmllcjowciagicagicagicbj
b2xsaxnpb25zojagdhhx dwv1zwxlbjoxmdawiagicagicagulggynl0zxm6mjazndkzntex
icgxotqumcbnauipicbuwcbiexrlczozmjuynzuxniaomzeumcbnauipcgpsbyagicagicagtglu
ayblbmnhcdpmb2nhbcbmb29wymfjayagciagicagicagicbpbmv0igfkzhi6m ti3ljaumc4xicbn
yxnroji1ns4wljaumaogicagicagicagaw5lddygywrkcjogojoxlzeyocbty29wztpib3n0ciag
icagicagicbvucbmt09qqkfdsybsvu5osu5hicbnvfu6mty0mzygie1ldhjpyzoxciagicagicag
icbswcbwywnrz xrzoju2otkzmsblcnjvcnm6mcbkcm9wcgvkojagb3zlcnj1bnm6mcbmcmftztow
ciagicagicagicbuwcbwywnrzxrzoju2otkzmsblcnjvcnm6mcbkcm9wcgvkojagb3zlcnj1bnm6
mcbjyxjyawvyojakicag icagicagignvbgxpc2lvbnm6mcb0ehf1zxvlbgvuojagciagicagicag
icbswcbiexrlczozmzezmdcxosaomzeunsbnauipicbuwcbiexrlczozmzezmdcxosaomzeunsbn
auipcgo=
The above is the detailed content of What are the methods for generating random passwords in Linux?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



How to use Docker Desktop? Docker Desktop is a tool for running Docker containers on local machines. The steps to use include: 1. Install Docker Desktop; 2. Start Docker Desktop; 3. Create Docker image (using Dockerfile); 4. Build Docker image (using docker build); 5. Run Docker container (using docker run).

Docker process viewing method: 1. Docker CLI command: docker ps; 2. Systemd CLI command: systemctl status docker; 3. Docker Compose CLI command: docker-compose ps; 4. Process Explorer (Windows); 5. /proc directory (Linux).

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

VS Code is the full name Visual Studio Code, which is a free and open source cross-platform code editor and development environment developed by Microsoft. It supports a wide range of programming languages and provides syntax highlighting, code automatic completion, code snippets and smart prompts to improve development efficiency. Through a rich extension ecosystem, users can add extensions to specific needs and languages, such as debuggers, code formatting tools, and Git integrations. VS Code also includes an intuitive debugger that helps quickly find and resolve bugs in your code.

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.
