Personal Cheat sheet
To config a ssh credential edit the config file ~/.ssh/config
as show bellow
Host {credential_name}
Hostname {ip_address}
User {username}
ssh username@{ip_address}
or with the credential
ssh {hostname}
ssh-copy-id {hostname}
ssh -L {port_to_bind_local}:localhost:{port_to_bind_remote} {hostname}
File transfert: scp {remote_Hostname}:{distant_file_path} {local_target_path}
File transfert with regex pattern: scp -r {remote_Hostname}:'{distant_file_path}{pattern}' {local_target_path}
Exemple of pattern
*.png
To get the ip address of a computer ifconfig
#!/bin/zsh
To send email from the terminal.
Show session: tmux ls
Connect to session {id}: tmux a -t {id}
Create a new session:tmux
Create a new named session: tmux new -s {name}
Press ctrl + B
and Press d
to detach. You must not hold ctrl + B
with d
sudo openconnect vpn.ulaval.ca --user={username}
or
sudo openconnect vpn.ulaval.ca -u {username}
watch -n 1 nvidia-smi
sudo /etc/init.d/cron start
sudo /etc/init.d/cron restart
See your Cron job log: sudo grep CRON /var/log/syslog
Start a new crontab: crontab -e
Log the output of the job: > ./`date +\%Y\%m\%d\%H\%M\%S`-cron.log
Alternative to Crontab
To manage your firewall setting.
python -m module1.src.file_name.script
May also need to define the PYTHONPATH variable
export PYTHONPATH=.
To run the jupyter notebook and bind it to the port 5000
jupyter notebook notebook.ipynb --port 5000
-
Start a new scrapy project
scrapy startproject {project_name}
-
Add a spider
scrapy genspider -t crawl {name} {domain}
crawl is the template used to created the spider
-
Start a scrapy shell to access variables.
scrapy shell {url}
-
Extract response variable.
response.xpath('{commnad}').extract()
-
Crawl and export into S3 bucket
scrapy crawl basic -o "s3://aws_key:aws_secret@{file_path_local}"
Get all the disk usage:
df -h
Get directory usage:
ll
Hibernate command: https://bentalbot.com/posts/creating-a-hibernate-shortcut-in-ubuntu-20.04
docker run -di -p {dockerport}:{localport} --name {nomDudocker} {image}
docker exec -it {dockername} {image}
docker run -di -p {dockerport}:{localport} --name {nomDudocker} mongo
docker exec -it {dockername} mongo
python3 -m tensorboard.main --port=8888 --logdir tensorboard
dvc remote add -d storage s3:// && dvc remote modify storage endpointurl https://s3.valeria.science && dvc remote add -f storage s3:// --local && dvc remote modify storage endpointurl https://s3.valeria.science --local && dvc remote modify storage profile --local