My Avatar

LanternD's Castle

PhD Student in ECE @ MSU

Tips on Ubuntu

2018-07-01

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.

Tips

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.

Change file owner and user group

Suppose the file name is “so_happy.org”

1
sudo chown user:group so_happy.org

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

Change file permission

Allow file executiohttps://askubuntu.com/questions/25596/how-to-set-up-usb-for-virtualboxn:

1
sudo chmod +x your_file

Set read/write/execute

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

Link.

1
sudo apt-mark hold <package>

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

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

Link.

Install dos2unix.

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

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:
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 “*.tex”.

Using USB passthrough to Oracle VirtualBox

Link: How to set up USB for Virtualbox?



Disqus Comment 0