Skip to content

Linux ​

Directory Structure ​

Binaries/packages - /bin, /usr/bin, /usr/local/bin ​

  • /usr/bin is for distribution-managed software packages/programs.
  • /usr/local/bin is for software packages that are not managed by the distribution package manager, e.g. locally compiled software.

INFO

See this answer on Stack Exchange: /usr/bin vs /usr/local/bin on Linux

Terminal / Shell ​

explainshell ​

explainshell tool to describe part by part a command-line.

write down a command-line to see the help text that matches each argument

Distros ​

Linux Mint ​

Install Docker on Linux Mint (21) ​

As the official documentation for Ubuntu does not cover the case of Linux Mint which somehow behaves differently.

How to Install Docker on Linux Mint 21: A Step-by-Step Guide

Tips and Tricks ​

Run an executable as a Service ​

If you are using systemd, it can be used to run an executable in the background as a service.

sh
# Create a service file
sudo vim /usr/lib/systemd/system/my-service.service

Add the following content (generic example)

ini
[Unit]
Description=My Service
After=network.target

[Service]
ExecStart=/path/to/executable

[Install]
WantedBy=multi-user.target

Enable your new service, start it and check its status

sh
sudo systemctl enable my-service
sudo systemctl start my-service
sudo systemctl status my-service

Cheat Sheet ​

sh
# rsync
# (https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories)
#
# In short
rsync -az source destination

# Send a file to a remote server
rsync /path/to/source/file username@remote_host:/path/to/destination

# Send a directory to a remote server
rsync -a /path/to/source/directory username@remote_host:/path/to/destination

#  Get a file from a remote server
rsync remote_username@remote_host:/path/to/source/file /path/to/local_destination

# Options:
# -a: archive mode
# -r: recurse into directories
# -P: same as --partial + --progress (keep partially transferred files)
# https://www.digitalocean.com/community/tutorials/how-to-use-rsync-to-sync-local-and-remote-directories#using-other-rsync-options
# > This first flag provides a progress bar for the transfers,
# > and the second flag allows you to resume interrupted transfers:

Server Setup ​

SSL Certificates with Let's Encrypt and Certbot ​

One issue that can happen when trying to get a certificate:

sh
sudo certbot --nginx -d yoursite.com -d www.yoursite.com

(Source)

That can give:

sh
Another instance of Certbot is already running.
Ask for help or search for solutions at https://community.letsencrypt.org.
See the logfile /tmp/tmpufwimhau/log or re-run Certbot with -v for more details.

One possible solution here

sh
ps -ef | grep certb

The process ID would be the first number after the user, like: root 5555 5100 … To kill the process, try:

sh
kill 5555

gzip Performance ​

Improve Website performance (using Nginx)

gzip is a tool for compressing files, that will then be decompressed by the browser.

Configuring Nginx’s gzip Settings
ini
. . .
##
# `gzip` Settings
#
#
gzip on;
gzip_disable "msie6";

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_min_length 256;
gzip_types
  application/atom+xml
  application/geo+json
  application/javascript
  application/x-javascript
  application/json
  application/ld+json
  application/manifest+json
  application/rdf+xml
  application/rss+xml
  application/xhtml+xml
  application/xml
  font/eot
  font/otf
  font/ttf
  image/svg+xml
  text/css
  text/javascript
  text/plain
  text/xml;
. . .

Article from DigitalOcean - How To Improve Website Performance Using gzip and Nginx on Ubuntu 20.04