Switch video output to another monitor from command line

So, you have two video outputs. The first is DisplayPort (eDP). The actual monitor sits on the second video output, which is HDMI. For some reason your Mate desktop sends all the panels and icons to the first output, where you can’t actually see them. The monitor shows you only pristinely clean desktop wallpaper coming from the second video output.

Solution:

  • Find out what displays your system thinks it has:
    xrandr --listmonitors

    The result will be something like this:

    0: +*eDP-1 1920/508x1080/286+0+0 eDP-1
    1: +HDMI-1 1920/480x1080/270+1920+0 HDMI-1
    
  • Then tell it that the second monitor is the primary one, where you want all your user interface widgets to be:
    xrandr --output HDMI-1 --primary

See disk usage from command line

From the command line to see which directories are using most of the space on your disk (root / as an example here):

  • du -h / | grep ‘[0-9\,]\+G’

Install Brave Browser from the latest .deb package

Download the latest available .deb package of Brave Browser for Ubuntu or Mint like this:

  • wget -O brave.deb https://laptop-updates.brave.com/latest/dev/ubuntu64

Then just  double click it in the file manager and do package install.

Though this is not the recommended way to install the browser, it is the simplest one, especially in a situation when you are using the latest release of the OS and there is no Brave release built specifically for it yet.

You can see it mentioned at the page Linux install instructions page.


Unable to uninstall MySQL – broken packages

You mess up your MySQL and attempt to remove it completely, but the command

  • apt-get remove mysql-common

fails with the following output:

  • You might want to run ‘apt-get -f install’ to correct these:
    The following packages have unmet dependencies:
    mysql-client-5.7 : Depends: mysql-common (>= 5.5) but it is not going to be installed
    mysql-server : Depends: mysql-server-5.7 but it is not going to be installed

Whatever you do you are stuck and can’t go around this.

If none of the common suggestions works, try this:

  • cd /var/lib
  • mv mysql mysql-old
  • apt install -f

 

[Source] 

 

 


Leave task running after logging out from SSH

Assume you are logged in to a remote server via SSH and are running a task which takes longer to complete than you want to wait.

The straight-forward option would be to terminate the task and re-run it at a later time, but that is not always an acceptable option.

Instead you can send the active task to background and leave it running even after you log out.

  • Press Ctrl-Z to pause the task
  • Type bg to send it to the background and resume running
  • Type disown to disassociate the process with your SSH login, so that it does not terminate when you log out
  • Type exit to log out

Ref.:[1]


Fast image viewer for Linux

Meet feh – a fast and minimalist image viewer, suitable for quickly scrolling though your collection of resized photos without annoying jerks and delays.

It can be installed from your package repository.

One way to use it is to open the terminal window in the folder where your images are stored and run command:

  • feh -ZF

Here “Z” stands for zoom, and “F” stands for full screen. So it goes full screen and any images smaller than the screen size will be zoomed up. You can also add “r” parameter to recursively scan all subdirectories.

You can also set delay between slides. Read more about it all:

  • man feh

Photoshop PSD thumbnailer for Gnome file manager

This script generates a system script and associated meta-information for displaying Adobe Photoshop .PSD image thumbnails in Gnome file manager. It is intended to work with Nautilus, but also works with Nemo in Linux Mint 18.2 Sonya Cinnamon, even though “Add GConf Hooks” section of the script fails.

Run the script with sudo and reboot afterwards.

The script was acquired from askubuntu.com here, and it is actually preferable that you get it from there, because here it may be automatically reformatted and fail at execution. It is posted here only for archival purposes.


#!/bin/bash

# ———————————————————–
# — Write psdthumbnailer
# ———————————————————–
OUTFILE=/usr/lib/psdthumbnailer
(
sudo cat <<‘EOF’ # bin/bash # Arguments / Parameters %i %o %s f_in=$1 f_out=$2 f_size=$3 # Execute Convert PSD to PNG through ImageMagick exec convert “psd:$f_in[0]” -scale “$f_sizex$f_size” “png:$f_out” EOF ) > $OUTFILE
# ———————————————————–
# — Write photoshop.thumbnailer
# ———————————————————–
OUTFILE=/usr/share/thumbnailers/photoshop.thumbnailer
(
sudo cat <<‘EOF’ # bin/bash [Thumbnailer Entry] TryExec=/usr/lib/psdthumbnailer Exec=/usr/lib/psdthumbnailer %i %o %s MimeType=image/vnd.adobe.photoshop; image/x-photoshop; image/x-psd; EOF ) > $OUTFILE
# ———————————————————–
# — Set File Permissions
# ———————————————————–
sudo chmod 0755 /usr/lib/psdthumbnailer
sudo chmod 0644 /usr/share/thumbnailers/photoshop.thumbnailer

# ———————————————————–
# — Add GConf Hooks to parse thumbnails
# ———————————————————–
sudo gconftool-2 –set /desktop/gnome/thumbnailers/image@vnd.adobe.photoshop/enable –type bool true

sudo gconftool-2 –set /desktop/gnome/thumbnailers/image@vnd.adobe.photoshop/command –type string “/usr/lib/psdthumbnailer %i %o %s %i %o %s”

# ———————————————————–
# — Install Dependencies
# ———————————————————–

sudo apt-get install imagemagick


Error – getcwd failed!

You run a command on command line and receive a mysterious error message:

sh: 0: getcwd() failed: No such file or directory

Possible explanation is that the directory you were working in has been deleted by some other process and indeed just does not exist anymore. Move, for example by typing “cd”, and continue working elsewhere.


Invalid command RewriteEngine

After (re-)installation of Apache2 the browser greets you with error 500 “Internal Server Error” and Apache2 error log file contains message “Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration”.

Well, you might want to enable mod_rewrite, which is disabled by default:

  • a2enmod rewrite
  • service apache2 restart

Missing php-mbstring

After (re-)installing PHP and attempting to run a script, you may see an error message saying “PHP Fatal error: Uncaught Error: Call to undefined function mb_strtoupper()”.

Well, you may be missing the php-mbstring extension to PHP. Simply install it by:

  • sudo apt-get install php-mbstring