Skip to content

Instantly share code, notes, and snippets.

@nojaf
Last active January 6, 2019 16:26
Show Gist options
  • Save nojaf/c455750080af598733f7b896a828f509 to your computer and use it in GitHub Desktop.
Save nojaf/c455750080af598733f7b896a828f509 to your computer and use it in GitHub Desktop.
linux commands
# Nginx
sudo ln -s /etc/nginx/sites-available/example.com /etc/nginx/sites-enabled/example.com
sudo nginx -t
sudo service nginx restart
# MySQL
sudo mysql --user=myuser --password=mypassword mydb
# Find bash shell
echo $SHELL
# grep
## find in files, http://explainshell.com/explain?cmd=grep+-rnw+%27%2Fpath%2Fto%2Fsomewhere%2F%27+-e+%22pattern%22
grep -rnw '/path/to/somewhere/' -e "pattern"
# upload & download
## download: remote -> local
scp user@remote_host:remote_file local_file
## ssh
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa
## run remote command with ssh
ssh [email protected] 'bash ~/scripts/myscript.sh'
apache2ctl configtest
# firewall
sudo ufw status
## add rule
sudo ufw allow from 78.20.198.50 to any port 3306 proto tcp
## upload: local -> remote
scp local_file user@remote_host:remote_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment