aliases

nano ~/.bashrc
source ~/.bashrc
alias home=”ssh -i /etc/ssh/azuredp chainer@13.66.198.140”
alias ll="ls -alF"

openssl rand -base64 12

ssh-copy-id -i id_rsa.pub user@146.190.17.136

copy ssh

scp -r /path/to/local/dir root@remotehost:/path/to/remote/dir

$ rsync -azu -e 'ssh -i ./pem_for_target_server.pem -p <port_number_for_target_server>' /folder/path/on/source username_on_target@target.server.name:/path/on/target/where/you/want/to/copy/folder/on/source/

scp -r remotehost:/etc/letsencrypt/live/kbchainer2.devops.rebrain.srwx.net/ /home/chainer/cert/

chainer@BEZRUCHENKOVK:~/git/ansible$ scp -r -i /etc/ssh/teraf root@161.35.135.222:/etc/letsencrypt/live/kbchainer2.devops.rebrain.srwx.net/ /home/chainer/cert/

generate key

ssh-keygen -t rsa -C "your_email@example.com"

nohup

 nohup flask run -h 0.0.0.0 > /dev/null 2>&1 &

and with ssh remote BG launch

ssh -n -f user@host "sh -c 'cd /whereever; nohup ./whatever > /dev/null 2>&1 &'"

known_hosts

ssh-keyscan -H 192.168.1.162 >> ~/.ssh/known_hosts

systemd service flask py web app

/etc/systemd/system/myproject.service

[Unit]
Description=Gunicorn instance to serve myproject
After=network.target

[Service]
User=sammy
Group=www-data
WorkingDirectory=/home/sammy/myproject
Environment="PATH=/home/sammy/myproject/myprojectenv/bin"
ExecStart=/home/sammy/myproject/myprojectenv/bin/gunicorn --workers 3 --bind unix:myproject.sock -m 007 wsgi:app

[Install]
WantedBy=multi-user.target

With that, our systemd service file is complete. Save and close it now.

We can now start the Gunicorn service we created and enable it so that it starts at boot:

sudo systemctl start myproject
sudo systemctl enable myproject

run as another user

sudo -H -u otheruser bash -c 'echo "I am $USER, with uid $UID"' 

own a folder

sudo chown -R $USER: .
ls -lah aksjghdkh ./ > /dev/null && echo OK || echo KO

b1
b2
b3
b4
rm all

rm ./*
find . -name "name*"-execrm{} \;

find file context

grep -rnw '/path/to/somewhere/'-e 'pattern'
echo $?  /// signal

AWK

awk options 'selection _criteria {action }' input-file > output-file

sed

sed -i'' "s/10.3.243.101/164.90.198.228/g" ./deploy/deployment.yaml