Linux-tips

Last updated: 2023-02-23

# sudo no password
echo "$(whoami)" ALL=(ALL) NOPASSWD:ALL >> /etc/sudoers
# copy ssh keys
ssh-copy-id -i ~/.ssh/id_rsa.pub user@host
ssh-copy-id -f -i ~/.ssh/id_rsa.pub user@host # force add without checking if key exists
# not fancy way
ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub

VIM

# delete a world: `daw`
# delete a sentence: `das`
#  __d__elete, __y__ank, __c__hange, > (indent in)
# b for before, e for end, a for append, i for insert.
# caw - perform the c operator on the aw text object (ergo, change the "a word" that the cursor is currently on).
# dd for delete line, yy for copy line, cc for change line
# >> for align line right, << for align line left
# :%s/old/new/g for replace all
# :%s/old/new/gc for replace all with confirm
# :%s/old/new/gcI for replace all with confirm and ignore case
# BdW (go to first whitespace delete to next whitespace)
# bdw, back delete word.
# Scroll: Ctrl-u (up), Ctrl-d (down)
# Find: f{character}, t{character}, F{character}, T{character}
# find/to forward/backward {character} on the current line
# , / ; for navigating matches
# Search: /{regex}, n / N for navigating matches
# %s/foo/bar/g replace foo with bar globally in file
# To switch to the right window, press “Ctrl + w”, then “l”. To go to the left window, it's “Ctrl + w”, then “h”. If you did a horizontal split, then going up and down is necessary. For going up, press “Ctrl + w”, then “k”. For going down, press “Ctrl + w”, then “j”.
# set :nu for line numbers

BASH

Last updated

Was this helpful?