systemctl
Where are service files? #
/etc/systemd/system/service-name.service
text
Start at Boot #
sudo systemctl enable sshd.service
bash
disable
is the opposite.
Use Environment in Service Unit File #
[Service]
Environment=PATH=/home/pi/.local/bin:/home/pi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ini
Note
$PATH
do not have its special meaning here.https://askubuntu.com/questions/1014480/how-do-i-add-bin-to-path-for-a-systemd-service for advanced.
Unit File Template #
Click to expand
[Unit]
Description=Jupyter Notebook
[Service]
Type=simple
PIDFile=/run/jupyter.pid
Environment=PATH=/home/pi/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ExecStart=jupyter lab --config=/home/pi/.jupyter/jupyter_notebook_config.py
User=pi
Group=pi
WorkingDirectory=/home/pi/Notebooks/
Restart=always
RestartSec=10
#KillMode=mixed
[Install]
WantedBy=multi-user.target
ini
Exited Without Error Log? #
Use journalctl
command. e.g.
journalctl -u service-name.service
bash
-u
is short for --unit
. More useful options:
-f
,--follow
: Show only the most recent journal entries, and continuously print new entries as they are appended to the journal.-r
,--reverse
: Reverse output so that the newest entries are displayed first.
apt
List All Versions #
https://askubuntu.com/questions/473886/list-all-versions-of-a-package
apt-cache madison chromium-browser
# or
apt-cache showpkg lyx
bash
Install Specific Version #
https://askubuntu.com/questions/428772/how-to-install-specific-version-of-some-package
# get version of installed package
apt-cache policy <package name>
# install a specific package version
sudo apt-get install <package name>=<version>
bash
OS Release Info #
cat /etc/os-release
bash
List All Users #
less /etc/passwd
bash
lsof
LiSt Open Files. A very powerful tool.
For network checking:
ls -i [46][protocol][@hostname|hostaddr][:service|port]
text
e.g.
sudo lsof -i :80
shell
find
find -iname 'qwerty'
find dir/ -iname 'qwerty'
find -name 'Qwerty'
bash
No Wireless Connection After Sleep #
sudo service network-manager restart
bash