Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
debian_common [2018/08/12 18:07] – [Configure Dynamic DNS] Júne Park | debian_common [2024/04/18 07:48] – [Install Services] Júne Park | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | * {{fa> | + | * {{fa> |
+ | * [[: | ||
* [[: | * [[: | ||
* [[: | * [[: | ||
* [[: | * [[: | ||
- | * [[:rpi_common|General | + | * [[:debian_common|■ General |
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * {{fa> | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * {{fa> | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
</ | </ | ||
- | ===== General info on Debian | + | ====== General info on Debian |
{{: | {{: | ||
---- | ---- | ||
- | ==== Initial steps freshly | + | ===== Initial steps ===== |
- | === Enable SSH === | + | ==== Watchlist for backup ==== |
- | Genesis step for all {{fa>linux}} Linux works. | + | <code bash> |
+ | / | ||
+ | / | ||
+ | / | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | **update-motd** | ||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | **crontab** | ||
+ | <code bash> | ||
+ | sudo crontab -l | ||
+ | sudo -u www-data crontab -l | ||
+ | crontab -l | ||
+ | </ | ||
+ | |||
+ | **MariaDB** '' | ||
+ | === Backup MariaDB DATABASE === | ||
+ | |||
+ | <code bash> | ||
+ | / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === Backup using rsync command === | ||
+ | |||
+ | == Backup Nginx configuration files == | ||
+ | <code bash> | ||
+ | sudo rsync -avh --progress / | ||
+ | </ | ||
+ | |||
+ | == Backup HTML source files == | ||
+ | <code bash> | ||
+ | sudo rsync -avh --progress /var/www/ / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | === Remote backup for webpages === | ||
+ | Rsync with '' | ||
+ | <code bash> | ||
+ | sudo -u www-data rsync -azP --exclude ' | ||
+ | </ | ||
+ | Put '' | ||
+ | |||
+ | ---- | ||
+ | ==== Configure log files ==== | ||
+ | |||
+ | Edit ''/ | ||
+ | <code nginx> | ||
+ | access_log / | ||
+ | error_log / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | ==== Purge log files ==== | ||
+ | |||
+ | == Cleaning compressed log files == | ||
+ | <code bash> | ||
+ | sudo find /var/log -name ' | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Set hostnames ==== | ||
+ | |||
+ | <code bash> | ||
+ | sudo hostname HOSTiD | ||
+ | sudo hostnamectl HOSTiD | ||
+ | </ | ||
+ | |||
+ | Edit ''/ | ||
+ | |||
+ | <code bash> | ||
+ | hostid.mydomain.com | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | ==== Enable SSH ==== | ||
+ | |||
+ | Genesis step for all {{mdi>debian?2x}} Linux works. | ||
---- | ---- | ||
Line 35: | Line 136: | ||
Append '' | Append '' | ||
+ | |||
+ | --- | ||
+ | |||
+ | === SSH Key to ED25519 === | ||
+ | |||
+ | <code bash> | ||
+ | ssh-keygen -o -a 100 -t ed25519 -f ~/ | ||
+ | </ | ||
+ | |||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | |||
+ | --- | ||
+ | |||
+ | ==== Enable colorful terminal ==== | ||
+ | |||
+ | Comment out **'' | ||
+ | |||
+ | <code bash> | ||
+ | vi ~/ | ||
+ | source ./ | ||
+ | </ | ||
+ | |||
+ | === Time stamp prompt === | ||
+ | |||
+ | Edit '' | ||
+ | |||
+ | <code bash> | ||
+ | if [ " | ||
+ | PS1=' | ||
+ | else | ||
+ | PS1=' | ||
+ | fi | ||
+ | </ | ||
+ | |||
+ | Save and load '' | ||
+ | |||
+ | <code bash> | ||
+ | source ~/ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== User aliases command ==== | ||
+ | |||
+ | If you don't have '' | ||
+ | <code bash> | ||
+ | touch .bash_aliases | ||
+ | </ | ||
+ | |||
+ | '' | ||
+ | |||
+ | <code bash> | ||
+ | alias backup_nginx=' | ||
+ | </ | ||
---- | ---- | ||
- | ==== Configure Dynamic DNS ==== | + | ===== Configure Dynamic DNS ===== |
=== Google Domains with ddclient === | === Google Domains with ddclient === | ||
Line 76: | Line 234: | ||
=== Cloudflare with ddclient === | === Cloudflare with ddclient === | ||
- | Assume you already installed '' | + | Assume you already installed '' |
It require a package '' | It require a package '' | ||
Line 110: | Line 268: | ||
---- | ---- | ||
- | |||
=== FreeDNS with ddclient === | === FreeDNS with ddclient === | ||
+ | Edit ''/ | ||
+ | |||
+ | <code ini> | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | Add '' | ||
+ | |||
+ | <code bash> | ||
+ | sudo crontab -e | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | === NO-IP with ddclient === | ||
+ | |||
+ | <code ini> | ||
+ | protocol=dyndns2 | ||
+ | server=dynupdate.no-ip.com | ||
+ | login=your_login_id | ||
+ | password=your_password | ||
+ | your_domain.com | ||
+ | </ | ||
+ | |||
+ | ---- | ||
=== Google Domains with API === | === Google Domains with API === | ||
+ | Create '' | ||
+ | |||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | |||
+ | ### Google Domains provides an API to update a DNS " | ||
+ | ### updates a record with the script-runner' | ||
+ | ### lookup. | ||
+ | ### | ||
+ | ### Google Dynamic DNS: https:// | ||
+ | ### Synthetic Records: https:// | ||
+ | |||
+ | USERNAME=" | ||
+ | PASSWORD=" | ||
+ | HOSTNAME=" | ||
+ | |||
+ | # Resolve current public IP | ||
+ | IP=$( dig +short myip.opendns.com @resolver1.opendns.com ) | ||
+ | # Update Google DNS Record | ||
+ | URL=" | ||
+ | curl -s $URL | ||
+ | </ | ||
+ | |||
+ | ---- | ||
=== Cloudflare with API === | === Cloudflare with API === | ||
Line 216: | Line 426: | ||
Then the script runs every 3 hours. \\ | Then the script runs every 3 hours. \\ | ||
- | | + | |
---- | ---- | ||
+ | |||
+ | ===== Disable unused settings ===== | ||
==== Disable suspend mode ==== | ==== Disable suspend mode ==== | ||
Line 254: | Line 466: | ||
---- | ---- | ||
+ | |||
+ | ==== Disable power wireless off ==== | ||
+ | |||
+ | <code bash> | ||
+ | sudo iwconfig wlan0 power off | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== Disable Bluetooth service ==== | ||
+ | |||
+ | <code bash> | ||
+ | vi / | ||
+ | </ | ||
+ | |||
+ | Edit the line with '' | ||
+ | <code ini> | ||
+ | AutoEnable = false | ||
+ | </ | ||
+ | |||
+ | A more radical way is to either stop the bluetooth service | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl stop bluetooth.service | ||
+ | </ | ||
+ | |||
+ | Or even more radical is to disable it permanently | ||
+ | <code bash> | ||
+ | sudo systemctl disable bluetooth | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
==== Debugging service ==== | ==== Debugging service ==== | ||
Line 265: | Line 510: | ||
---- | ---- | ||
- | ==== Delete unnecessary files regularly | + | ==== Configure locales |
- | '' | + | |
- | <code bash> | + | <code bash> |
- | 30 */6 * * * / | + | sudo dpkg-reconfigure locales |
- | </ | + | </ |
- | Delete empty directory at 30 minutes past every 12 hours | + | Deselect unused '' |
- | <code bash> | + | ---- |
- | 30 */12 * * * / | + | |
- | </ | + | |
+ | ===== Upgrade & Maintenance ===== | ||
+ | |||
+ | ===== Install Services ===== | ||
+ | |||
+ | ==== Nextcloud™ ==== | ||
+ | |||
+ | [[os_nextcloud|Nextcloud 101]] --- Nextcloud user's Guides | ||
---- | ---- | ||
- | ==== Delete all files except for desired file types ==== | + | ==== Major LTS upgrade |
+ | |||
+ | Upgrade from 18.04 LTS to 20.04 LTS ('' | ||
+ | |||
+ | Official Guide on upgrade [[https:// | ||
+ | |||
+ | === Upgrade on the command line === | ||
+ | |||
+ | Update all repository for packages, which already installed on the system. | ||
<code bash> | <code bash> | ||
- | find . -type f ! -name '*.mkv' -delete | + | sudo apt update && sudo apt dist-upgrade |
- | </ | + | </ |
+ | |||
+ | Upgrade with major LTS with | ||
+ | |||
+ | <code bash> | ||
+ | sudo do-release-upgrade -d | ||
+ | </ | ||
+ | |||
+ | Follow the procedures and finish. | ||
+ | |||
+ | <code text> | ||
+ | Some third party entries in your sources.list were disabled. You can | ||
+ | re-enable them after the upgrade with the 'software-properties' | ||
+ | or your package manager. | ||
+ | </ | ||
---- | ---- | ||
- | ==== Disable power wireless off ==== | + | |
+ | ==== Fetch error during update | ||
+ | |||
+ | Error during update --- '' | ||
<code bash> | <code bash> | ||
- | sudo iwconfig wlan0 power off | + | sudo apt-get clean |
+ | sudo rm -vf / | ||
+ | sudo rm -vf / | ||
+ | sudo apt-get update | ||
</ | </ | ||
+ | |||
+ | Run '' | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== Upgrade php 7.x ==== | ||
+ | |||
+ | Append additional source for php7.x latest, | ||
+ | <code bash> | ||
+ | sudo apt install software-properties-common | ||
+ | sudo add-apt-repository ppa: | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | wget -q https:// | ||
+ | echo "deb https:// | ||
+ | </ | ||
+ | |||
+ | Append '' | ||
+ | |||
+ | <code bash> | ||
+ | sudo add-apt-repository ppa: | ||
+ | </ | ||
+ | |||
+ | Update source lists | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get update | ||
+ | </ | ||
+ | |||
+ | <code text> | ||
+ | Reading package lists... Done | ||
+ | E: The method driver / | ||
+ | N: Is the package apt-transport-https installed? | ||
+ | E: Failed to fetch https:// | ||
+ | E: Some index files failed to download. They have been ignored, or old ones used instead. | ||
+ | </ | ||
+ | |||
+ | When it comes to this errors, install additional packages for update, | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install ca-certificates apt-transport-https | ||
+ | </ | ||
+ | |||
+ | Install php with latest version | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install php7.2 php7.2-cli php7.2-common php7.2-opcache php7.2-curl php7.2-mbstring php7.2-mysql php7.2-zip php7.2-xml | ||
+ | </ | ||
+ | |||
+ | To verify the installation is completed run the following command: | ||
+ | |||
+ | <code bash> | ||
+ | php -v | ||
+ | </ | ||
+ | |||
---- | ---- | ||
- | ==== User defined command alias ==== | + | ==== Install & upgrade Nginx ==== |
- | If you don't have '' | + | Install the prerequisites: |
+ | |||
+ | <code bash> | ||
+ | sudo apt install curl gnupg2 ca-certificates lsb-release | ||
+ | </ | ||
+ | |||
+ | To set up the apt repository for stable nginx packages, run the following command: | ||
<code bash> | <code bash> | ||
- | touch .bash_aliases | + | echo "deb http:// |
+ | | sudo tee / | ||
</ | </ | ||
- | '' | + | If you would like to use mainline nginx packages, run the following command instead: |
<code bash> | <code bash> | ||
- | alias backup_nginx=' | + | echo "deb http:// |
+ | | sudo tee /etc/apt/sources.list.d/nginx.list | ||
+ | </code> | ||
+ | |||
+ | Next, import an official nginx signing key so apt could verify the packages authenticity: | ||
+ | |||
+ | <code bash> | ||
+ | curl -fsSL https://nginx.org/keys/nginx_signing.key | sudo apt-key add - | ||
+ | </code> | ||
+ | |||
+ | Verify that you now have the proper key: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-key fingerprint ABF5BD827BD9BF62 | ||
+ | </ | ||
+ | |||
+ | The output should contain the full fingerprint | ||
+ | |||
+ | <code txt> | ||
+ | pub | ||
+ | 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62 | ||
+ | uid [ unknown] nginx signing key < | ||
+ | </ | ||
+ | |||
+ | To install nginx, run the following commands: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt update | ||
+ | sudo apt install nginx | ||
</ | </ | ||
---- | ---- | ||
+ | ==== Upgrade mariadb ==== | ||
+ | |||
+ | <button type=" | ||
+ | |||
+ | Select '' | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt-get install software-properties-common | ||
+ | sudo apt-key adv --fetch-keys ' | ||
+ | sudo add-apt-repository 'deb [arch=amd64, | ||
+ | </ | ||
+ | |||
+ | Once the key is imported and the repository added you can install MariaDB 10.5 from the MariaDB repository with: | ||
+ | |||
+ | <code bash> | ||
+ | sudo apt update | ||
+ | sudo apt install mariadb-server | ||
+ | </ | ||
+ | |||
+ | Check service is working correctly and installed version. | ||
+ | |||
+ | <code bash> | ||
+ | sudo mysql -uroot -p | ||
+ | </ | ||
+ | |||
+ | Alternatively, | ||
+ | |||
+ | < | ||
+ | # MariaDB 10.5 repository list - created 2020-08-31 04:34 UTC | ||
+ | # http:// | ||
+ | deb [arch=amd64] https:// | ||
+ | deb-src https:// | ||
+ | </ | ||
+ | |||
+ | If you need debug packages, add the debug component to your sources.list with: | ||
+ | |||
+ | <code bash> | ||
+ | sudo add-apt-repository 'deb [arch=amd64, | ||
+ | </ | ||
+ | |||
+ | MariaDB debug packages will now show up when searching for ' | ||
+ | |||
+ | ---- | ||
==== Basic commands 101 ==== | ==== Basic commands 101 ==== | ||
- | {{fa> | + | {{fa> |
=== rm === | === rm === | ||
Line 345: | Line 759: | ||
---- | ---- | ||
+ | |||
+ | === find string(s) in files === | ||
+ | |||
+ | <code bash> | ||
+ | find / | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === [output to file] === | ||
+ | |||
+ | | | visible in terminal | ||
+ | | syntax | ||
+ | | | | | | | | | ||
+ | | ''>'' | ||
+ | | ''>>'' | ||
+ | | '' | ||
+ | | '' | ||
+ | | ''&>'' | ||
+ | | ''&>>'' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | | | | | | | | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | command &>> | ||
+ | </ | ||
+ | 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.. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | (*) | ||
+ | </ | ||
+ | Bash has no shorthand syntax that allows piping only StdErr to a second command, which would be needed here in combination with tee again to complete the table. If you really need something like that, please look at "How to pipe stderr, and not stdout?" | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | <code bash> | ||
+ | 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. | ||
+ | |||
+ | ---- | ||
+ | |||
+ |