- Usage (Example):
sudo ln -s ~/Downloads/eigen/Eigen /usr/local/include/Eigen
- After doing this,
/usr/local/include/Eigenwill link to the original folder
~/Downloads/eigen/Eigen, so the compiler will be able to detect Eigen library.
-smeans the link is permanant ( will not disappear after rebooting ); must provide full paths rather than relative paths.
find . -name 'introduction.md' -type f | xargs rm -rf
- It’s convenient to create an
gedit ~/.bashrc, then add
alias od='nautilus --browser ~/OneDrive'in the file, just replace
odby your name and
~/OneDriveby your own directory, then save it and run
source ~/.bashrcto update.
- Next time you just need to open the terminal and simpy run
od(for example) to open
~/OneDrivedirectory, without having to type in the whole path.
- My NTFS file system on my ubuntu suddenly become read-only, this is perhaps because it is not properly unmounted, thus they are marked as locked.
sudo ntfsfix /dev/sda3to fix it. (
/dev/sda3is the device you want to mount )
- However, when I then try to run
sudo mount /dev/sda3 /media/eastin terminal, it says “
Windows is hibernated, refused to mount.“. So why it can be mounted in GUI interface but cannot do the same thing in command line ?
- Usage: cd -
- It depends on Linux distributions and terminal applications, but in Ubuntu (eoan), it can be achieved by :
- Just simply select the text in terminal for copying.
- And middle click for paste.
- Or use keyboard shortcut: Ctrl+Shift+C for copy and Ctrl+Shift+V for paste.
- Create a service: (recommend in
/etc/systemd/system; below is a common template to use )
ExecStart=/usr/bin/ss-local -c /home/ss.json
- Start a service:
sudo systemctl start applicationfor root user (
systemctl --user start applicationfor current user ).
applicationis the service name, namely, application.service.
- Stop a service:
sudo systemctl stop application
- Restart a service:
sudo systemctl restart application
- To tell systemd to start services automatically at boot, you must enable them:
sudo systemctl enable application.service; If you don’t want it afterwards, just replace
disableand run the command.
- Create a service: (recommend in
sudo systemctl enable application.servicecommand is quite convenient if you want to let a software start at boot.
- After you modify services, run
sudo systemctl daemon-reloadto reload them.
- Usually, in Ubuntu, the package provided unit files go in
/lib/systemd/system/directory, whereas the user provided or any modification to the package provided unit files go in
/etc/systemd/system/directory. But I’m not sure where this application.service is:
systemctl --user start application.
fd – “A simple, fast and user-friendly alternative to ‘find’”
sd – “Intuitive find & replace CLI (sed alternative)”
ripgrep(rg) – “ripgrep recursively searches directories for a regex pattern”
Find all files then pass them to
fd -HI -e conf -0 --type file | xargs -0 sd --string-mode 'find_str' 'replace_str'
fdcommand finds all the files with .conf suffix and pass them to
sdcommand to replace.
-Hlet fd additionally searches hidden directories and files;
-Ilet fd searches patterns from .gitignore files;
-eto specify a certain suffix of files (if don’t use -e then it will find all the files).
- Note: It’s convenient to use
fd 'file_name'to find all files with the given file name.
Find all files containing the given string then pass them to
rg --files-with-matches --fixed-strings 'find_str' | xargs sd --string-mode 'find_str' 'replace_str'
rgcommand finds all the files (in the current directory) with ‘find_str’ and pass them to
sdcommand will replace ‘find_str’ with ‘replace_str’.
You can put your own bash files in
~/bin directory, which is easier to manage these bash files than putting them in
/usr/local/bin. Of course, you should add
PATH="$PATH:~/bin" to your
~/.bashrc file. After that, if you have a file in ~/bin called fn, then you could simply run fn in the terminal from any directory to execute it.
If you create a bash file or just a text file, and you want to execute the comands in it, you have to grant it with executable permission. Simply use
chmod 700 file_name to change its permission (700 means owner can read(4), write(2) and execute(1)) .
As I am just a learner, please comment if you find any mistakes or have any advice. :)