Flush DNS cache
sudo resolvectl flush-caches
Install dynamic libs *.so
After installing, use ldconf
to refresh symbolic links and caches, or apps may not find your newly installed *.so.
rsync vs scp
They are similar tools but you may prefer to use one over another in certain cases:
- scp is pre-installed on basically all machines while usually you need to installed rsync on both the sending and the receiving side.
- scp is fast and efficient on first transfer.
- rsync works best on transferring the same dir multiple times since it supports incremental transmission.
- rsync supports complex filtering pattern.
Useful rsync arguments
-avz
: archive mode(transfer recursively, copy symlinks as symlinks, preserve permissions, preserve modification times, preserve group, preserve special files), verbose, compressed--exclude-from=FILE
or--exclude=PATTERN
: you can write that file like you're writing a .gitignore file.--delete
: delete extraneous files from dest dirs; useful when you want a copy.
restart ssh
On Ubuntu:
sudo systemctl restart ssh
usermod | Grant User sudo privileges
sudo usermod -aG sudo nameOfTheUser
useradd | Add User
sudo useradd -m whateverNameYouLike
sudo passwd nameOfTheUser
sudo usermod --shell /bin/bash nameOfTheUser
su nameOfTheUser
tzselect | Set Timezone
A simple, user-friendly timezone settings guider.
tzselect
Remember to add a line in ~/.profile
according to instructions given by tzselect
.
clean | Clear Terminal Screen
A simple command to clear the terminal screen.
clear
screen | A Terminal Multiplexer
What does it do?
There are several cases you want to use screen to manage your terminals.
- You are connecting to your Linux machine using ssh, but the job is time-consuming. You don't want to keep the ssh window open, but killing it will also kill the process.
- You are using Linux desktop. You want to hide a terminal when you not need it and resume to the status right before you hide it.
screen does the job perfectly. It serve as a layer between the terminal users see and the actual processes.
How to Use it
To create a new screen:
screen -S whateverNameYouLike
To list all screens:
screen -ls
To reattach to a screen:
screen -r theNameOfTheScreen (and then hit tab to complete it)
or
screen -r theIdOfTheScreen (and then hit tab to complete it)
To end a screen:
screen -S screenIdYouWantToKill -X quit
If you are in a screen, you can do the following operations:
I will use @
to refer to Ctrl+A
To detach the screen: press @+D
.
To create a window in a screen: press @+C
.
To navigate to the previous/next window in a screen: press @+P/N
To list all windows in a screen: press @+W
.