Sometimes we need to make up the password. Normally the password should be easy to remember but hard to guess. I show you how to generate strong passwords that are not easy to remember :). We'll use for this purpose /dev/urandom device, which generates random data. Suppose we want to generate 10 passwords, each 8 characters long. To achieve this we type:
$ cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -8 | head -10
lUrBzyuv
RuDq498i
mOzJMs4Y
s0lUpMZd
LmwuN6Sy
fubIOO6g
KKynsPs4
dFH4W0Ux
3JAbwJQD
PofhRhTS
The fold command breaks each line after n characters, so defines the length of the password, the head command shows first n lines so defines the number of passwords. The tr deletes (-d) all but specified (-c) characters. The idea comes from here.
Showing posts with label head. Show all posts
Showing posts with label head. Show all posts
Tuesday, August 25, 2009
Saturday, August 22, 2009
The lines
If you want to check how many lines the file has, use wc -l command:
$ cat /etc/shells | wc -l
6
To see the content of the file along with line numbers use cat -n:
$ cat -n /etc/shells
1 /bin/bash
2 /bin/tcsh
3 /bin/csh
4 /bin/ash
5 /bin/ksh
6 /bin/zsh
To get the particular line from the file use head and tail. To see the 4th line from /etc/shells, type:
$ cat /etc/shells | head -4 | tail -1
/bin/ash
$ cat /etc/shells | wc -l
6
To see the content of the file along with line numbers use cat -n:
$ cat -n /etc/shells
1 /bin/bash
2 /bin/tcsh
3 /bin/csh
4 /bin/ash
5 /bin/ksh
6 /bin/zsh
To get the particular line from the file use head and tail. To see the 4th line from /etc/shells, type:
$ cat /etc/shells | head -4 | tail -1
/bin/ash
Subscribe to:
Posts (Atom)