grep match lines starts with pattern
match lines starts with default
ip route show | grep "^default"
References
https://unix.stackexchange.com/questions/59893/grep-lines-starting-with-1-in-ubuntu
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
|| visible in terminal || visible in file || existing Syntax || StdOut | StdErr || StdOut | StdErr || file ==========++==========+==========++==========+==========++=========== > || no | yes || yes | no || overwrite >> || no | yes || yes | no || append || | || | || 2> || yes | no || no | yes || overwrite 2>> || yes | no || no | yes || append || | || | || &> || no | no || yes | yes || overwrite &>> || no | no || yes | yes || append || | || | || | tee || yes | yes || yes | no || overwrite | tee -a || yes | yes || yes | no || append || | || | || n.e. (*) || yes | yes || no | yes || overwrite n.e. (*) || yes | yes || no | yes || append || | || | || |& tee || yes | yes || yes | yes || overwrite |& tee -a || yes | yes || yes | yes || append
command > output.txt
The standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.
command >> output.txt
The standard output stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
command 2> output.txt
The standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, it gets overwritten.
command 2>> output.txt
The standard error stream will be redirected to the file only, it will not be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
command &> output.txt
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, it gets overwritten.
command &>> output.txt
Both the standard output and standard error stream will be redirected to the file only, nothing will be visible in the terminal. If the file already exists, the new data will get appended to the end of the file..
command | tee output.txt
The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, it gets overwritten.
command | tee -a output.txt
The standard output stream will be copied to the file, it will still be visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
command |& tee output.txt
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, it gets overwritten.
command |& tee -a output.txt
Both the standard output and standard error streams will be copied to the file while still being visible in the terminal. If the file already exists, the new data will get appended to the end of the file.
References
https://askubuntu.com/questions/420981/how-do-i-save-terminal-output-to-a-file
journalctl -f -u mystuff.service
References
https://unix.stackexchange.com/questions/475292/how-to-watch-output-from-systemd-service