https://askubuntu.com/questions/1349900/duplicate-system-path-variable-snap-bin-snap-bin
- Start on boot
sudo systemctl enable <service>
- Disable perminent
sudo systemctl disable <service>
- Start (reset after login)
sudo systemctl start <service>
- Remove greeting
set -U fish_greeting
- Print current OS type
$(uname)
- Print status code
$status
(in bash, it's$?
- Set
$EDITOR
togedit
to be used when ranfunced
- Break long-line command
Alt+Enter
- print default shell
echo $SHELL
- list all shells installed
cat /etc/shells
- change default shell
chsh -s /usr/bin/fish
(remember to log out to see effect)
- Check authentication method for each MySQL user accounts
SELECT user,authentication_string,plugin,host FROM mysql.user;
- Create new user
CREATE USER 'sammy'@'localhost' IDENTIFIED WITH caching_sha2_password BY 'password';
- Change user auth method
ALTER USER 'sammy'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
- Grant privileges
GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;
- Check
systemctl is-active <service_name>
ip a
ip addr show <network_interface> | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
-
Enable
sudo ufw enable
-
Disable
sudo ufw disable
-
Reset
sudo ufw reset
(fresh start, disable and remove all custom rules) -
Check status
sudo ufw status [verbose] [numbered]
-
Allow/Deny
sudo ufw allow/deny <port>
-
Allow/Deny by name defined in
/etc/services
sudo ufw allow/deny <service_name>
-
Delete by number
sudo ufw delete <num>
-
Delete by actual rule
sudo ufw delete allow ssh
Ref: https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-22-04
- Begin SSH-ing
ssh <user-name>@<ip address>
- Enable service
sudo systemctl start ssh
- Check service
sudo systemctl status ssh
- Disable service
sudo systemctl disable --now ssh
- Re-enable service
sudo systemctl enable --now ssh
- Restart service
sudo systemctl restart ssh
- Open SSH port via ufw
sudo ufw allow ssh
- Generate SSH key
ssh-keygen -t rsa -b 4096 -C "some comment"
(ssh-keygen
generate default RSA-3072) - Automatic add SSH key
ssh-copy-id <user_name>@<server_IPaddress>
- Manual add SSH key
cat ~/.ssh/id_rsa.pub | ssh user_name@server_ipaddress "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"
- Check SSH key
ls ~/.ssh/id_*
- Disable SSH password authentication
In sshd_config, set PasswordAuthentication no
Ref:
- https://linuxize.com/post/how-to-enable-ssh-on-ubuntu-20-04/
- https://linuxize.com/post/using-the-ssh-config-file/
- sshd_config file setup https://serverfault.com/a/994935
- client config file setup https://linuxize.com/post/using-the-ssh-config-file/
- permission denied (publickey) error https://www.tecmint.com/ssh-permission-denied-publickey/
Prefix hotkey Ctrl+b
-
List running sessions
tmux ls (or tmux list-sessions)
-
New session with name
tmux new -s <session-name>
-
Attach to session
tmux attach -t <session-name>
-
Kill session
tmux kill-session -t <session-name>
-
Detach from session
Ctrl+b then D
-
Create new win
Ctrl+b then C
-
Cycle prev win
Ctrl+b then P
-
Cycle next win
Ctrl-b then N
-
Kill current win
Ctrl-b then &
(or justexit
) -
Manual select wins
Ctrl-b then W
-
Rename
Ctrl-b then ,
-
Split ver
Ctrl-b then %
-
Split hor
Ctrl-b then "
-
List keybindings
Ctrl-b then ?
-
Type command
Ctrl-b then :
(e.g. to split var, usesplit-screen
, to split hor, usesplit
Ref: https://gist.github.com/andreyvit/2921703
- Clone a specific tag
git clone --depth 1 --branch <tag_name> <repo_url>
NOTE:--depta 1
is optional, only used when need the state at the 1 revision, no download history. Some people downloads whole history for nothing :v Ref: https://stackoverflow.com/a/24102558
https://superuser.com/questions/183870/difference-between-bashrc-and-bash-profile/183980#183980 (24/08/23)
https://stackoverflow.com/questions/42757236/what-does-mean-in-bash (23/08/23)
https://stackoverflow.com/questions/40747576/need-help-understanding-a-strange-bashrc-expression (23/08/23)
- Update
flatpak update
- The rest https://docs.flatpak.org/en/latest/using-flatpak.html#the-flatpak-command
- Search
snap find <package_name>
- Install
sudo snap install <package_name>
- List install
snap list
- List install + Old package
snap list --all (reveal old ver marked as disabled)
- Get info
snap info <package_name>
- Uninstall
sudo snap remove <package_name> --purge
- Uninstall + Delete snap shot
sudo snap remove <package_name> --purge
- Uninstall disabled package
sudo snap remove <package_name> --revision=<rev name>
- Desktop entry files
~/.local/share/applications
https://askubuntu.com/questions/3167/what-is-difference-between-the-options-autoclean-autoremove-and-clean
-sudo apt remove --purge <package_name>
-sudo apt autoclean
-sudo apt clean
-sudo apt autoremove