Tartalomjegyzék

Install display driver

Sikersztorik:

  1. Xubuntu 17.04 (XFCE4), ThinkPad T540p, nVidia GeForce GT 730M [2017-07-07] - nvidia-381
  2. Xubuntu 17.04 (XFCE4), ASUS B85M-G, nVidia GeForce GTX 750 Ti [2017-09-25] - nvidia-381
  3. Xubuntu 18.04 (XFCE4), ThinkPad T540p, nVidia GeForce GT 730M [2018-09-19] - nvidia-390
  4. Xubuntu 18.04 (i3-wm), ASUS B85M-G, nVidia GeForce GTX 750 Ti [2018-12-05] - nvidia-driver-415, But UEFI Secure Boot needed to be disabled from BIOS (or at least from OS)
  5. Xubuntu 20.04.1 (i3-wm), ASUS B85M-G, nVidia GeForce GTX 750 Ti [2020-11-05] - nvidia-driver-455, But UEFI Secure Boot and fast boot needed to be disabled from BIOS

Ubuntu 18.04.4 LTS, install or upgrade:

# When a new OS is installed:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update.

# Find out which package is installed
dpkg -l | egrep nvidia

# Remove old drivers
sudo apt purge nvidia-driver-xxx

# Find recommended drivers
ubuntu-drivers devices

# Install recommended drivers
ubuntu-drivers autoinstall

# Autoremove
sudo apt-get autoremove

# Find not completely removed packages, then remove them: apt purge ... ...
sudo dpkg -l | egrep "^[^i]"

Older solutions:

Find out which display driver is currently used:

sudo lshw -c video

Make sure which display driver you need:

sudo lspci

List all available device drivers

ubuntu-drivers devices

Disable default nouveau driver

Grub Boot loader press E, type this, than F10

linux   /boot/vmlinuz-4.4.0-38-generic root=UUID=5a76bb7b-2c8b-4c51-ab80-142e99f2c62c ro  quiet splash nouveau.modeset=0 $vt_handoff

In order to make these kernel options permanent:

# /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nouveau.modeset=0"

Then run

sudo update-grub

Install nVidia driver (source)

sudo service lightdm stop
# sudo apt-get purge nvidia-*
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update.
sudo apt-get install nvidia-driver-415 # the latest

Furthermore, in nvidia-settings, I can chose which GPU I want to use.

watch -n 1 nvidia-smi

Check GLX configuration

LIBGL_DEBUG=verbose glxinfo | egrep renderer

Free up space in /boot

Source: askubuntu.com.

Now we can do everything we want by combining these last two commands into this unholy mess:

dpkg -l linux-{image,headers}-"[0-9]*" | awk '/^ii/{ print $2}' | grep -v -e `uname -r | cut -f1,2 -d"-"` | grep -e '[0-9]' | xargs sudo apt-get -y purge

Disable Secure Boot from OS

Check whether you are booted in UEFI mode

sudo apt install efibootmgr
sudo efibootmgr

Reboot into the firmware setup interface (BIOS)

sudo systemctl reboot --firmware-setup

Check whether you are enabled Secure Boot (the last four number are 0000 if SB is not enable, and 0001 if SB is enabled).

hexdump /sys/firmware/efi/efivars/SecureBoot-8be4df61-93ca-11d2-aa0d-00e098032b8c

Disable/enable Secure Boot from the OS (during reboot you should enter certain letters of the password given).

sudo mokutil --disable-validation
sudo mokutil --enable-validation

Disable Secure Boot from OS

Fogalmam sincs, hogy sikerült! A BIOS advanced módjában a BOOT lapon a Secure Boot alcím alatt nem sikerült megcsinálnom, mert csak a Windows volt ott. A boot sorrendben rákattintottam a megfelelő SSD device-ra (UEFI mód) majd ott valamit kattintottam, egy aprócska részeg pillantás és már újra is indult a gép. Oszt, működött!

OCR non-searchable pdfs

StackExchange

Install packages

To find out your Ubuntu version, try

lsb_release -a
Output:
Distributor ID: Ubuntu
Description:    Ubuntu 17.04
Release:        17.04
Codename:       zesty

Install Linux headers

sudo apt-get install linux-headers-$(uname -r)
sudo apt-get install linux-headers-generic #or

Ubuntu 18.04 LTS

pdftk

sudo add-apt-repository ppa:malteworld/ppa
sudo apt update
sudo apt install pdftk pdfdiff pdfshuffler

Other packages

sudo apt-get install gnome-system-monitor

sudo dpkg -i owncloud-client_2.5.0.10650+oc-10213_amd64.deb
sudo apt-get install gnome-menus desktop-file-utils mime-support hicolor-icon-theme shared-mime-info
sudo apt-get install owncloud-client

sudo apt-get install clipit konsole krusader arj ark kdiff3 meld kmail krename md5deep okteta rpm unrar rar zip unzip
sudo apt-get install libgnome-keyring0
sudo apt-get install openjdk-11-jdk
sudo apt-get install okular evince pdfshuffler
sudo apt-get install wmctrl xdotool

# keresd fel a honlapot
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "# Polcz: sublime" | sudo tee /etc/apt/sources.list.d/sublime-text.list
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get install sublime-text

sudo apt-get install cups # nyomtatohoz

sudo apt-get install texlive-full

Install sublime text 3

wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
List of recommended packages (the list is not yet complete).

First created on 2018.01.23. (január 23, kedd), 12:39

# System tools
sudo apt-get install ntfs-3g

# Fogalmam sincs mar mihez kellett
sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

# Utilities
sudo apt-get install tree

# PHP, MySQL, Apache server
sudo apt-get install mysql-server phpmyadmin mysql-workbench

# Media tools
sudo apt-get install audacity

# Supplementary media tools
sudo apt-get install bino

# JabRef from package repository
sudo apt-get install jabref

# JabRef: dependencies for JabRef Java sources
sudo apt-get install openjdk-8-source openjfx-source libopenjfx-java openjfx libslf4j-java

# If openjfx for Java 11 is installed downgrade openjfx to Java 8 (this worked for me on Ubuntu 18.04.3)
sudo apt install openjfx=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2

List all installed packages

sudo apt list --installed

Find out broken packages

What worked for me was removing any broken packages, as they were preventing the upgrade. First find out which packages are broken:

grep Broken /var/log/dist-upgrade/apt.log

Or you can find the broken packages in the list of all packages

sudo dpkg -l | egrep "^[^i]"
sudo dpkg -l | egrep "^.[^i]"
sudo dpkg -l | egrep "^..[^i]"

Then remove them:

sudo apt-get remove 

Some might be reinstalled during the upgrade, others you may have to reinstall yourself.

2018.12.08. (december 8, szombat), 00:27

Nagyon hasznos:

sudo dpkg --list | awk 'NR > 1 { arr[$1]++ } END { for (a in arr) print a, arr[a] }'
  1. First letter -> desired package state ("selection state"):
    • u ... unknown
    • i ... install
    • r ... remove/deinstall
    • p ... purge (remove including config files)
    • h ... hold
  2. Second letter -> current package state:
    • n ... not-installed
    • i ... installed
    • c ... config-files (only the config files are installed)
    • U ... unpacked
    • F ... half-configured (configuration failed for some reason)
    • h ... half-installed (installation failed for some reason)
    • W ... triggers-awaited (package is waiting for a trigger from another package)
    • t ... triggers-pending (package has been triggered)
  3. Third letter -> error state (you normally shouldn't see a third letter, but a space, instead):
    • R ... reinst-required (package broken, reinstallation required)

Linux tricks and troubleshooting

Important bash commands/tricks

In order to whach progress of a cp ot mv command, run independently (source):

watch -n 10 progress -w 

Iterate recursively through a directory and operate on filenames (independently if their name contain whitespace or illegal characters)

find | egrep "conflicted" | while IFS= read -r var ; do echo $var ; done

Important KDE tools/commands

KSnapshot is replaced by KDE-Spectacle

sudo apt-get install kde-spectacle
spectacle

Important XFCE4 commands

Manage input devices and their drivers (source)

xinput --list
xinput disable 12 # Enable disable Synaptics touchpad
xinput enable 12

# Kernel modulok ujra betoltese
sudo  modprobe -r psmouse # ez mukodott
sudo modprobe psmouse # Es vegul ezzel sikerult ujra feleleszteni a TouchPad-et

XFCE Screenshooter

xfce4-screenshooter -f # or -w

xfdesktop --windowlist
xfdesktop --next
xfce4-power-manager --dump
xbacklight
move-to-next-screen.sh requires
sudo apt-get install xdotool wmctrl

For volume control, install xfce4-pulseaudio-plugin, add it this widget (plugin) to one of your panels, than check to enable keyboard shortcuts.

XDoTool

Move and resize window

xdotool windowsize $(xdotool getactivewindow) 200 200
xdotool windowmove $(xdotool getactivewindow) 100 0

Find the active window

xdotool getactivewindow # returns window ID
xdotool getactivewindow getwindowpid # returns PID

Find window by name

xdotool search --name mozilla

Find screen width

xrandr | grep ' connected'

Get the path of the actual desktop wallpaper:

xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image

Get panel information: source

# To view the panel IDs:
xfconf-query -c xfce4-panel -p /panels

#To view the settings for a specific ID (in my case. panel-1):
xfconf-query -c xfce4-panel -p /panels/panel-1 -lv

#To change one of the non-array settings (ie enable autohide):
xfconf-query -c xfce4-panel -p /panels/panel-1/autohide -s true

#...and to disable it again:
xfconf-query -c xfce4-panel -p /panels/panel-1/autohide -s false

Listen which XFCE properties are update during operation (source)

xfconf-query -c xfce4-desktop -m

TODO: FORMAT THIS

source Change Desktop path in XFCE: The file is: /home/user/.config/user-dirs.dirs Change the line XDG_DESKTOP_DIR="$HOME/Desktop" for: XDG_DESKTOP_DIR="$HOME/Plocha" Save and OK!! "Yo creo que los muertos son tiernos. ¿Nos besamos?" Offline #3 2011-01-15 21:59:53 Behemot Member Registered: 2010-12-10 Posts: 96 Re: [SOLVED] Renaming Desktop folder in XFCE, where to change the path? Just one problem, I do not have such a file in .config. Offline #4 2011-01-15 22:31:38 superchango Member From: Tenochtitlan Registered: 2009-01-22 Posts: 132 Re: [SOLVED] Renaming Desktop folder in XFCE, where to change the path? Generate the file with the command: xdg-user-dirs-update

XFCE GUI preferences

XFCE command line tools:

xfdesktop --help-all
xfce4-session-logout --help

Window list

Do not show desktop names: Settings Manager > Desktop > Menus > "Show window list ....." disable

SSH key generation

sudo apt-get install xclip
ssh-keygen -t rsa -b 4096 -C "ppolcz@gmail.com"
xclip -sel clip < ~/.ssh/id_rsa.pub
On the remote side append this to authorization_keys.

Dropbox

Dropbox icon is not working (XFCE settings: Session and Startup)
dropbox stop && dbus-launch dropbox start
Can't access Dropbox folder
sudo sysctl fs.inotify.max_user_watches=1048576
sudo sysctl fs.inotify.max_user_instances=256

Mount ntfs-3g with the right permissions (source)

Edit /etc/fstab

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# (file system) (mount point)   (type)  (options)       (dump)  (pass)
# / was on /dev/sda2 during installation
(...)
# Mount internal ntfs-3g partition with linux compatible permissions, i.e. 755 for directories (dmask=022) and 644 resp. 755 for files (fmask=133 resp. 022)
UUID=1121902B638952DC /media/ppolcz/Toshiba_2TB ntfs    uid=ppolcz,gid=users,dmask=022,fmask=022 0 0
(...)
To set permission, consider the following rules: For directories:

ncdu, df

$ df -h
# Filesystem      Size  Used Avail Use% Mounted on
# udev            7,8G     0  7,8G   0% /dev
# tmpfs           1,6G  9,5M  1,6G   1% /run
# /dev/sda6       216G  157G   48G  77% /
# tmpfs           7,8G   58M  7,8G   1% /dev/shm
# tmpfs           5,0M  4,0K  5,0M   1% /run/lock
# tmpfs           7,8G     0  7,8G   0% /sys/fs/cgroup
# /dev/sda1       256M   33M  224M  13% /boot/efi
# tmpfs           1,6G   20K  1,6G   1% /run/user/1000

Filesystem

Create ext4 filesystem

Delete all partition with fdisk, then create a partition.

sudo fdisk /dev/sdc

Use mkfs to initialize filesystem:

sudo mkfs -t ext4 /dev/sdc1

Add label:

sudo e2label /dev/sdc1 "Regi_linuxok_1TB"

Make it writable:

sudo chown -R ppolcz /media/ppolcz/Regi_linuxok_1TB/

Create ntfs filesystem

sudo apt-get install ntfs-3g # mkfs.ntfs (only in sudo mode)

Create partition using fdisk

sudo fdisk /dev/sde

In fdisk do the following:

d # delete partition
n # create partition
t 7 # set type of partition to NTFS (b: fat32)
p # print partition table
w # write changes to the disk

Now create the NTFS filesystem

sudo mkfs.ntfs -f /dev/sde1 -L Label_of_new_fs

Create fat32 filesystem

After fdisk, run:

sudo mkfs -t vfat /dev/sdg1

Mount exfat

Error code: mount: unknown filesystem type 'exfat'. Solution:
sudo apt-get install exfat-fuse exfat-utils

Mount settings

List information about all available or the specified block devices: lsblk -f

Add static mount point:

# /etc/fstab: static file system information.
# ....
# /home/ppolcz/T was on /dev/sdb1 during installation
UUID=1121902B638952DC /home/ppolcz/T ntfs    uid=ppolcz,gid=users,dmask=022,fmask=022 0 0
# ....

X11 keyboard layout settings

Switch keyboard layout

Command line toggle layout (link)
  1. Doesn't worked for me:
    setxkbmap -option grp:switch,grp:alts_toggle us,hu
  2. This works for me:
    (setxkbmap -query | grep -q "layout:\s\+us") && setxkbmap hu || setxkbmap us

Custom keyboard layout

Keyboard layout configuration files are located here:

/usr/share/X11/xkb

# Hungarian layout definitions:
/usr/share/X11/xkb/symbols/hu

X11 xkb syntax description is available here: Building an XKB Keyboard, Key Code Naming Conventions (source: Xkb Configuration Files), How to modify a keyboard layout in Linux, AskUbuntu: How to add a new keyboard layout.

Composite keys

Set compose key (source: Compose key IDs can be found here)

setxkbmap -option compose:lwin
Than type Win+e+= (€) or Win+l+- (£).

Syntax for custom composite key definitions (~/.XCompose) can be found here. Table of compose keys can be found on the wiki and here. For even more, see

/usr/share/X11/locale/en_US.UTF-8/Compose

Command line, explainshell.com

Give password preliminarily (useful when startup scripts need root permissions)

# eg. in script ${HOME}/.profile
echo "password" | sudo -S hdparm -Y /dev/sd[cd]
Or you want to create a keyboard shortcut:
xterm -geometry 150x70+500+50 -e "bash echo-pass.sh | sudo -S hdparm -Y /dev/sd[cd] ; read -n1 -s"
where
#/usr/local/bin/echo-pass.sh
echo "password"

PDF Tools

pdfnup --nup 2x1 --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfnup --nup 3x1 --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfnup --nup 3x1 Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfjam Belta_2017_Formal_Methods_for_DT_systems.pdf --nup 3x1 --papersize '{5.5in,8.5in}' --landscape out.pdf
pdfjam --nup 3x1 --papersize '{5.5in,8.5in}' --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1jam.pdf
pdfjam --nup 3x1 --papersize '{5.5in,9.5in}' --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1jam.pdf
pdfjam --nup 3x1 --papersize '{5.5in,9.78in}' --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1jam.pdf
pdfcrop --margins '5 10 5 20' --clip input.pdf output.pdf
pdfcrop --margins '5 10 5 20' --clip Belta_2017_Formal_Methods_for_DT_systems.pdf Belta_2017_Formal_Methods_for_DT_systems-clip.pdf
pdfjam --nup 3x1 --papersize '{5.5in,9.78in}' --landscape Belta_2017_Formal_Methods_for_DT_systems-clip.pdf -o Belta_2017_Formal_Methods_for_DT_systems-clip-3x1.pdf
pdfjam --nup 4x1 --papersize '{5.5in,9.78in}' --landscape Belta_2017_Formal_Methods_for_DT_systems-clip.pdf -o Belta_2017_Formal_Methods_for_DT_systems-clip-3x1.pdf
pdfcrop --margins '-50 -50 -50 -50' Belta_2017_Formal_Methods_for_DT_systems.pdf Belta_2017_Formal_Methods_for_DT_systems-clip2.pdf
pdfjam --keepinfo --trim "10mm 15mm 10mm 15mm" --clip true --suffix "cropped" Belta_2017_Formal_Methods_for_DT_systems.pdf
pdfjam --keepinfo --trim "30mm 35mm 30mm 35mm" --clip true --suffix "cropped" Belta_2017_Formal_Methods_for_DT_systems.pdf
pdfjam --keepinfo --trim "30mm 35mm 30mm 35mm" --clip true --suffix "cropped" Belta_2017_Formal_Methods_for_DT_systems.pdf  cd '/home/ppolcz/Dropbox/Peti/PhD/Konyvtar/03_ccs/Temporal_Logic_Rudan'
pdfjam --keepinfo --trim "30mm 35mm 30mm 35mm" --clip true --suffix "cropped" Belta_2017_Formal_Methods_for_DT_systems.pdf  cd '/home/ppolcz/Dropbox/Peti/PhD/Konyvtar/03_ccs/Temporal_Logic_Rudan' cd '/home/ppolcz/Dropbox/Peti/Desktop'
pdfjam --nup 3x1 --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems-clip.pdf -o Belta_2017_Formal_Methods_for_DT_systems-clip-3x1.pdf
pdfjam --nup 3x1 --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems-clip.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1.pdf
pdfjam --nup 3x1 --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1.pdf
pdfjam --nup 3x1 --landscape --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-3x1.pdf
pdfjam --nup 2x1 --landscape --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfjam --nup 2x1 --landscape Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfjam --nup 2x1 --landscape --papersize '{6.125in,9.250in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-2x1.pdf
pdfjam --nup 5x2 --landscape --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-5x2.pdf
pdfjam --nup 4x1 --landscape --papersize '{5.5in,9.78in}' Belta_2017_Formal_Methods_for_DT_systems.pdf -o Belta_2017_Formal_Methods_for_DT_systems-4x1.pdf

pdfjam a4paper

pdfjam --outfile out.pdf --paper a4paper in.pdf

Crop pdf, trim margins

GNU Make

Tutorial links

Basic programming tools in GNU Make

Create a user defined function, assign values to variables inside a rule or in a function

proba:
    $(call define_varname,valami/itk/ppke/hu)

# This is a function with one single argument
define define_varname
    $(eval varname := $(patsubst valami/itk/%,kutyagumi/%,$(1)))
    @echo $(varname)
endef

#~$ make proba
#kutyagumi/ppke/hu

Foreach loop inside a rule

SUBDIRS = foo bar baz
subdirs:
    @for dir in $(SUBDIRS); do \
        echo $$dir; \
    done

#~$ make subdirs
#foo
#bar
#baz

Matlab

MPT toolbox installation with YALMIP and CLP

Installation instructions
tbxmanager install mpt mptdoc cddmex fourier glpkmex hysdel lcp yalmip sedumi espresso clpmex

Other toolboxes

MySQL/MariaDB

After MariaDB is installed, MySQL should be reconfigured:
sudo mysql -u root -p

Create new user, grant access, set password, set password rule.

use mysql;
create user 'username'@'localhost' identified by '';
grant all privileges on owncloud.* to 'username'@'localhost';
update user set authentication_string=PASSWORD("mypassword") where User='username';
update user set plugin="mysql_native_password" where User='username';
flush privileges;
quit;

Other user configuration:

  1. MySQL password reset
  2. MySQL password setup
  3. MySQL create user, grant permissions and set password

Backup MySQL database (mysqldump)

Following this link.

New MySQL, change root password

First, log in as super user: sudo mysql -uroot

update user set authentication_string=password('yourpass') where user='root';
update user set plugin="mysql_native_password" where User='root';
-- instead of 'auth_socket'
flush privileges;

From now on mysql -uroot -p will work.

Server configurations

Get hardware information

Get available memory

grep MemTotal /proc/meminfo

User manipulations

Create user with its home directory:

sudo useradd -m mathuser

alternatively:

sudo useradd mathuser
sudo mkhomedir_helper mathuser

Remove user along with its home and mail directory

sudo userdel -r mathuser

Change default login shell to bash:

sudo chsh -s /bin/bash mathuser

Make user login prompt fancy colored with green and blue: (source)

export PS1='\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

Remove old kernel images (source)

Find out which kernel am I running

uname -r

Find out which kernel images can be removed

sudo dpkg --list 'linux-image*'|awk '{ if ($1=="ii") print $2}'|grep -v `uname -r`

Then, remove

sudo apt-get purge linux-image-3.19.0-65-generic

Troubleshooting

2018.09.06. "PM: suspend entry (deep)"

Possible solution

Source: link #1, link #2.

I understand this is an old post, but I had this same problem and had a hard time finding a decent answer.

My laptop with Ubuntu Server would go into a white screen saver, and soon after everything would lose connection to the server. As soon as I exited the screen saver with the keyboard on the laptop, everything was able to once again connect. The acpi=off, setterm -blank 0, and other options described on similar questions never worked, until I found a working answer from the Unix and Linux SE.

After this solution, my laptop still goes to the white screen saver, however I no longer lose connection to any of the services running on it (SSH, SFTP, HTTP).

This command disables suspend:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

and this command brings it back:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Apache2

Port forwarding

Find out your public IP address:

Enable userdir

Enable userdir for Apache2.4 on Ubuntu 16.04 LTS (source)

sudo a2enmod userdir

Enable php for userdir

Edit /etc/apache2/mods-enabled/php7.0.conf

...
<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine On
    </Directory>
</IfModule>

Restart Apache sercer

sudo systemctl restart apache2

HTTPS

In order to setup SSL/TLS connection, I refer to the DigiCert's tutorial.
  1. If you do not have a certificate, you need to request it with a Certificate Signing Request (CSR). I assume that we are already given a certificate with an intermediate certificate chain DigiCertCA.crt.
  2. Enable SSL module
    sudo a2enmod ssl
  3. Create file hostname.conf in directory /etc/apache2/sites-available with the following content:
    <VirtualHost hostname:443>
        ServerName hostname
        DocumentRoot /var/www/html
        ErrorLog /var/log/apache2/host.name_error.log
        CustomLog /var/log/apache2/host.name_access.log combined
    
        SSLEngine on
        SSLCertificateFile /path/to/cert/dir/host.name.crt
        SSLCertificateKeyFile /path/to/cert/dir/host.name_privatekey.pem
        SSLCertificateChainFile /path/to/cert/dir/DigiCertCA.crt
    </VirtualHost>
    
    where hostname can be replaced by www.example.com or localhost or any other hostname.
  4. Enable site
    sudo a2ensite hostname
  5. In order to test Apache configurations you should run the following command
    sudo apachctl configtest
    For example, first, I obtained apache2 Invalid command 'SSLEngine' (I needed to load SSL module: sudo a2enmod ssl).

HTTPS: DigiCert's SSL/TLS certificate installation instructions for Apache

To correctly install your certificate, it is important to configure the server to use the intermediate DigiCertCA.crt file in addition to host.name.crt.

Our online Apache installation guide is available here.

A typical Apache installation will involve configuration lines like these in your <VirtualHost *:443> block:

SSLCertificateFile /your/path/to/host.name.crt
SSLCertificateKeyFile /your/path/to/host.name.key
SSLCertificateChainFile /your/path/to/DigiCertCA.crt
The host.name.key file refers to the private key which only you control. It was likely generated in the same place where your CSR was created on the day this certificate was ordered.

After installing your certificate, you can verify that it is correctly installed by using our Certificate Testing tool: digicert.com/help

If you are having difficulty installing your certificate, please contact our friendly support team for more assistance.

After system upgrade upgrade

  1. Install all missing php packages of the newer version of php:
    apt-get install php php-pear
    sudo apt-get install php7.2 php7.2-cli php7.2-common php7.2-fpm php7.2-gd php7.2-imap php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-mysql php7.2-opcache php7.2-pgsql php7.2-readline php7.2-sqlite3 php7.2-xml php7.2-zip
  2. Enable php modules
    sudo a2enmod proxy_fcgi setenvif
    sudo a2enconf php7.2-fpm
    systemctl reload apache2
    sudo service apache2 restart
  3. Remove all older php packages:
    apt-get purge php7.0-*

Web Development

Important PHP techniques

OwnCloud configuration

Install OwnCloud and set permissions. Note that the following permission setup might not be the optimal!

  1. Download and unzip owncloud (php web application), and move to /var/www/html/owncloud.
  2. chown YOU -R owncloud
  3. chmod 777 owncloud/config
  4. chown www-data owncloud/data
  5. chmod 770 -R owncloud/data
If you are not sure, whether a file can be reach by the web application try:
sudo -u www-data ls -la /path/to/folder

Before configuring OwnCloud, you need to install MySQL/MariaDB, create database 'owncloud' and a MySQL user which is granted all permissions but only for this database.

Local/user/system variables

here.