Quick tips / references for using Linux / Ubuntu.
π Note: Fresh installation Ubuntu note.
π Note: Bash
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:
ps ax | grep teamviewer # check the id
kill -9 <pid> # kill some processπ
Install file .bin, .run
chmod +x file-name.run
./file-name.runπ
Make a script executable: chmod a+x script_file
π Unzip a file,
sudo apt-get install unzip
unzip <file>
unzip <file> -d <destination>π Terminal multi windows:
sudo 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
sudo rm /etc/apt/sources.list.d/<file>Or using below command lines
# install
sudo add-apt-repository ppa:name
# remove
sudo add-apt-repository --remove ppa:nameπ
Get ip address: ifconfig
Settings
π Make Monday as the start of the week:
sudo -H gedit /usr/share/i18n/locales/en_GB
# change to 1
first_weekday 1
# save and restart the systemπ Add / Remove / Manage app icon in launcher:
sudo apt-get install alacarteπ Change ubuntu logo in settings: replace
/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):
sudo apt install lightdm
dpkg-reconfigure lightdm
# current config
lightdm --show-configπ
Save / Load dconf[ref]: ~/.config/dconf/user
# save guake configs to a file
dconf dump / > dconf-settings.ini
# load
dconf load / < dconf-settings.ini
# or
cat dconf-settings.ini | dconf load /π Save / load custom keyboard shortcuts (ref)
# keybindings
dconf dump /org/gnome/desktop/wm/keybindings/ > keybindings.dconf
# media keys
dconf dump /org/gnome/settings-daemon/plugins/media-keys/ > media-keys.dconf
# load
dconf load /org/gnome/desktop/wm/keybindings/ < keybindings.dconf
dconf load /org/gnome/settings-daemon/plugins/media-keys/ < keybindings.dconfApplications
π Completely remove LibreOffice,
# zsh uses \*
sudo apt-get remove --purge libreoffice*
sudo apt-get clean
sudo apt-get autoremoveπ Remove snap store
sudo apt autoremove --purge snapdπ Uninstall snap applications
sudo snap remove <app_name>π Convert office's files to pdf
# install first
sudo apt install libreoffice
# pptx -> pdf
soffice --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
sudo updatedbπ Sync one folder to another (more info)
# A -> B/A
rsync -avu --delete "/home/user/A" "/home/user/B"
# A/* -> B/A
rsync -avu --delete "/home/user/A/" "/home/user/B/A"
# A, C -> B/A, B/C
rsync -avu --delete "/home/user/A" "/home/user/C" "/home/user/B"-aDo the sync preserving all filesystem attributes-vrun verbosely-uonly copy files with a newer modification time (or size difference if the times are equal)--deletedelete the files in target folder that do not exist in the source
# exclude
rsync -a --exclude 'dir1' src_directory/ dst_directory/
rsync -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
sudo chown -R yourusername:yourusername ~/.cache/thumbnailsπ Shorten directory in terminal
Temporarily, just enter
PS1='\u:\W\$ 'en press enter.Permanently, open
sudo gedit ~/.bashrcand findif [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fiRemove
@\hand replace\wby\Wso that it becomes,if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
fiSave, exit, close terminal and start another to see the result.
π Right click nautilus "Open as Administrator":
sudo apt-get install nautilus-admin
nautilus -q # restart nautilusπ Mount iso file on linux
# create a folder
mkdir /mnt/<folder>
sudo mount -o loop <image>.iso /mnt/<folder>
# unmount
sudo umount /mnt/<folder> # umount, not "unmount"!!!If you mount another iso file to the same
π
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.
# copy all files in /iso/ to <directory>/
cp -r /mnt/iso/* <directory>/π Sync files with mega right on terminal
Install megatools:
sudo apt-get install megatoolsUsing megatools, cf the main website.
Create a condig file which stores your login information (be careful, everyone can see your pass)
sudo apt-get install vim # in case that you don't have vim on your system
vim .megarc # create a file named .megarcvimopens and type[Login]
Username = your@email
Password = yourpasswordIf you have back slash in your password, you must escape it with another backslash
Quit
vimand save the file by pressing ESC and then:wq!Upload a file:
megaput --path /Root/<folder> fileSee the list of file on remote:
megalsUpload a folder:
megacopy --local <folder> --remote <folder>Download from link:
megadl <mega-link>Download a single file:
megaget <file>megaget /Root/Apps/matlab17b/R2017b_glnxa64_dvd2.isoDownload from uploaded directory:
megacopy --local <folder> --remote <folder-to-download> --download
π
Save a directory a $PATH of local profile.
sudo gedit ~/.profile
# copy and paste following line (should change the path)
export PATH=/home/thi/anaconda3/bin:$PATH
# save and close .profile and then apply following line to get instant update
source ~/.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
sudo apt install renamerename 's/.+/our $i; sprintf("chap%d", 46+$i++)/e' *abc xyz 123 # from
chap46 chap47 chap48 # toConnect to iOS / iPhone / iPad
# Install
sudo apt install libimobiledevice6 ifuse libimobiledevice-utils ideviceinstaller
# Connect iDevice to computer with usb
idevicepair pair # Trust on iDevice and then rerun this
sudo mkdir /media/$USER/ipad
sudo chown -R $USER /media/$USER/ipad
ifuse /media/$USER/ipad
# 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]
sudo usermod -a -G groupName userNameπ Change ownership of a folder and its children
# folder and its children
chown -R thi:root folder
# a file
chown <user>:<group> fileπ Check the permission of curent directory:
ls -l
ls -l <file>
Matlab
π Scale matlab: need to install matleb version >= R2017b
s = settings;s.matlab.desktop.DisplayScaleFactor
s.matlab.desktop.DisplayScaleFactor.PersonalValue = 2π Launching matlab without graphic ui[ref]
matlab -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
sudo env "PATH=$PATH"from this, you can sudo matlab
π Matlab drive connector: after installing, run
~/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)
Suppose that you have 2 dvd iso files which contains the installation of matlab (
dvd1.isoanddvd2.iso)For the activation, you have
libmwservices.soandlicense_standalone.licFirst, you need to extract 2 dvd iso files to a common folder named
install_matlabin/home/thi/Create a new folder to install matlab called
matlabRin/home/thi/Extract all files in 2 iso files to folder
install_matlablike the other tut (search for "mount").Run below command line
sudo /home/thi/matlab_install/install -agreeToLicense yes -mode silent -destinationFolder /home/thi/matlabR -fileInstallationKey xxxxx-xxxxx-xxxxx -outputFile /home/matlab_install.logAfter the installation, copy file
license_standalone.licto/home/thi/matlabR/licenses/Copy file
libmwservices.soto/home/thi/matlabR/bin/glnxa64/Try running matlab:
/home/thi/matlabR/bin/matlabIf you have an error like,
# ERR: libXt.so.6: cannot open shared object file: No such file or directory
sudo apt-get install libxt6Make linux recognize your matlab command
matlablike in the instruction 40.
π Make linux recognize matlab command
Suppose that you have installed matlab on
/home/thi/matlabRYou need to add above directory to the
$PATHso that the system can recognize yourmatlabcommandexport PATH=$PATH:/home/thi/matlabR/binYou can use
echo $PATHto check if the path is located in it or not.
π Remove matlab on linux: simply
rm -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,
# install
curl https://www.teleconsole.com/get.sh | sh
# share current terminal
teleconsole
# choose to connect via web browser
# or via terminal
teleconsole join <id>
# stop broadcasting
exit
# port forwarding
# suppose that a port is open at 3000 on your machine and you
# wanna share it with your friend
teleconsole -f localhost:3000π Download a direct link by terminal
wget <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)
- Follow (a little bit) here.
- On the remote machine
- update and upgrade install
- install
openssh-server - open
/etc/ssh/sshd_configand uncomment onPort 22and lines starting withHostkey... - start the network:
sudo service ssh start - stop the network:
sudo service ssh stop - check if the network is running or not?
sudo service ssh status - Check the current ip:
ifconfig: look on the inet
- On the local machine
8. Install the same tool and usessh username@remote-host
π
Connect ssh to a virtual machine (the same network)
Install openssh for both client and server machine
sudo apt-get install openssh-client
sudo apt-get install openssh-serverOn server machine, check ssh is running or not
ps -A | grep sshd
# return [number] ? 00:00:00 sshd then it works
π
Download playlist audio youtube, using youtube-dl
sudo apt-get install curl -y (cΓ i curl nαΊΏu chΖ°a cΓ i)
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
# update 11/11/20: not working with playlist but single song!
youtube-dl --extract-audio --audio-format mp3 -o "%(title)s.%(ext)s" <link-playlist>π Install TOR Browser
sudo add-apt-repository ppa:micahflee/ppa
sudo apt update
sudo apt install torbrowser-launcher
# Open "Tor Browser" and install for the 1st time
# Click "Connect" to connect to Tor Network
# Uninstall
sudo apt remove torbrowser-launcherFree 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.
- Enable plugin "MPRIS D-Bus interface".
- Add custom shortcuts keyboards as
- Play/Pause:
rhythmbox-client --play-pause - Next:
rhythmbox-client --next - Previous:
rhythmbox-client --previous
- Play/Pause:
π
Convert .ts videos to .mp4
sudo apt install ffmpeg
ffmpeg -i input.ts -c:v libx264 -c:a aac output.mp4π Mp3 tag editor:
sudo 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:
# play/puase
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
# next track
dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next
# previous track
dbus-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:
- Download and install this app.
- Change to Youtube Music interface.
- Remove all shortcut keyboards that look like the ones you wanna set in the app in Ubuntu system (Keyboard shortcuts).
- 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+Spacefor play/pause track).
# install
sudo apt-get install imagemagick# resize but keep the ratio (save to jpg)
mogrify -resize 50% -format jpg *# resize keep the extension
mogrify -resize 50% *# with a specific size (save to jpg)
mogrify -resize 800x600 -format jpg *# just the width (save to jpg)
mogrify -resize 800x -format jpg *# only resize images bigger than 1000px width
mogrify -resize 1000x\> *Game
π Game platforms: Steam, Lutris.
π Xbox Controller on Ubuntu:
# for bluetooth recognize
sudo apt-get install xboxdrv
# start the service
sudo systemctl start xboxdrv.service
# if: Failed to start xboxdrv.service: Unit xboxdrv.service not found
# install
sudo apt-add-repository -y ppa:rael-gc/ubuntu-xboxdrv
sudo apt-get update
sudo apt-get install ubuntu-xboxdrv# for GUI testing app
sudo apt-get install jstest-gtkIf you cannot connect controller to bluetooth,[ref]
sudo apt install sysfsutils
# edit as root
/etc/sysfs.conf
# add below line to the end of above file
/module/bluetooth/parameters/disable_ertm=1
# save changes and restartLutris 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:
CLick on "+" (Add Game)
Tab Game info: "Name" the game + choose "Runner".
Tab Game options: "Excutable" choose
# an example
~/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
sudo apt install nodejs
sudo apt install npm
sudo npm install -g vtopFont
- Method 1 -- To install font, copy all font file (eg.
.ttf) to~/.local/share/font/. For global, it's/usr/share/fonts. - 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
sudo apt install libcanberra-gtk-module libcanberra-gtk3-moduleπ nvidia docker signatures invalid. The following signatures were invalid: EXPKEYSIG
curl -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)
echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
locale-gen en_US.UTF-8π dpkg: error processing package install-info
sudo 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
dpkg --configure -a
apt-get install -fGPU-NVDIA problems
π Check this note.
π¬ Comments