Ubuntu stuff

  • upgrading
  • find ubuntu and linux version

    lsb_release -a
    cat /proc/version
    uname -a
  • taks screenshot: fullsize Print, currently active window Alt+Print, area Shift+Print (select window or drag area). images are automatically saved to ~/Pictures Use ctrl instead of alt if you want to copy to clipboard
  • port forwarding ssh -L 8080:localhost:80 my.server.com socks tunel ssh -C -D 1080 server_url_or_ip, than in firefox

<about:preferences#advanced> Networktab -> Settings choose “Manual proxy configuration” and type SOCKS Host: localhost, and port 1080. Do not write anyting in HTTP proxy… For Chrome or another connections you can use system wide Ubuntu Settings -> Network -> Network Proxy -> Method: Manual -> Socks Host localhost 1080 (HTTP Proxy is empty), Ignore Hosts: localhost, *.loc For curl you need to export variable

export https_proxy=socks5://localhost:1080 http_proxy=socks5://localhost:1080
curl ifconfig.me

For ruby, you can check public ip address with

require "net/http"

but ruby does not support proxy using socks. Here are some alternatives: polipo http proxy using socks upstream, torsocks wrapper https://superuser.com/questions/280129/http-proxy-over-ssh-not-socks

# /etc/polipo/config
# proxyAddress = "::1"
proxyPort = 8118
socksParentProxy = "localhost:1080"
socksProxyType = socks5

restart with

sudo /etc/init.d/polipo restart

for curl use

export https_proxy=localhost:8118 http_proxy=localhost:8118

but the best option is to change in system settings (it will add new env variable) and open new terminals, curl and ruby works fine

echo "puts Net::HTTP.get(URI('http://ifconfig.me'))" | ruby -rnet/http
  • gui ssh forwarding ssh -X server remote ssh -R 5900:localhost:5900 [email protected] local
  • v4l2loopback, after sudo make install and sudo modprobe v4l2loopback we can stream some video file to device while true; do gst-launch-0.10 filesrc location=~/Desktop/buck.ogv ! decodebin ! v4l2sink device=/dev/video1;done
  • dim screen adjust brightness xrandr -q | grep " connected" to find the name, for example DFP1, than xrandr --output DFP1 --brightness 0.5. Here is what I use d 0.8 in my_bashrc.sh
# ~/.bashrc
function d {
  if [  -z $1 ]
    echo Default is middle value: d 0.5
  xrandr --output DFP1 --brightness ${1:-0.5}
alias dim=d

there is f.lux software that can automate screen brighthness.

  • webcam does not work on chrome but works in firefox
sudo apt-get install libv4l-0
sudo mv /opt/google/talkplugin/GoogleTalkPlugin /opt/google/talkplugin/GoogleTalkPlugin.real 
cat > /opt/google/talkplugin/GoogleTalkPlugin <<HERE_DOC
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libv4l/v4l1compat.so /opt/google/talkplugin/GoogleTalkPlugin.real


Simple scan scanner for HP LasetJet MF1212nf MFP does not work if you add printer from gui. Better is to use:

  sudo apt install hplip # install hp-setup
  hp-setup -i
  # chose net
  # chose to download driver from hp site
  # no need to install fax printer

On ubuntu 16 it works for 3.16.3 version

  HP Linux Imaging and Printing System (ver. 3.16.3)
  Printer/Fax Setup Utility ver. 9.0
  Plugin Download and Install Utility ver. 2.1
  Plugin Installer ver. 3.0

On ubuntu 18 I used binary installation hplip-3.19.6.run from https://developers.hp.com/hp-linux-imaging-and-printing/gethplip but somehow hp-plugin does not work, so I used old version

To install hp-plugin I disabled aamor https://bugs.launchpad.net/hplip/+bug/1813768/comments/8

sudo apt-get install apparmor-utils
sudo aa-disable /usr/share/hplip/plugin.py

To remove package and reinstall printer you can follow https://askubuntu.com/questions/1056077/how-to-install-latest-hplip-on-my-ubuntu-to-support-my-hp-printer-and-or-scanner

sudo apt-get purge hplip hplip-data hplip-doc hplip-gui hpijs-ppds \
libsane-hpaio printer-driver-hpcups printer-driver-hpijs
sudo rm -rf /usr/share/hplip/
sudo apt-get autoremove

To remove hplip

sh hplip-3.19.8.run --noexec
cd hplip-3.19.8
sudo ./uninstall.py
sudo rm -rf /usr/share/hplip/

On ubuntu 18 I used official

sudo apt-get install hplip-gui

Enable automatic adding network printers

sudo systemctl start cups-browsed
sudo systemctl disable cups-browsed # remove from /etc/cups/cupsd.conf
sudo systemctl stop cups-browsed

To use HP color laserjet CP1215 you can use http://foo2hp.rkkda.com/

wget -O foo2zjs.tar.gz http://foo2zjs.rkkda.com/foo2zjs.tar.gz
tar zxf foo2zjs.tar.gz
cd foo2zjs
./getweb 1215      # Get HP LaserJet CP1215 .ICM files
sudo make install
sudo make cups

Go to http://localhost:631/admin/ (your username and password) and configure Color mode to Color instead of Monochrome. Instructions as screenshots http://foo2hp.rkkda.com/cups/ Note that pdf usually use monochrome colors (unless after Ctrl+P under Advanced tab Color Mode is Color) so use Writter to insert image and print document.

  • recently I got dns error (I’m using Following post I comment out # dns=dnsmasq from /etc/NetworkManager/NetworkManager.conf and sudo restart network-manager

  • test sound using
    speaker-test -t wav -c 6
  • if Bus 002 Device 003: ID 0d8c:013c C-Media Electronics, Inc. CM108 Audio Controller microphone does not work automatically (but you can see in sound settings as CM108 Audio Controller than you need to comment out last line #options snd-usb-audio index=0 in /etc/modprobe.d/alsa-base.conf.

Chrome chromium

  • take screenshot with ctrl+Shift + p and search screenshot
  • chrome scrambled can be solved with sudo amdconfig --initial
  • chrome flickers on resize link solution is to disable (uncheck) Use hardware acceleration when available in System Settings -> Show Advanced -> (at bottom, search for this option) (or --disable-gpu in /usr/share/applications/chromium-browser.desktop). I try to disable only composition --blacklist-accelerated-compositing but still is enabled. Check that features is software only on <chrome://gpu/>.
  • you can open extension by going to <chrome://apps>
  • enable some flags on <chrome://flags>
    • for example sound icon
  • dns or other network <chrome://net-internals>
  • T-rex game <chrome://network-error/-106>
  • disable url minimisation, go to chrome://flags/#omnibox-ui-hide-steady-state-url-trivial-subdomains and set Omnibox UI Hide Steady-State URL Path, Query, and Ref On Interaction to Disabled

Chrome plugins and extensions

Chrome DNS and HSTS problem for .localhost and .dev

Since google owns .dev domain and it exists in hsts list, in chrome (no firefox) request to my-domain.dev will be always https. You can also use lvh.me since it always resolves to But for local development I use .loc with dnsmasq or .localhost also with dnsmasq. Old answer: I did not choose to use localhost because I can not remap subdomain of localhost in /etc/hosts and use in google chrome (firefox works fine) for some pathetic reason https://stackoverflow.com/questions/39666979/chrome-ignoring-hosts-file-for-subdomains-of-localhost Now localhost works in Chrome but not in Firefox (about:config network.dns.disableIPv6 set to false did not work for me). When I change loc to localhost in /etc/dnsmasq.d/dev-tld than it works.

For all subdomains I use dnsmasq so I do not need to edit /etc/hosts for each subdomain:

# /etc/dnsmasq.d/dev-tld

restart with

sudo systemctl restart NetworkManager
sudo /etc/init.d/dnsmasq restart

Also follow instructions

DNS server dnsmasq for .dev domains for osx https://passingcuriosity.com/2013/dnsmasq-dev-osx/ https://gist.github.com/ogrrd/5831371

brew install dnsmasq
# read suggested commands and apply them
cp /usr/local/opt/dnsmasq/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
sudo brew services start dnsmasq

# in /usr/local/etc/dnsmasq.conf

sudo brew services restart dnsmasq

sudo mkdir -p /etc/resolver
sudo tee /etc/resolver/loc >/dev/null <<EOF

Test with

# Make sure you haven not broken your DNS.
ping -c 1 www.google.com
# Check that .loc names work
ping -c 1 this.is.a.test.loc

You can check your domain name resolutions with mxtoolbox.com or domain settings with command nslookup (dns resolution, dns lookup)

nslookup asd.loc
# Server:
# Address:
# Name:	asd.loc
# Address:

# To display the MX records, use the -query=mx option:
# you can show any records with
nslookup -query=any move-index.org

You can also use dig to find out dns lookup

dig +short trk.in.rs

Also host command

host trk.in.rs

On linux you can update /etc/hosts with you custom domain name and use it instead of IP address. On window it is c:\Windows\System32\Drivers\etc. Just edit with notepad and save. No need to restart (maybe it will be cleared on restart).

Chrome Developer tools

  • open developer tools on last tab that was used is with F12 or ctrl+shift+i. Switch to next and prev panel with ctrl+] and ctrl+[. ctrl+shift+d dock undock. Open drawer with ESC
  • on drawer three dots, you can
    • to search file in google developer tools you can open console window (not console tab with console input, window can be opened on any tab with ESC key in dev tools). Than on three dots, open dropdown menu and find Search (keyboard shortcut is ctrl+shift+f). To search current panel use ctrl+f
  • three dots -> Coverage can give how much of css or js is used on the page
  • network tab filter request will filter by filename containg the string posts. But it also supports keywords with autosuggestions. Examples: domain:*.com, larger-than:1K,
  • to stop on some page that redirects immediatelly, you can go Sources tab and Event Listener Breakpoints and Load -> beforeunload or Script -> Script first statement. To stop on XHR/Fetch call you can set breakpoint on Sources -> XHR breakpoint
  • to search all files ctrl+o
  • to open command menu use ctrl+shift+p
    • screenshot
  • to open Console panel you can use ctrl+shift+j (also on a page). You can use monitor(function), monitorEvents($0, "key"); debug(function) or undebug(function). Usefull when you want to stop on some event listener debug(getEventListeners($0).click[0].listener) (you can do the same using Elements, Event Listeners tab, click, and jump to source where you want breakpoint). To show some value in log you can add Conditional breakport with console.log(varname); to use current selected element in console use $0 ($1 previous selected and so on), for xpath use $x(). Use $_ for last returned value in console. link
  • to open Elements panel (if developer tools is not yet opened) is ctrl+shift+c. You can use h to hide element (visibility: hidden). Use ctrl+f to find element (enter to find next). You can use .class to locate by css class.

  • ctrl+Shift + m to toggle mobile responsive view
  • ctrl+o find filename
  • ctrl+shift+
  • ^shift+c to click and locate element
  • ^shift+f to find string in all files
  • ^shift+o find functions in the current js file
  • ^shift+p chrome shortcuts

Enable experiments with <chrome://flags/#enable-devtools-experiments> and go to Experiments menu in Settings (F1 or Ctrl+P+Settings)

To clear autofill suggestions you can use keyboard shortcut. First select suggestion with UP or Down arrows than press Shift + Delete answer

In console you can call

await fetch(url)
await r.text()

Audit tab can give you broken best practices and explanations.


url suggestion does not use port number, so it is advised to disable it on about:config for browser.urlbar.autoFill to false. That way only history links will be provided, so you can navigate to them using tab.

Search https://thoughtbot.com/blog/make-the-most-of-your-browser-s-address-bar

^ str, matches history with str, # str matches page titles

when strange characters are shown as squares on ubuntu https://askubuntu.com/questions/1224125/font-characters-displayed-as-squares-in-ubuntu-18-04

rm -rf ~/.cache/fontconfig
sudo fc-cache -r -v

and restart computer (restarting firefox is also ok is you kill all firefox sessions).

Firefox developer tools and navigations

like vim

  • ctrl+[ back
  • ctrl+] forward
  • ctrl+f find (F3 and shift+F3 find next and prev)
  • / quick find, ' find only in links
  • ctrl+j focus search bar
  • ctrl+shift+i toggle developer tools (F12), ctrl+shift+k console, ctrl+shift+c inspector, shift+F7 style, ctrl+shift+m mobile responsive, ctrl+shift+j browser console
  • shift+f4 scratchpad and run with ctrl+r
  • shift+f2 developer toolbar
  • ctrl+i page info (content-type, referring url, size…)
  • f7 carret browsing so you can navigate cursor with shift arrow and ctrl+c

Firefox WebIDE

You can remotelly debug a page on your phone. Start https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging Enable Developer mode on Android: Settings -> About Phone -> Build Number -> Tap 10 times and you will see parent Setting menu -> Developer Options -> enable USB Debugging.

On desktop Firefox open Settings -> Web Developer -> WebIDE (shift+F8). On android Firefox open Settings -> Advanced -> enable Remote Debugging via USB.

Android Firefox needs to confirm Incomming connection: Allow USB debugging connection ?. Also the app needs to be opened (in focus).


Download for ubuntu https://www.opera.com/ Download mobile browser Opera mobile emulator https://www.opera.com/developer/mobile-emulator

# error while loading shared libraries: libQtGui.so.4: cannot open shared object file: No such file or directory

# to find in which package this file belongs use
# apt-file search libQtGui.so

sudo apt install libqtwebkit4
# still same error


Cage transform https://www.youtube.com/watch?v=jL8TepHX0qE does not work in latest gimp so use old ubuntu 14 in virtual box.


To enable ftp write you need to uncomment sudo vi /etc/vsftpd.conf write_enable=YES and restart sudo service vsftpd restart. You need to create folder (owner should be trkftp user).


Also https://localtunnel.github.io/www/

You can create local tunnel with ngrok.

When you signup you can generate authtoken in your ~/.ngrok2/ngrok.yml.

You need to upgrade to use custom subdomains, but free domain is fine if you can use some of your dns.

ngrok http 3002


Merge several pdf files

pdftk * cat output ../p.pdf

Convert images files to pdf. Some restrictions should be removed https://askubuntu.com/questions/1081895/trouble-with-batch-conversion-of-png-to-pdf-using-convert

sudo mv /etc/ImageMagick-6/policy.xml /etc/ImageMagick-6/policy.xmlout
convert johny* nin.pdf

Canon camera wifi

http://www.testcams.com/airnef/ is used to download files from Canon camera.


ifconfig is a tool to change network configuration, but changes are not persisted unless you save them in /etc/network/interfaces

ifconfig eth0

To configure default dateway gw you can use route command

sudo route add default gw eth1
route -n

To configure DNS you can edit /etc/resolv.conf. To purge all configuration you can ip addr flush eth0

To prevent Network manager to use connection as default route, you can edit connections -> IPv4 Settings -> Routes -> check “Use this connection only for resources on its network”

To remove docker bridge you can run ip link del docker0

  • resize mp4 video with avconv
avconv -i input.mp4 -s 640x480 -strict -2 output.mp4
for i in *.MP4; do avconv -i "$i" -strict -2 "resized/$i"; done
  • convert dvd vob to mp4
    for f in *.VOB ; do ffmpeg -i "$f" -vcodec copy -strict experimental -c:a aac "${f%.*.VOB}.mp4"; done
  • join videos using ffmpeg

    ffmpeg -i concat:"input1.mp4|input2.mp4" -fflags +genpts output.mp4
    # or
    # ls > textfile
    # edit file to contain:
    # file 'input1.mp4'
    # file 'input2.mp2'
    # ...
    ffmpeg -f concat -i textfile -fflags +genpts merged.mp4
    ffmpeg -f concat -i mylist.txt -c copy -safe 0 output.mp4
  • slideshow using ffmpeg https://trac.ffmpeg.org/wiki/Slideshow
    # hold single image duration
    ffmpeg -loop 1 -i a00.jpg  -c:v libx264 -t 10 -pix_fmt yuv420p a00.mp4
  • rotate video file using ffmpeg
    ffmpeg -i in.mov -vf "transpose=1" out.mov # 90 clockwise
    ffmpeg -i in.mov -vf "transpose=2" out.mov # 90 counter-clockwise
  • cat video
    ffmpeg -ss 00:01:00 -i input.mp4 -to 00:02:00 -c copy output.mp4
  • default gnome screenshot folder dconf-editor find org->gnome->gnome-screenshot-> auto-save-directory -> file:///home/user/Download/

  • install Oracle Java instead of OpenJDK http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html

    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java8-installer
    sudo update-alternatives --config java
    java -version
    javac -version
  • bluetooth


    systemctl status bluetooth.service
    sudo systemctl restart bluetooth.service
    lspci -knn
    agen on
    power on
    scan on

    My is

    04:00.0 Network controller [0280]: Qualcomm Atheros AR9462 Wireless Network Adapter [168c:0034] (rev 01)
      Subsystem: Lite-On Communications Inc AR9462 Wireless Network Adapter [11ad:6621]


    sudo -i
    echo "options ath9k btcoex_enable=1"  >  /etc/modprobe.d/ath9k.conf
  • trim or mute vocals in mp3 files with audacity
  • boot old computers
    • unetbootin http://unetbootin.github.io/
    • burn cd with mini.iso https://help.ubuntu.com/community/Installation/MinimalCD (since full iso is 850MB > 700 MB CD capacity)
  • find motherboard proccessor model with sudo dmidecode | less. To find type of memory run sudo dmidecode --type 17 and look for Type Detail (for my server Dell power Edge T110 it is Type Detail: Synchronous Unbuffered (Unregistered) and Part Number (M391B5273DH0-CK0) so it does not support registered/buffered memory link

Remote access to services

To enable mysql service from remote you need to bind it to in configuration. To test on which interface is used port listening you can see port use port in use

sudo netstat -tupln | grep 3306

You can try with nmap but it does not show for example neo4j 7474 port


To start service on boot use

service --status-all

# to automatically boot
sudo update-rc.d neo4j defaults
# to remove from auto start
update-rc.d -f neo4j remove

# another way to set up to run at boot [+]

sudo systemctl enable neo4j

Video processing

For youtube, video should be 16:9, ie for 1080p: 1920x1080, and for 720p: 1280x720.

Here are some tools

  • Open Shot https://www.openshot.org/static/files/user-guide/introduction.html#features but better is KDEenlive
  • http://www.blender.org for creating animations
  • handbrake for video processing. I used for cropping, first to preview for 720px height and use ffmpeg to crop window (original_width x 720) starting from position 0 x (top_pixel_handbrake) Ffmpeg generates smaller video than handbrake’s output m4v file.

    ffmpeg -i dahua.ts -filter:v 'crop=2592:720:0:824' -strict -2 k.mp4
  • kdenlive. When sound starts flickering, restart computer helps. Videos can be joined splited merged.

ImageMagic rmagick

https://imagemagick.org/index.php https://github.com/rmagick/rmagick Load image

require 'rmagick'
image = Magick::Image.read( 'demo.png' )
image = Magick::ImageList.new( 'demo.png' )
# to load just header block to find size of image
image = Magick::Image.ping( 'demo.png' ).first
# to return to ruby and not block the
pid = fork { draw.display }
# you can close from ruby
fork { sleep 30; Process.kill('SIGKILL', pid) }

# write output to different file
image.write file_name.split('.').insert(-2, 'proccessed').join('.')

To get a size of a image

image.columns # width
image.rows # height

To create gif

anim = ImageList.new("start.gif", "middle.gif", "finish.gif")

To resize but keep aspect ratio (ie to scale under constrains)

image = image.change_geometry("400") {|cols, rows, img| img.resize!(cols, rows)}

To write blue transparent box

draw = Magick::Draw.new
draw.stroke 'blue'
draw.fill_opacity 0
draw.rectangle 5,10, 50,100
draw.draw image


  • to change default program open with file type, you can right click, properties, set default. another way is to edit vi ~/.local/share/applications/defaults.list and run sudo update-mime
  • read only usb, can’t create file since usb is readonly https://askubuntu.com/questions/781223/physical-block-size-is-2048-bytes-but-linux-says-it-is-512-when-formatting-us

or error: ‘The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes’

df -Th
umount /media/duleusb
sudo fdisk -l
udisksctl unmount -b /dev/sdc1
sudo sgdisk --zap-all /dev/sdc
sudo sgdisk --new=1:0:0 --typecode=1:ef00 /dev/sdc
sudo mkfs.vfat -F32 /dev/sdc1

use disks application to erase and format usb flash drive. If it is not mountable than try forum but change number of KB 1024, 2048 …

sudo dd if=/dev/zero bs=4096 of=/dev/sdc
sudo apt-get install gparted
# Device -> Create partition table.
# format to fat32
  • to backup external usb, you can sync files. With rsync files are not deleted, just added, or overwritten if same filename. cd /media/orlovic/bf12a7e5-a5d4-4532-8612-a3984f90b56c/backup and rsync -r /media/dusan/EKSTERNIUSB/ EXTERNIUSB

  • suspend recovery https://wiki.ubuntu.com/DebuggingKernelSuspend

# enable trace and log
sudo sh -c "sync && echo 1 > /sys/power/pm_trace && pm-suspend"

# enable log in command env
sudo PM_DEBUG=true pm-suspend

less /var/log/pm-suspend.log
  • instead of double click .deb file to install you can use command line sudo dpkg -i /home/orlovic/Downloads/skypeforlinux-64.deb

  • decrease font size in terminal with Ctrl - , increase Ctrl + and reset Ctrl 0 (find them in manu Preferences -> Shortcuts)
  • https://hluk.github.io/CopyQ/ for showing clipboard content in window
  • open ms office docx files on https://onedrive.live.com/ to see comments
  • to install rpm package use alien
    sudo apt-get install alien
    sudo alien --to-deb bluejeans-*.rpm
    sudo dpkg -i bluejeans_*.deb
  • get image size information from command line
    file image.png
    MyPNG.png: PNG image, 681 x 345, 8-bit/color RGB, non-interlaced
    # get sizes of all images in a folder
    ls | xargs file
    # or
    identify image.png
  • workspace grid is in one line, to use 2x2 matrix you can use this extension https://github.com/mzur/gnome-shell-wsmatrix Installation is using the side (browser extension and native host connector $ sudo apt-get install chrome-gnome-shell for me, host connector is not detected in firefox) By default, only primary monitor windows are switching workspace, to swich all windows you should https://askubuntu.com/questions/1059479/dual-monitor-workspaces-in-ubuntu-18-04 install Gnome Tweaks app or
    gsettings set org.gnome.mutter workspaces-only-on-primary false
            (i.e., without -a or -p options)
    fsck exited with status code 4
    Failure: File system check of the root filesystem failed
    The root filesystem on /dev/sda1 requires a manual fsck

    solution is to run (initramfs) fsck -yf /dev/sda1

  • low resolution of second vga monitor is low 1024x768 . If you need better resolution of thet Unknown Display you can use
    xrandr --listactivemonitors
    # find monitor id like VGA-0
    xrandr --addmode VGA-0 1920x1080
  • to check disk usage you can run to see folder size
    sudo du /* -s
    # to sort
    du -sm * | sort -nr

    to free up disk space from ubuntu you can remove /var/log/journal

    journalctl --disk-usage
    sudo vi /etc/systemd/journald.conf
    sudo journalctl --vacuum-size=50M

    and snapd https://www.linuxuprising.com/2019/04/how-to-remove-old-snap-versions-to-free.html

    sudo snap set system refresh.retain=2
    # ~/Programs/remove-old-snaps.sh
    # Removes old revisions of snaps
    set -eu
    LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
        while read snapname revision; do
            snap remove "$snapname" --revision="$revision"
    chmod +x ~/Programs/remove-old-snaps.sh
    sudo ~/Programs/remove-old-snaps.sh