How-to bash

Put files and directory rights to default values

find ../492A-5B6E/ \( -type f -execdir chmod 644 {} \; \) -o \( -type d -execdir chmod 755 {} \; \)
find where_to_search/ -name name_directory -type d

Look (grep) for utf8 characters in files

grep --color='auto' -P -n "[\x80-\xFF]" file

Rename files (extensions)

rename 's/\.cxx$/.cpp/' *.cxx

Idem inside the text (like “includes” in C++)

grep -rl '\.cxx' ./ | xargs sed -i 's/\.cxx/\.cpp/g'

Copy with a progression bar (and more)

rsync -av --delete-after --stats --progress to_save/ rep_where_to_save/

The options are:

Vim command to search and replace in several files

:args *.cpp *.h
:bufdo %s/pattern/replace/g | update

Generate public and private ssh keys

ssh-keygen -t rsa

Give a name like “id_rsa_foo” and you get two files:

Then copy the public key on the remote machine:

scp username@remotemachine:/home/username/.ssh/

Add the key to the authorized host file:

cat >> authorized_hosts

Make a config file for ssh

In .ssh/, create a file named “config” and add a profile to make it easy to connect via ssh.

Host remMach
	HostName remoteMachineName
	User username
	IdentityFile ~/.ssh/id_rsa_foo
	ProxyCommand ssh remoteMachineName nc %h %p

Or even simpler depending on the case:

Host remMach
	User username
	PubkeyAuthentication no

Then to connect instead of:

scp -r .

one can use:

ssh username@remMach
scp -r username@remMach:/mnt/home/username/dir/ .

Create a torrent file

transmission-create -o ~/torrent_name.torrent -t udp:// -t udp:// -t udp:// -p -c "comment"

Different tracker addresses can be used, but beware what you share.

Download a website

wget -r -l5 -k -E ""

Add the option -c to restart an incomplete download, or the option -np to avoid going up the directory tree to download a single page.