My Avatar

LanternD's Castle

PhD Student in ECE @ MSU

Tips on Ubuntu


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: 2018-10-22.


How to add a .desktop executable file to start menu and “favorites”?

.desktop file usually comes with the software packages in 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:

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.

Change file owner and user group

Suppose the file name is “”

sudo chown user:group

The userhao and group are the ones you want to set.

Change file permission

Allow file executio

sudo chmod +x your_file

Set read/write/execute

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 apt upgrade


sudo apt-mark hold <package>

[] TODO How to ignore packages in Ubuntu Software Updater?

Change End-of-Line (EOL) of a file


Install dos2unix.

sudo apt install dos2unix

Process file with it.

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).

Taking area screenshot with shortcut

Link: How to change the keyboard shortcut to take screenshots with Shutter? - StackOverflow.

  1. Install shutter (Available in Ubuntu Software Center).
  2. Go to System Settings -> Devices -> Keyboard.
  3. Scroll down to the bottom, add a personal shortcut (Ctrl + Shift + Alt + Z for me).
  4. Give it a name, whatever. The command is shutter -s.
  5. If you want to take a full screenshot, change the command to shutter -f, or simply press the PrintScreen key.

Convert GBK-encoded files to UTF-8 encoding

Link: Linux 下 GBK->UTF-8 文件编码批量转换命令.

  1. Install enca by apt: sudo apt install enca.
  2. Check the usage via man enca.
  3. In our case, run the command in terminal:
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 “*.tex”.

Using USB passthrough to Oracle VirtualBox

Link: How to set up USB for Virtualbox?

Disqus Comment 0