Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux (Ubuntu) Cheatsheet #81

Open
AllanChain opened this issue Apr 18, 2020 · 0 comments
Open

Linux (Ubuntu) Cheatsheet #81

AllanChain opened this issue Apr 18, 2020 · 0 comments
Labels
blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post

Comments

@AllanChain
Copy link
Owner

AllanChain commented Apr 18, 2020

View Post on Blog

Useful commands and tips about system operation. Things more about scripting are in Bash Cheatsheet


systemctl

Where are service files?

/etc/systemd/system/service-name.service

Start at Boot

sudo systemctl enable sshd.service

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

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

Exited Without Error Log?

From https://unix.stackexchange.com/questions/225401/how-to-see-full-log-from-systemctl-status-service/225407

Use journalctl command. e.g.

journalctl -u service-name.service

-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

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>

OS Release Info

cat /etc/os-release

List All Users

less /etc/passwd

lsof

LiSt Open Files. A very powerful tool.

For network checking:

ls -i [46][protocol][@hostname|hostaddr][:service|port]

e.g.

sudo lsof -i :80

find

find -iname 'qwerty'
find dir/ -iname 'qwerty'
find -name 'Qwerty'

No Wireless Connection After Sleep

sudo service network-manager restart
@AllanChain AllanChain changed the title Linux (Ubuntu) | AC's Blog Linux (Ubuntu) Cheatsheet Jun 30, 2020
@AllanChain AllanChain added blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post labels Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blog: cheatsheet |108686978-1ae51480-7531-11eb-93c7-d201146b237d.jpg @post This is a blog post
Projects
None yet
Development

No branches or pull requests

1 participant