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 [2019/04/14 08:44] – [Basic commands 101] Júne Park | debian_common [2024/04/18 07:49] – [Upgrade & Maintenance] Júne Park | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
* {{fa> | * {{fa> | ||
- | * [[: | + | * [[: |
* [[: | * [[: | ||
* [[: | * [[: | ||
* [[: | * [[: | ||
- | * [[: | + | * [[: |
* [[: | * [[: | ||
+ | * [[: | ||
+ | * [[: | ||
* {{fa> | * {{fa> | ||
- | * [[: | + | * [[: |
* [[: | * [[: | ||
* [[: | * [[: | ||
Line 14: | Line 16: | ||
* [[: | * [[: | ||
* {{fa> | * {{fa> | ||
- | * [[: | + | * [[: |
* [[: | * [[: | ||
* [[: | * [[: | ||
+ | * [[: | ||
* [[: | * [[: | ||
* [[: | * [[: | ||
Line 22: | Line 25: | ||
</ | </ | ||
- | ===== 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 50: | 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 145: | Line 288: | ||
---- | ---- | ||
+ | === 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 === | ||
Line 274: | Line 429: | ||
---- | ---- | ||
+ | |||
+ | ===== Disable unused settings ===== | ||
==== Disable suspend mode ==== | ==== Disable suspend mode ==== | ||
Line 309: | Line 466: | ||
---- | ---- | ||
- | ==== Debugging service | + | |
+ | ==== Disable power wireless off ==== | ||
<code bash> | <code bash> | ||
- | sudo service stop sshd # ssd daemon for example | + | sudo iwconfig wlan0 power off |
- | / | + | |
</ | </ | ||
- | |||
- | Find problem from messages in debugging mode. | ||
---- | ---- | ||
- | ==== Delete unnecessary files regularly | + | ==== Disable Bluetooth service |
- | '' | + | |
- | <code bash> | + | <code bash> |
- | 30 */6 * * * /usr/bin/find /..((your path)).../ -name '*.nfo' | + | vi /etc/bluetooth/main.conf |
- | </ | + | </code> |
+ | |||
+ | Edit the line with '' | ||
+ | <code ini> | ||
+ | AutoEnable = false | ||
+ | </ | ||
- | Delete empty directory at 30 minutes past every 12 hours | + | A more radical way is to either stop the bluetooth service |
<code bash> | <code bash> | ||
- | 30 */12 * * * / | + | sudo systemctl stop bluetooth.service |
</ | </ | ||
+ | |||
+ | Or even more radical is to disable it permanently | ||
+ | <code bash> | ||
+ | sudo systemctl disable bluetooth | ||
+ | </ | ||
---- | ---- | ||
- | ==== Delete all files except for desired file types ==== | + | ==== Debugging service |
<code bash> | <code bash> | ||
- | find . -type f ! -name ' | + | sudo service stop sshd # ssd daemon for example |
- | </ | + | / |
+ | </ | ||
+ | |||
+ | Find problem from messages in debugging mode. | ||
---- | ---- | ||
- | ==== Disable power wireless off ==== | + | |
+ | ==== Configure locales | ||
<code bash> | <code bash> | ||
- | | + | |
</ | </ | ||
+ | |||
+ | Deselect unused '' | ||
---- | ---- | ||
- | ==== User defined command alias ==== | ||
- | If you don't have '' | + | |
+ | |||
+ | |||
+ | ===== Install Services ===== | ||
+ | |||
+ | ==== Nextcloud™ ==== | ||
+ | |||
+ | [[os_nextcloud|Nextcloud 101]] --- Nextcloud user's Guides | ||
+ | |||
+ | ---- | ||
+ | |||
+ | ==== 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> | ||
- | touch .bash_aliases | + | sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove |
</ | </ | ||
- | '' | + | Upgrade with major LTS with |
<code bash> | <code bash> | ||
- | alias backup_nginx=' | + | sudo do-release-upgrade |
</ | </ | ||
+ | |||
+ | 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 ' | ||
+ | or your package manager. | ||
+ | </ | ||
---- | ---- | ||
+ | |||
==== Fetch error during update ==== | ==== Fetch error during update ==== | ||
Line 378: | Line 576: | ||
---- | ---- | ||
+ | ==== 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 | ||
+ | </ | ||
+ | |||
+ | |||
+ | ---- | ||
+ | ==== Install & upgrade Nginx ==== | ||
+ | |||
+ | 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> | ||
+ | echo "deb http:// | ||
+ | | sudo tee / | ||
+ | </ | ||
+ | |||
+ | If you would like to use mainline nginx packages, run the following command instead: | ||
+ | |||
+ | <code bash> | ||
+ | echo "deb http:// | ||
+ | | sudo tee / | ||
+ | </ | ||
+ | |||
+ | Next, import an official nginx signing key so apt could verify the packages authenticity: | ||
+ | |||
+ | <code bash> | ||
+ | curl -fsSL https:// | ||
+ | </ | ||
+ | |||
+ | 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 415: | Line 759: | ||
---- | ---- | ||
- | === [output to file] === | ||
- | | | visible | + | === find string(s) |
- | | syntax | '' | + | |
- | | ''>'' | + | |
+ | <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. | 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. | 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. | 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. | 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. | 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.. | 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. | 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. | 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?" | 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. | 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. | 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. | ||
- | |||
---- | ---- | ||
+ | |||
+ |