gpg / ssh

gpg

http://deferred.io/2017/08/03/yubikey4-gpg-ssh-u2f.html#how-i-use-my-yubikey-gnupg

gpg --list-secret-keys --keyid-format LONG
gpg --import

git

tmux

tmux new -s named-session
tmux -a named-session

Ctrl + b I to install/restart
Ctrl + b y to yank
Ctrl + b o to switch panes
Ctrl + b % for a vertical pane
Ctrl + b " for a horizontal pane

vim

  • :sp and :vsp for splits

  • Ctrl + w for focus shifting, max/min with _ and =

  • ':set spell' activates vim spellchecker. Use ']s' and '[s' to move between mistakes, 'zg' adds to the dictionary, 'z=' suggests correctly spelled words

fish

chsh -s /usr/local/bin/fish
#edit /etc/shells  I think
chsh -s /bin/bash

curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish

Once nice thing about Fish is a web-based configuration. Run fish_config to start the web client.

Consider further...

set --universal fish_user_paths $fish_user_path ~/bin/
# Define alias in shell
alias rmi "rm -i"

# Define alias in config file
alias rmi="rm -i"

# This is equivalent to entering the following function:
function rmi
    rm -i $argv
end

# Then, to save it across terminal sessions:
funcsave rmi

tools

  • 'htop' instead of 'top'
  • ps aux | egrep '[t]erminal'
  • Pipe any command over 'column -t' to nicely align the columns
  • 'file' gives information about a file, as image dimensions or text encoding
  • 'watch'
  • 'echo start_backup.sh | at midnight' starts a command at the specified time
  • 'ranger' is a nice console file manager for vi fans https://ranger.github.io/
  • linux: Use 'apt-file' to see which package provides that file you're missing
  • if you liked the 'psgrep' alias, check 'pgrep' as it is far more powerful
  • learn to use 'pushd' to save time navigating folders (j.py is better though) https://unix.stackexchange.com/questions/77077/how-do-i-use-pushd-and-popd-commands#77081
  • 'dict' is a commandline dictionary
  • Learn to use 'find' and 'locate' to look for files
  • Compile your own version of 'screen' from the git sources. Most versions have a slow scrolling on a vertical split or even no vertical split at all
  • 'trash-cli' sends files to the trash instead of deleting them forever. Be very careful with 'rm' or maybe make a wrapper to avoid deleting ' ' by accident (e.g. you want to type 'rm tmp_' but type 'rm tmp *')
  • 'sort | uniq' to check for duplicate lines
  • Google 'magic sysrq' and learn how to bring you machine back from the dead
  • 'diff --side-by-side fileA.txt fileB.txt | pager' to see a nice diff
  • 'j.py' http://tiny.cc/62qjow remembers your most used folders and is an incredible substitute to browse directories by name instead of 'cd'
  • 'dropbox_uploader.sh' http://tiny.cc/o2qjow is a fantastic solution to upload by commandline via Dropbox's API if you can't use the official client

docker

DJANGO_DOCKER_ID=$( docker service ls | grep sportshi_dev_django | awk '{print $1}' )
echo $DJANGO_DOCKER_ID
docker exec -i $DJANGO_DOCKER_ID bash
git commit --amend --reset-author --no-edit

youtube-dl

youtube-dl
youtube-dl --extract-audio --audio-format mp3 -o "% (title)s.%(ext)s" <url to playlist>
youtube-dl --extract-audio --audio-format mp3 -o "% (title)s.%(ext)s" https://www.youtube.com/playlist?list=PLeuCAdRSnObyIgsHQowMS0Of-tQmHbdFa
youtube-dl --extract-audio --audio-format mp3 -o "% (title)s.%(ext)s"

mysql

SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM users;

prompt mysql (\d)-(\r:\m:\s)>;
CREATE USER 'stampede'@'%' IDENTIFIED BY 'password';
grant all on `stampede_%`.* to `stampede`@`%`;
\G

bash

Networking

check ports

lsof -i -n -P | grep trans
  • Some tools to monitor network connections and bandwith:

    • 'lsof -i' monitors network connections in real time
    • 'iftop' shows bandwith usage per connection
    • 'nethogs' shows the bandwith usage per process
  • 'python -m SimpleHTTPServer 8080' shares all the files in the current folder over HTTP, port 8080

screen

screen -a
screen -list
echo $TERM

Ctrl+a c create
Ctrl+a n next
Ctrl+a d detach
Ctrl+a m monitor
Ctrl+a k kill
Ctrl+a h log
Ctrl+a x lock
screen -r