Копилка интересного про шеллы

Маленькие хитрости, конкретные команды


Esc _ (Esc, затем подчеркивание), Alt + ., $_ -- последний аргумент предыдущей команды

Полезно и при интерактивной работе, и при составлении примеров и инструкций

mkdir /some/complicated/path
cd $_

Ctrl+w -- стереть слово слева от курсора

Alt+b, Alt+f -- перемещаться влево и вправо по началам слов

TODO: редактирование текущей команды в $EDITOR

также см. https://en.wikipedia.org/wiki/Bash_%28Unix_shell%29#Keyboard_shortcuts


GPG Change Passphrase Secret Key Password Command

gpg --edit-key Your-Key-ID-Here
gpg> passwd
gpg> save


10 UNIX Command Line Mistakes

"Experience is the name everyone gives to their mistakes." -- Oscar Wilde


Want to make apt-get install less noisy at a shell prompt or in a script?

apt-get -qq update >/dev/null
apt-get upgrade -qq -y > /dev/null


Use vim to edit files over the network using ssh on a Linux/Unix/OSX/BSD:

vim scp://user@server//home/user/file


Exclude files at a bash:
shopt -s extglob

List all except *.py
ls !(*.py)

rm all except *.pl
rm !(*.pl)


If you start editing httpd.conf without root & wanted to save without root permission, try:

:w !sudo tee %

HowTo: Save A File In Vim / Vi Without Root Permission


Shell Script To Add MySQL Database, Username and Password Including Remote Host Access

A simple shell script to add users to #MySQL/#MariaDB


HowTo: Find Out My Linux Distribution Name and Version


Convert HTML Page To a PDF Using Open Source Tool [ Linux / OS X / Windows ]


скриншоты под MacOS

screencapture + scp


Забавное sed: подбор английский слов, которые годятся как команды поиска и замены


Quick and dirty pseudo daemons

screen -S foo -m -d program


Never set SUID bit on shell scripts


Мигаем Scroll lock'ом при входящем email сообщении (perl + bash)


Как записать терминальную сессию в Linux


Sudo: A free font for coders by Jens Kutilek


Google hiring task (first 10-digit prime in e) in bash one-liner


Отдельные ситуации, сложные инструменты

USEFUL ONE-LINE SCRIPTS FOR SED


Want to view/open compressed file on a Unix/Linux/OSX/BSD?

zgrep word file zcat file

More info on z* commands

zcommands: Read gzip Compressed Text Files On a Fly


Common threads: Часть 1. Awk в примерах


ZSH Tips by ZZapper

collection of zsh shell tips for Unix/Linux/OSX/BSD users and sysadmins


Linux and Unix Port Scanning With netcat [nc] Command


Bash: Reissue And Repeat A Long Command Without Retyping It on a Linux, OS X & Unix


Linux / Unix: Cat Command Examples


xargs: How To Control and Use Command Line Arguments


Управление заданиями


Bash Extended Globbing


Linux: See Bandwidth Usage Per Process With Nethogs Tool

Want to easily find out which process are eating too much bandwidth on a Linux?


SOcket CAT

http://www.dest-unreach.org/socat/doc/socat.html

примеры


Back To The Future: Unix Wildcards Gone Wild

This article will cover one interesting old-school Unix hacking technique, that will still work nowadays in 2013. Hacking technique of which (to my suprise) even many security-related people haven't heard of. That is probably because nobody ever really talked about it before. Why I decided to write on this subject is because, to me personally, it's pretty funny to see what can be done with simple Unix wildcard poisoning tricks. So, from this article, what you can expect is collection of neat *nix hacking tricks that as far as I know somehow didn't emerge earlier. If you wonder how basic Unix tools like 'tar' or 'chown' can lead to full system compromise, keep on reading.


Tmux Resurrect

Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc. There are helpful management tools out there, but they require initial configuration and continuous updates as your workflow evolves or you start new projects.

tmux-resurrect saves all the little details from your tmux environment so it can be completely restored after a system restart (or when you feel like it). No configuration is required. You should feel like you never quit tmux.


http://www.shellcheck.net/about.html

ShellCheck is a static analysis and linting tool for sh/bash scripts. It's mainly focused on handling typical beginner and intermediate level syntax errors and pitfalls where the shell just gives a cryptic error message or strange behavior, but it also reports on a few more advanced issues where corner cases can cause delayed failures.


shell configuration management (F*CKING Shell Scripts)


StackOverflow: Fuzzy file search in linux console

agrep

AGREP - approximate GREP for fast fuzzy string searching. Files are searched for a string or regular expression, with approximate matching capabilities and user-definable records. Developed 1989-1991 by Udi Manber, Sun Wu et al. at the University of Arizona. ISC open source license since Sept. 2014.


Lock your script (against parallel run)


12 Useful “df” Commands to Check Disk Space in Linux


Piping with SSH


Mosh (mobile shell)


15 малоизвестных команд Linux + комментарии


Что такое grep и с чем его едят


Общие обзоры

Hints for writing Unix tools

“One thing well” misses the point: it should be “One thing well AND COMPOSES WELL”

Consume input from stdin, produce output to stdout.

Output should be free from headers or other decoration.

Output should be simple to parse and compose.

Treat a tool’s output as an API.

Place diagnostics output on stderr.

Signal failure with an exit status.

Make a tool’s output portable.

Omit needless diagnostics.

Avoid making interactive programs.


Linux Shell Scripting Tutorial


Shell programming with bash: by example, by counter-example


Survival guide for Unix newbies


Settling into Unix


Мини-портал Shell скрипты


Десятка лучших консольных команд


Defensive BASH Programming


20 Linux System Monitoring Tools Every SysAdmin Should Know


Top 10 Best Cheat Sheets and Tutorials for Linux / UNIX Commands


GNU Coreutils Cheat Sheet

This cheat sheet is useful if you're learning Linux and want to have a quick overview of all the available commands

Bonus: Here are some of the commands that was used to create the cheat sheet:

$ curl 'http://www.gnu.org/software/coreutils/manual/coreutils.html' 2>/dev/null |
    grep 'h3 class' |
    grep 'class="command"' |
    sed 's/.*class="command">//' |
    sed 's|</span></samp>||' |
    sed 's|</h3>||' |
    grep ':' |
    sort


https://wiki.ubuntu.com/DashAsBinSh

Почему Ubuntu перешли на dash как на дефолтный шелл


Better Bash Scripting in 15 Minutes

перевод


Github: Data Science at the Command Line

repository contains the virtual machine, data, scripts, and custom command-line tools used in the book Data Science at the Command Line.


Программирование на bash. Онлайн-курс.

Интересно посмотреть на программу: какие аспекты shell-программирования вообще существуют


Нестандартные расширения, дополнения

bish - Shell scripting with a modern feel.

Bish is a language that compiles to Bash. It's designed to give shell scripting a more comfortable and modern feel.


Functional programming in sh


UnixShell (last edited 2015-04-04 13:10:46 by lena)