Output HTTP status code using curl
curl -I http://www.example.org
References
https://superuser.com/questions/272265/getting-curl-to-output-http-status-code
curl -I http://www.example.org
References
https://superuser.com/questions/272265/getting-curl-to-output-http-status-code
You can do this with inotifywait
utility from inotify-tools
package
while true ; do inotifywait -e delete_self "/tmp/fileToMonitor.txt" \ && cp new_file "/tmp/fileToMonitor.txt" done
[ "$UID" -eq 0 ] || exec sudo "$0" "$@" while true ; do inotifywait -e modify "/etc/resolv.conf" && ./dns.sh done
References
https://superuser.com/questions/939600/how-to-get-notified-when-a-specific-file-is-deleted-in-linux
https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes
http://man7.org/linux/man-pages/man1/inotifywait.1.html#EVENTS
match lines starts with default
ip route show | grep "^default"
References
https://unix.stackexchange.com/questions/59893/grep-lines-starting-with-1-in-ubuntu
cat LIST | grep -v git
ip route show | grep -v "^default"
References
https://superuser.com/questions/655715/regex-does-not-begin-by-pattern
Text between backticks is executed and replaced by the output of the command (minus the trailing newline characters, and beware that shell behaviors vary when there are NUL characters in the output). That is called command substitution because it is substituted with the output of the command.
A=`cat /etc/p2ass2wd2 | head -n1` echo "$A"
A=$(cat /etc/p2ass2wd2 | head -n1) echo "$A"
References
https://unix.stackexchange.com/questions/48392/understanding-backtick
https://unix.stackexchange.com/questions/147420/what-is-in-a-command
Displaying private IP addresses
ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/'
address=$(ip addr show wlp3s0 | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
Displaying the public IP address
If you want to know the public IP address of a Linux server, you can send an HTTP request to one of the following web servers.
curl http://checkip.amazonaws.com
wget -qO- http://checkip.amazonaws.com
References
https://unix.stackexchange.com/questions/119269/how-to-get-ip-address-using-shell-script
https://www.linuxtrainingacademy.com/determine-public-ip-address-command-line-curl/
Check size of logs
du -hs /var/log/journal/
Clear systemd journals older than X days
journalctl --vacuum-time=10d
Clear systemd journals if they exceed X storage
journalctl --vacuum-size=2G
References
https://ma.ttias.be/clear-systemd-journal/
git status
git add -A
stages all changes
git add .
stages new files and modifications, without deletions
git add -u
stages modifications and deletions, without new files
git add -A
is equivalent to git add .; git add -u
git add -A
is equivalent to git add --all
git add -u
is equivalent to git add --update
References
https://stackoverflow.com/questions/572549/difference-between-git-add-a-and-git-add
https://git-scm.com/docs/git-stage
https://git-scm.com/docs/git-add
gpg --list-secret-keys --keyid-format LONG
From the list of GPG keys, copy the GPG key ID you’d like to use. In this example, the GPG key ID is 3AA5C34371567BD2
$ gpg --list-secret-keys --keyid-format LONG /Users/hubot/.gnupg/secring.gpg ------------------------------------ sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10] uid Hubot ssb 4096R/42B317FD4BA89E7A 2016-03-10
git config --global user.signingkey 3AA5C34371567BD2
or
git commit -S -m your commit message
References
https://help.github.com/en/articles/telling-git-about-your-signing-key
https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work
https://help.github.com/en/articles/signing-commits
sudo nano /lib/systemd/system/vpnserver.service
[Unit] Description=SoftEther VPN Server After=network.target [Service] Type=forking ExecStart=/usr/local/vpnserver/vpnserver start ExecStop=/usr/local/vpnserver/vpnserver stop [Install] WantedBy=multi-user.target
sudo systemctl enable vpnserver.service
References
https://linuxconfig.org/setting-up-softether-vpn-server-on-ubuntu-16-04-xenial-xerus-linux