General

🔅 Run MacOS apps on Linux, use Darling.
🔅 Run Android apps on Linux, use Anbox.
🔅 Find in linux with command lines ⇾ link.
🔅 Cannot move files to the trash/wrong owner ⇾ link.
🔅 Gnome screenshot ⇾ link.
🔅 Windows shrink drive in windows ⇾ link (partition, resize disk drive, hard disk).
🔅 Type Vietnamese in SublimeText, install vn ime (exactly like that). Press F2 for using.
🔅 Look and kill an app process:
1ps ax | grep teamviewer # check the id
2kill -9 <pid> # kill some process
🔅 Install file .bin, .run
1chmod +x file-name.run
2./file-name.run
🔅 Make a script executable: chmod a+x script_file
🔅 Unzip a file,
1sudo apt-get install unzip
2unzip <file>
3unzip <file> -d <destination>
🔅 Terminal multi windows:
1sudo apt-get install terminator
🔅 Add bookmark for evince (default pdf reader)
  • F9: hide/show sidebar
  • Menu on the top right > Add bookmarks
  • Click on bookmark and rename it
  • Ctrl + Shift + S to save (instead of Ctrl + S)
🔅 Remove PPA from ubuntu by terminal. For example, The repository 'http://ppa.launchpad.net/b-eltzner/qpdfview/ubuntu artful Release' does not have a Release file. Remove the file b-eltzner-qpdfview-ubuntu from directory /etc/apt/sources.list.d
1sudo rm /etc/apt/sources.list.d/<file>
Or using below command lines
1# install
2sudo add-apt-repository ppa:name
3
4# remove
5sudo add-apt-repository --remove ppa:name
🔅 Get ip address: ifconfig

Settings

🔅 Make Monday as the start of the week:
1sudo -H gedit /usr/share/i18n/locales/en_GB
2# change to 1
3first_weekday 1
4# save and restart the system
🔅 Add / Remove / Manage app icon in launcher:
1sudo apt-get install alacarte
🔅 Change ubuntu logo in settings: replace
1/usr/share/icons/hicolor/256x256/apps/ubuntu-logo-icon.png
🔅 Turn off animation open and minimize windows on ubuntu 17.10 and later (gnome desktop): Gnome Tweak Tools > Apperance > Animations OFF
🔅 Choose between "lightdm" and "gdm3" (ref):
1sudo apt install lightdm
2dpkg-reconfigure lightdm
3# current config
4lightdm --show-config
🔅 Save / Load dconf (ref): ~/.config/dconf/user
1# save guake configs to a file
2dconf dump / > dconf-settings.ini
3
4# load
5dconf load / < dconf-settings.ini
6# or
7cat dconf-settings.ini | dconf load /
🔅 Save / load custom keyboard shortcuts (ref)
1# keybindings
2dconf dump /org/gnome/desktop/wm/keybindings/ > keybindings.dconf
3# media keys
4dconf dump /org/gnome/settings-daemon/plugins/media-keys/ > media-keys.dconf
5
6# load
7dconf load /org/gnome/desktop/wm/keybindings/ < keybindings.dconf
8dconf load /org/gnome/settings-daemon/plugins/media-keys/ < keybindings.dconf

Applications

🔅 Completely remove LibreOffice,
1# zsh uses \*
2sudo apt-get remove --purge libreoffice*
3sudo apt-get clean
4sudo apt-get autoremove
🔅 Remove snap store
1sudo apt autoremove --purge snapd
🔅 Uninstall snap applications
1sudo snap remove <app_name>
🔅 Convert office's files to pdf
1# install first
2sudo apt install libreoffice
3# pptx -> pdf
4soffice --headless --convert-to pdf prezentacja.pptx
🔅 Modify / Add icon in launcher: alacarte" (Main Menu, can be found in App Store).

Nautilus / Files management

🔅 Force Unity Dash to index all files on Home
1sudo updatedb
🔅 Sync one folder to another (more info)
1# A -> B/A
2rsync -avu --delete "/home/user/A" "/home/user/B"
3
4# A/* -> B/A
5rsync -avu --delete "/home/user/A/" "/home/user/B/A"
6
7# A, C -> B/A, B/C
8rsync -avu --delete "/home/user/A" "/home/user/C" "/home/user/B"
  • a Do the sync preserving all filesystem attributes
  • v run verbosely
  • u only copy files with a newer modification time (or size difference if the times are equal)
  • -delete delete the files in target folder that do not exist in the source
1# exclude
2rsync -a --exclude 'dir1' src_directory/ dst_directory/
3rsync -a --exclude={'file1.txt','dir1/*','dir2'} src_directory/ dst_directory/
🔅 Make a shortcut link to a folder/file in linux terminal ⇾ link.
🔅 Shortcut to a folder in linux ⇾ link.
🔅 Thumbnail nautilus: go to setting, set and apply this line.
1sudo chown -R yourusername:yourusername ~/.cache/thumbnails
🔅 Shorten directory in terminal
  • Temporarily, just enter PS1='\u:\W\$ ' en press enter.
  • Permanently, open sudo gedit ~/.bashrc and find
    • 1if [ "$color_prompt" = yes ]; then
      2PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
      3else
      4PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
      5fi
  • Remove @\h and replace \w by \W so that it becomes,
    • 1if [ "$color_prompt" = yes ]; then
      2PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
      3else
      4PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
      5fi
  • Save, exit, close terminal and start another to see the result.
🔅 Right click nautilus "Open as Administrator":
1sudo apt-get install nautilus-admin
2nautilus -q # restart nautilus
🔅 Mount iso file on linux
1# create a folder
2mkdir /mnt/<folder>
3
4sudo mount -o loop <image>.iso /mnt/<folder>
5
6# unmount
7sudo umount /mnt/<folder> # umount, not "unmount"!!!
If you mount another iso file to the same <folder>, it will replace the current one.
🔅 Extract a iso file: first, mount it like in previous tut to a folder named iso then copy all the contents in iso to some folder you want.
1# copy all files in /iso/ to <directory>/
2cp -r /mnt/iso/* <directory>/
🔅 Sync files with mega right on terminal
  • Install megatools:
    • 1sudo apt-get install megatools
  • Create a condig file which stores your login information (be careful, everyone can see your pass)
    • 1sudo apt-get install vim # in case that you don't have vim on your system
      2vim .megarc # create a file named .megarc
  • vim opens and type
    • 1[Login]
      2Username = your@email
      3Password = yourpassword
      If you have back slash in your password, you must escape it with another backslash
  • Quit vim and save the file by pressing ESC and then :wq!
  • Upload a file: megaput --path /Root/<folder> file
  • See the list of file on remote: megals
  • Upload a folder: megacopy --local <folder> --remote <folder>
  • Download from link: megadl <mega-link>
  • Download a single file: megaget <file>
    • 1megaget /Root/Apps/matlab17b/R2017b_glnxa64_dvd2.iso
  • Download from uploaded directory:
    • 1megacopy --local <folder> --remote <folder-to-download> --download
🔅 Save a directory a $PATH of local profile.
1sudo gedit ~/.profile
2# copy and paste following line (should change the path)
3export PATH=/home/thi/anaconda3/bin:$PATH
4# save and close .profile and then apply following line to get instant update
5source ~/.profile
🔅 Copy files from ubuntu to iPhone iOS iPad
  • Don't need to install any files if one needs to copy photos/videos from iphone to ubuntu, one can use gThumb to do this or just use file manager to copy.
  • If one wants to copy files to iphone. Follow this one
🔅 Check the current path: pwd

Rename with some RegEx

1sudo apt install rename
1rename 's/.+/our $i; sprintf("chap%d", 46+$i++)/e' *
2
3# output
4abc xyz 123	# from
5chap46 chap47 chap48 # to
 

Connect to iOS / iPhone / iPad

1# Install
2sudo apt install libimobiledevice6 ifuse libimobiledevice-utils ideviceinstaller
3
4# Connect iDevice to computer with usb
5idevicepair pair # Trust on iDevice and then rerun this
6
7sudo mkdir /media/$USER/ipad
8sudo chown -R $USER /media/$USER/ipad
9ifuse /media/$USER/ipad
10
11# Check File Manager and see ipad!

Surface

🔅 Tweaks for ubuntu on surface book ⇾ link.
🔅 App linux-surface.

User / Group / Ownership

🔅 How to add existing user to an existing group (ref)
1sudo usermod -a -G groupName userName
🔅 Change ownership of a folder and its children
1# folder and its children
2chown -R thi:root folder
3# a file
4chown <user>:<group> file
🔅 Check the permission of curent directory:
1ls -l
2ls -l <file>

Matlab

🔅 Scale matlab: need to install matleb version >= R2017b
1s = settings;s.matlab.desktop.DisplayScaleFactor
2s.matlab.desktop.DisplayScaleFactor.PersonalValue = 2
🔅 Launching matlab without graphic ui (ref)
1matlab -nodesktop
🔅 Cannot open matlab without sudo: change the owner permission of folder /home/thi/.matlab to thi
Another solution: suppose that matlab is installed on a user's directory and you have already add this to the $PATH. IT's only work if you use matlab (not sudo matlab). Then do
1sudo env "PATH=$PATH"
from this, you can sudo matlab
🔅 Matlab drive connector: after installing, run
1~/bin/MATLABConnector toggle
🔅 How to install matlab silently (only with command lines) on linux? (if below doesn't work, you can check here, my method is different from this one)
  1. Suppose that you have 2 dvd iso files which contains the installation of matlab (dvd1.iso and dvd2.iso)
  1. For the activation, you have libmwservices.so and license_standalone.lic
  1. First, you need to extract 2 dvd iso files to a common folder named install_matlab in /home/thi/
  1. Create a new folder to install matlab called matlabR in /home/thi/
  1. Extract all files in 2 iso files to folder install_matlab like the other tut (search for "mount").
  1. Run below command line
    1. 1sudo /home/thi/matlab_install/install -agreeToLicense yes -mode silent -destinationFolder /home/thi/matlabR -fileInstallationKey xxxxx-xxxxx-xxxxx  -outputFile /home/matlab_install.log
  1. After the installation, copy file license_standalone.lic to /home/thi/matlabR/licenses/
  1. Copy file libmwservices.so to /home/thi/matlabR/bin/glnxa64/
  1. Try running matlab: /home/thi/matlabR/bin/matlab
  1. If you have an error like,
    1. 1	# ERR: libXt.so.6: cannot open shared object file: No such file or directory
      2sudo apt-get install libxt6
  1. Make linux recognize your matlab command matlab like in the instruction 40.
🔅 Make linux recognize matlab command
  • Suppose that you have installed matlab on /home/thi/matlabR
  • You need to add above directory to the $PATH so that the system can recognize your matlab command
    • 1export PATH=$PATH:/home/thi/matlabR/bin
  • You can use echo $PATH to check if the path is located in it or not.
🔅 Remove matlab on linux: simply
1rm -rf <matlab-folder>

Network

🔅 Don't show "Turn on wifi hotspot..." for clicking => try: click on "Network" and then "Wifi" in Settings.
🔅 Share terminal for other (via SSH): using Teleconsole
1# install
2curl <https://www.teleconsole.com/get.sh> | sh
3
4# share current terminal
5teleconsole
6
7# choose to connect via web browser
8# or via terminal
9teleconsole join <id>
10
11# stop broadcasting
12exit
13
14# port forwarding
15# suppose that a port is open at 3000 on your machine and you
16# wanna share it with your friend
17teleconsole -f localhost:3000
🔅 Download a direct link by terminal
1wget <direct-link> -O <name-of-file>.<file-extension>
🔅 Download from google drive by terminal
  • Download as usual without terminal by a web browser
  • Open Downloads windows of the browser and then copy the download link.
  • Stop the download process
  • Use the command link in 33 where <direct-link> is the link copied above.
🔅 Use ssh to get access to another computer in the same network (LAN)
  1. Follow (a little bit) here.
  1. On the remote machine
    1. update and upgrade install
    2. install openssh-server
    3. open /etc/ssh/sshd_config and uncomment on Port 22 and lines starting with Hostkey...
    4. start the network: sudo service ssh start
    5. stop the network: sudo service ssh stop
    6. check if the network is running or not? sudo service ssh status
    7. Check the current ip: ifconfig: look on the inet
  1. On the local machine
    8. Install the same tool and use
    ssh username@remote-host
🔅 Connect ssh to a virtual machine (the same network)
  • Install openssh for both client and server machine
    • 1sudo apt-get install openssh-client
      2sudo apt-get install openssh-server
  • On server machine, check ssh is running or not
    • 1ps -A | grep sshd
      2# return [number] ?  00:00:00 sshd then it works
🔅 Download playlist audio youtube, using youtube-dl
1sudo apt-get install curl -y (cài curl nếu chưa cài)
2sudo curl -L <https://yt-dl.org/downloads/latest/youtube-dl> -o /usr/local/bin/youtube-dl
3sudo chmod a+rx /usr/local/bin/youtube-dl
4
5# update 11/11/20: not working with playlist but single song!
6youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" <link-playlist>
🔅 Install TOR Browser
1sudo add-apt-repository ppa:micahflee/ppa
2sudo apt update
3sudo apt install torbrowser-launcher
4
5# Open "Tor Browser" and install for the 1st time
6
7# Click "Connect" to connect to Tor Network
8
9# Uninstall
10sudo apt remove torbrowser-launcher

Free VPN

Using vpnbook and its tutorial. Note that, at the last step, we need to run with sudo! Note: very low speed!

Media / Photo / Music

🔅 Add shortcut keys for Rhythmbox Music Player -> read this.
  1. Enable plugin "MPRIS D-Bus interface".
  1. Add custom shortcuts keyboards as
      • Play/Pause: rhythmbox-client --play-pause
      • Next: rhythmbox-client --next
      • Previous: rhythmbox-client --previous
🔅 Convert .ts videos to .mp4
1sudo apt install ffmpeg
2ffmpeg -i input.ts -c:v libx264 -c:a aac output.mp4
🔅 Mp3 tag editor:
1sudo apt install exfalso  # Ex Falso
🔅 Spotify controller shortcut keyboards on Ubuntu (ref): using below commands for controlling playbacks in spotify, put them in a shortcut keys on ubuntu:
1# play/puase
2dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
3
4# next track
5dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
6
7# previous track
8dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous
🔅 Resize multiple photos (keep the ratio/scale) (more options):
🔅 Youtube Music Controller for Linux:
  1. Download and install this app.
  1. Change to Youtube Music interface.
  1. Remove all shortcut keyboards that look like the ones you wanna set in the app in Ubuntu system (Keyboard shortcuts).
  1. On taskbar, right click on the You Tube Music app > Desktop settings > Hotkeys > Set your keyboards (eg. Ctrl+Shift+> for next track, Ctrl+Shift+< for previous track, Ctrl+Shift+Space for play/pause track).
1# install
2sudo apt-get install imagemagick
1# resize but keep the ratio (save to jpg)
2mogrify -resize 50% -format jpg *
1# resize keep the extension
2mogrify -resize 50% *
1# with a specific size (save to jpg)
2mogrify -resize 800x600 -format jpg *
1# just the width (save to jpg)
2mogrify -resize 800x -format jpg *
1# only resize images bigger than 1000px width
2mogrify -resize 1000x\> *

Game

🔅 Game platforms: Steam, Lutris.
🔅 Xbox Controller on Ubuntu:
1# for bluetooth recognize
2sudo apt-get install xboxdrv
3
4# start the service
5sudo systemctl start xboxdrv.service
6
7# if: Failed to start xboxdrv.service: Unit xboxdrv.service not found
8# install
9sudo apt-add-repository -y ppa:rael-gc/ubuntu-xboxdrv
10sudo apt-get update
11sudo apt-get install ubuntu-xboxdrv
1# for GUI testing app
2sudo apt-get install jstest-gtk
If you cannot connect controller to bluetooth (ref)
1sudo apt install sysfsutils
2
3# edit as root
4/etc/sysfs.conf
5
6# add below line to the end of above file
7/module/bluetooth/parameters/disable_ertm=1
8
9# save changes and restart

Lutris tips

🔅 Install GOG's games: Open Lutris > Search Lutris.net > Install with option "GOG". Installed from GOG Galaxy may be not working but with this method is working!
🔅 Add icon in the Lutris windows:
  1. CLick on "+" (Add Game)
  1. Tab Game info: "Name" the game + choose "Runner".
  1. Tab Game options: "Excutable" choose
    1. 1# an example
      2~/Games/epic-games-store/drive_c/Program Files/Epic Games/ShadowTactics/Shadow Tactics.exe
🔅 Add icon on Ubuntu/POP!_OS launcher: on Lutris interface, right click on a game > "Create application menu shortcut", it will appear on the launcher after that. You can use "alacarte" (Main Menu, can be found in App Store).

System

🔅 System monitor in terminal: vtop.
1sudo apt install nodejs
2sudo apt install npm
3sudo npm install -g vtop

Font

  1. Method 1 -- To install font, copy all font file (eg. .ttf) to ~/.local/share/font/. For global, it's /usr/share/fonts.
  1. Method 2 -- Open with Font Viewer and then click on Install.

Errors

🔅 Problem save file as root user and cannot open later ⇾ link.
🔅 Prevent bluetooth devices disconnected after sleep ⇾ link.
🔅 Failed to load module 'canberra-gtk-module
1sudo apt install libcanberra-gtk-module libcanberra-gtk3-module
🔅 nvidia docker signatures invalid. The following signatures were invalid: EXPKEYSIG
1curl -s -L <https://nvidia.github.io/nvidia-docker/gpgkey> | sudo apt-key add -
🔅 bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
1echo "LC_ALL=en_US.UTF-8" >> /etc/environment
2echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
3echo "LANG=en_US.UTF-8" > /etc/locale.conf
4locale-gen en_US.UTF-8
🔅 dpkg: error processing package install-info
1sudo mv /var/lib/dpkg/info/install-info.postinst /var/lib/dpkg/info/install-info.postinst.bad
🔅 APT had planned for dpkg to do more than it reported back
1dpkg --configure -a
2apt-get install -f

GPU-NVDIA problems

👉 Check Docker & GPU.