Some quick fixes and minor hacks on Ubuntu. I update it every now and then.
A Few Words
I encounter problem every now and then on Ubuntu. I decide to take some notes on what I get when searching through websites like StackOverflow.
Last update: 2019-04-05.
Command about listing
ls: list files and directory.
lsusb: list USB devices.
lscpu: list CPU info.
lspci: list PCI devices.
dmesg: list display and driver messages.
sudo ss -lntup: list all the ports that the computer is using or listening.
How to add a
.desktop executable file to start menu and “favorites”?
.desktop file usually comes with the software packages in
.tar.bz format, for example, Zotero. When you double click to execute the
zotero.desktop, you can not add it to the side bar (favorites). The solution is:
1 ln -s ~/Software/Zotero_linux-x86_64/zotero.desktop ~/.local/share/applications
I just use Zotero to illustrate, other software is likewise. After the symbol exists, you can find it in start menu by press the super (win) key. Open Zotero, and now you can add it to the side bar by right clicking the icon.
2019.03.14 Update: GUI desktop entry editor.
Change file owner and user group
Suppose the file name is “so_happy.org”
1 sudo chown user:group so_happy.org
group are the ones you want to set.
Change file permission
Allow file execution:
1 sudo chmod +x your_file
1 sudo chmod 755 your_file
There are three bits to represent readable/writable/executable. Then 000 - 111 are mapped to 0-7 decimal digits.
The three digits in the command are owner, group, others.
Read more: AskUbuntu.
Hold back a package in
1 sudo apt-mark hold <package>
 TODO How to ignore packages in Ubuntu Software Updater?
Change user password
1 sudo passwd your_user_name
Type the old password first, then the new one.
Switch between root and normal users
1 2 sudo -i # switch to root (temporarily) su your_user_name # switch to some user.
Change End-of-Line (EOL) of a file
1 sudo apt install dos2unix
Process file with it.
1 dos2unix input_file.txt output_file.txt
This is especially helpful for the file
~/.aspell_pws/.aspell.en.pws. Once Spacemacs is run on Windows, the EOL will be changed to DOS (I synchronize this file with Dropbox).
Use shortcut to open the file explorer (Nautilus)
Link: Setting a key shortcut to run an application in GNOME - Fedora Docs
System Settings ->
Keyboard. Scroll to the end. Add a new shortcut. The command to open new folder window is
nautilus -w. I bind it to
Super+E, same as Windows.
Btw, I also change the “Hide all normal window” shortcut to
Super+D (also, same as Windows).
Taking area screenshot with shortcut
Link: How to change the keyboard shortcut to take screenshots with Shutter? - StackOverflow.
- Install shutter (Available in Ubuntu Software Center).
- Go to
Keyboard(same as above).
- Scroll down to the bottom, add a personal shortcut (
- Give it a name, whatever. The command is
- If you want to take a full screenshot, change the command to
shutter -f, or simply press the
Convert GBK-encoded files to UTF-8 encoding
sudo apt install enca.
- Check the usage via
- In our case, run the command in terminal:
1 2 3 enca -L zh_CN file # check the encoding of the file enca -L zh_CN -x UTF-8 file # convert GBK to UTF-8 enca -L zh_CN -x UTF-8 file1 file2 # convert file1 to UTF-8 and save to file2
Note: it supports wild card matching, like
Using USB pass-through to Oracle VirtualBox
Link: How to set up USB for Virtualbox?
- Install “VirtualBox Extension Pack”.
sudo usermod -aG vboxusers <username>
- Reboot the host computer. Done!
Minimize the window when clicking the dock icon
Link: Click on Icon to Minimize Application Window in Ubuntu 18.04
Open terminal, type in the following command and press
1 gsettings set org.gnome.shell.extensions.dash-to-dock click-action 'minimize'
Check gnome version
1 gnome-shell --version
- ← Older-Zotero Configuration for Attachment Synchronization Between Multiple Computers
- C Coding Standard - Formatted-Newer →