Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux_commands [2020/04/09 14:33] – created misaka00251linux_commands [2022/03/02 15:14] (current) – Add tmux misaka00251
Line 1: Line 1:
 ====== Linux Commands ====== ====== Linux Commands ======
 +
 +===== tmux =====
 +
 +
 +<code>
 +tmux new -s build
 +tmux detach            # or Ctrl+b d
 +tmux ls
 +tmux attach -t 0
 +tmux kill-session -t 0
 +tmux switch -t 0
 +tmux rename-session -t 0 <new_name>
 +</code>
 +
 +To create a new tab, ''Ctrl+b c''.
 +
 +Switch between tabs, ''Ctrl+b <tab_number>''.
  
 ===== Copy ===== ===== Copy =====
Line 11: Line 28:
   * ''-a'' make a backup. Don't rely on it!   * ''-a'' make a backup. Don't rely on it!
   * ''-p'' Keep the properties of this file.   * ''-p'' Keep the properties of this file.
 +
 +===== Systemd =====
 +
 +A sample service file:
 +
 +<code - gitea.service>
 +[Unit]
 +Description=Gitea (Git with a cup of tea)
 +After=syslog.target
 +After=network.target
 +#After=mysqld.service
 +#After=postgresql.service
 +#After=memcached.service
 +#After=redis.service
 +
 +[Service]
 +#LimitMEMLOCK=infinity
 +#LimitNOFILE=65535
 +RestartSec=2s
 +Type=simple
 +User=git
 +Group=git
 +WorkingDirectory=/home/git
 +ExecStart=/usr/local/bin/gitea web -c /etc/gitea/app.ini
 +Restart=always
 +#Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/home/git
 +
 +[Install]
 +WantedBy=multi-user.target
 +</code>
 +
 +So, the right way to implement ''Environment'' is to run ''systemctl edit myservice''.
 +
 +In normal installations this will create a directory ''/etc/systemd/system/myservice.service.d'', and inside that directory create a file whose name ends in ''.conf'' (typically, ''override.conf''), and in this file you can add to or override any part of the unit shipped by the distribution.
 +
 +For instance, in a file /etc/systemd/system/myservice.service.d/myenv.conf:
 +
 +<code>
 +[Service]
 +Environment="USER=git"
 +Environment="HOME=/home/git"
 +Environment="GITEA_WORK_DIR=/home/git"
 +</code>
 +
 +Also note that if the directory exists and is empty, your service will be disabled! If you don't intend to put something in the directory, ensure that it does not exist.
 +
 +[[https://serverfault.com/questions/413397/how-to-set-environment-variable-in-systemd-service|Copied from here]].