10 Способов сгенерировать пароль в консоли

One of the great things about Linux is that you can do the same thing hundreds of different ways—even something as simple as generating a random password can be accomplished with dozens of different commands. Here’s 10 ways you can do it.

We gathered all of these commands from Command-Line Fu and tested them out on our own Linux PC to make sure they work. You should be able to use at least some of these on Windows with Cygwin installed, though we didn’t test all of them—the last one definitely works though.

Generate a Random Password

For any of these random password commands, you can either modify them to output a different password length, or you can just use the first x characters of the generated password if you don’t want such a long password. Hopefully you’re using a password manager like LastPass anyway so you don’t need to memorize them.

This method uses SHA to hash the date, runs through base64, and then outputs the top 32 characters.

date +%s | sha256sum | base64 | head -c 32 ; echo

Читать

Стреляем себе в ногу

Пришла в голову идея создать список способов «стрельбы в ногу» в *NIX.

  1. chmod -x `which chmod`
  2. rm * .o
  3. rm -rf $VAR/
  4. rm -rf --no-preserve-root /*
  5. rm -rf /usr /lib/nvidia-current/xorg/xorg — эпичный баг в bumblebee, который обеспечивает поддержку nvidia optimus
  6. perl -e '$??s:;s:s;;$?::s;;=]=>%-{<-|}<&|`{;;y; -/:-@[-`{-};`-{/" -;;s;;$_;see'
  7. Русская рулетка:
    [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo «You're live»
  8. cat /dev/urandom > /dev/sda1
  9. rm /var/lib/btmp # После этого в openSUSE 11.4 не работает авторизация
  10. Fork Bomb:
    :(){ :|:& };:
  11. Замена шелла на невалидный (в современных версиях Linux не работает)
    chsh -s /usr/blin/sh; logout
  12. echo logout >> ~/.bashrc
  13. ssh server ifdown eth0
  14. Случайно нажимаем r вместо e:
    crontab -r
  15. sed -i -e 's#id:.:initdefault:#id:6:initdefault:#' /etc/inittab
  16. nohup '/etc/init.d/networking restart' & при interface 'auto'
  17. echo 'alias cd=false' >> ~/.bashrc
  18. ln -sf /bin/cat /bin/sh
  19. ln -sf /dev/urandom /etc/motd
  20. cat /dev/zero > /file
Читать