


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

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 five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

vscode built-in terminal is a development tool that allows running commands and scripts within the editor to simplify the development process. How to use vscode terminal: Open the terminal with the shortcut key (Ctrl/Cmd). Enter a command or run the script. Use hotkeys (such as Ctrl L to clear the terminal). Change the working directory (such as the cd command). Advanced features include debug mode, automatic code snippet completion, and interactive command history.

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

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.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

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.

Causes and solutions for the VS Code terminal commands not available: The necessary tools are not installed (Windows: WSL; macOS: Xcode command line tools) Path configuration is wrong (add executable files to PATH environment variables) Permission issues (run VS Code as administrator) Firewall or proxy restrictions (check settings, unrestrictions) Terminal settings are incorrect (enable use of external terminals) VS Code installation is corrupt (reinstall or update) Terminal configuration is incompatible (try different terminal types or commands) Specific environment variables are missing (set necessary environment variables)
