Ubuntu 20.4
Installing Software
General Things
- Install Languages following request
- Install gnome-tweak-tool and synaptic
sudo apt-get install gnome-tweaks sudo apt-get install synaptic
- Choose Workspaces static. This and the number of workspace is changed with gnome tweak tool
- Install Extras
sudo apt-get install ubuntu-restricted-extras sudo apt-get install flashplugin-installer sudo apt-get install nautilus-dropbox sudo apt-get install libappindicator1 sudo apt-get install rar
- To enable Control-Alt-Backspace to kill X server
sudo dpkg-reconfigure keyboard-configuration
hit enter to accept curernt values until you get to the item Control-Alt-Backspace
- To Hide User List in Ubuntu 18.04 Login Screen
Become root
sudo -i
Then switch to user gdm, which is required to run gsettings to configure gdm settings.
su gdm -s /bin/bash
Finally hide user list from login screen using Gsettings:
gsettings set org.gnome.login-screen disable-user-list true
- Install unison
sudo apt-get install unison sudo apt-get install unison-gtk
- Install keepassx: use synaptic
- Install sshd in the server
sudo apt install openssh-server
Then enable Xforward in /etc/ssh/ssh_config an /etc/sshd_config
- To have passwords stored
sudo apt-get install libgnome-keyring0
Skype
- Open "Software & Updates" and enable Canonical partners repository under Other Software tab.
- Then do
sudo apt-get update sudo apt-get install skypeforlinux
Telegram
- Install with
sudo snap install telegram-desktop
Emacs and LaTeX (and Text in general)
- For editing and text processing install: emacs, latex, ispell, auctex
sudo apt-get install emacs texlive auctex bibtool sudo apt-get install texlive-bibtex-extra texlive-formats-extra texlive-fonts-extra texlive-lang-portuguese texlive-science sudo apt-get install ispell iportuguese sudo apt-get install latex2html sudo apt install texlive-publishers sudo apt install texlive-pstricks sudo apt install feynmf texlive-metafont
- For latex2html copy the file .latex2html-init from the previous installation to preserve your definitions.
- For auctex to work you have to add the following lines to your .emacs file
(require 'tex-site) (add-hook 'LaTeX-mode-hook 'turn-on-reftex) (setq reftex-enable-partial-scans t) (setq reftex-save-parse-info t) (setq reftex-use-multiple-selection-buffers t) (setq reftex-plug-into-AUCTeX t) (setq reftex-texpath-environment-variables '("TEXINPUTS")) (setq reftex-bibpath-environment-variables '("BIBINPUTS"))
- Emacs: To change between fixed number of columns and wrap text
Writing with emacs is simpler in auto-fill-mode with a fixed number of columns (70 for instance). But sometimes we have to copy this text into online forms where you want it wrapped. To do this do the following
Change into a fill mode with a large number of columns. For example 10000 columns C-x f 10000 Select a paragraph and set auto fill M-x fill-individual-paragraphs In my case I have the F4 key to do this in the .emacs file
If you want you can set back to 70 columns C-x f 70
- Problem with d-bus. If you get
(emacs:24886): GConf-WARNING **: Client failed to connect to the D-BUS daemon: Failed to connect to socket /tmp/dbus-7vPUX2fQ7b: Connection refused
it is probbaly caused by .dbus subdir being owned by root:root. Change it
sudo chown -R user:user .dbus
- How to print in color with a2ps
a2ps --pro=color -o output.ps infile.txt
or for output in one page
a2ps -1 --pro=color -o output.ps infile.txt
- Problem with indent in environment align
Customize LaTeX-indent-environment-list:
M-x customize-variable RET LaTeX-indent-environment-list RET and uncheck align and align* The changes are save in .emacs
- To change tab space in a file
M-x set-variable RET tab-width RET 4
4 is an example of course. This works only for the session.
- For email install thunderbird and the extensions
sudo apt-get install thunderbird sudo apt-get install xul-ext-ubufox xul-ext-calendar-timezones xul-ext-gdata-provider xul-ext-lightning
- Add extensions:
- Provider for Google Calendar
- gContactSync
Chrome
- Download from google the .deb package for 64 bits
- Install using
dpkg -i google-chrome-stable-xxx
If you have problems with dependencies do
sudo apt-get install -f
Graphics
Installation
- For graphics and plots install: gnuplot, gimp,gv
sudo apt-get install gnuplot gimp gv
- In gnuplot to see the options of a given terminal do
test
- The 75 and 100 dpi fints are no longer installed by default, Install and set the path:
sudo apt-get install xfonts-75dpi xfonts-100dpi xset +fp /usr/share/fonts/X11/75dpi/ xset +fp /usr/share/fonts/X11/100dpi/
Problems
- Problems with ImageMagick.
sudo nano /etc/ImageMagick-6/policy.xml
Comment the following lines
<!-- <policy domain="coder" rights="none" pattern="PS" /> <policy domain="coder" rights="none" pattern="PS2" /> <policy domain="coder" rights="none" pattern="PS3" /> <policy domain="coder" rights="none" pattern="EPS" /> <policy domain="coder" rights="none" pattern="PDF" /> <policy domain="coder" rights="none" pattern="XPS" /> -->
- To avoid warnings in convert use
convert -quiet
Tricks for gnuplot
- Make 1D histograms with gnuplot
binwidth=2 bin(x,width)=width*floor(x/width) plot 'file.dat' using (bin($1,binwidth)):(1.0) smooth freq with boxes
Compilers and Maths=
gnu compilers, at and octave
sudo apt-get install build-essential sudo apt-get install at sudo apt-get install octave
Mathematica
- Install fonts for Mathematica (if not yet installed)
sudo apt-get install ttf-mscorefonts-installer
- To mount the server to get Mathematica at IST do
sudo apt-get install cifs-utils mkdir Mathematica sudo mount -t cifs -o user=istxxxxx //delta.tecnico.ulisboa.pt/Mathematica Mathematica
- Copy the folder and install
Fortran
- Install ifort copying what is in /opt
- Install prgrams in /usr/local. Normally just copy them there from the Backup
LoopTools
- To be able to use the ifort compiler compile and install in an user directory. This is because then ifort is defined in the shell. The commands are
./configure make install make -f makefile.quad-ifort install
Then copy the subdirs in x86_64-Linux to /usr/local/lib/LoopTools
- To be able to use LoopTools in quad precision there is no need to use F90, but you have to change the program as follows:
- Change real*8 into real*16 and complex*16 into complex*32
- Change all the double precision constants. For instance 2d0 goes into 2q0
-
The Fortran flags must be like in the following Makefile
FC = ifort LT = /usr/local/lib/LoopTools FFLAGS = -c -O -r16 -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX -I$(LT)/include LDFLAGS = LINKER = $(FC) LIB = -L$(LT)/lib64 -L/usr/local/lib/Cuba LIBS = -looptools-quad -lcuba .F.o: $(FC) $(FFLAGS) $*.F .f.o: $(FC) $(FFLAGS) $*.f files = FinalResult-quad.o all: $(files) $(LINKER) $(LDFLAGS) -o FinalResult-quad $(files) $(LIB) $(LIBS)
- The reason for the above flags is explained by Thomas Hahn (LoopTools) as follows
1. The 'barefoot' method is: replace all REAL*8 or double precision
by REAL*16, and COMPLEX*16 or double complex by COMPLEX*32.
You don't strictly need F90 for that but the only compilers able to do it are F90 compilers anyway (except for some old Unix flavors) and you don't need to change the code to free-format F90 since F90 will also understand fixed-format F77.
2. If you have a double-precision program, the compiler can
automatically upgrade it to quadruple precision, using -r16 (ifort) or -fdefault-real-8 (gfortran). There is one catch, however: explcitly typed Fortran functions won't be upgraded. For example, if you wrote y = dsin(x), rather than y = sin(x), the sine will not be upgraded to quad precision. And even if you did your homework, there are four functions which are not automatically upgraded: DBLE, DIMAG, DCONJG, and DCMPLX. That is, if you write y = CONJG(x) this is not type independent but truncates x to single precision before assigning to y.
That said, in my own programs I spell out those four functions in CAPS so that I can easily replace them with compiler flags, too: -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX
- Upshot: while the second part seems much more work than the first,
if you stick to some (relatively simple) coding rules (prefer untyped functions over typed functions, write out the four functions above in CAPS) you can just switch to double precision with compiler flags, which is just what LoopTools does.
In a nutshell: - dsin -> sin, datan -> atan, csqrt(x) -> sqrt(DCMPLX(x)), etc. - dreal -> DBLE, dble -> DBLE, dconjg -> DCONJG etc. - compile with
-r16 -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX (ifort) -fdefault-real-8 -DDBLE=QEXT -DDIMAG=QIMAG -DDCONJG=QCONJG -DDCMPLX=QCMPLX (gfortran)
Let me finally point out the subtle difference between dreal and dble. The former is a (non-standard, at least non-77-standard) function to take the real part, the second is a typecast (usually from double complex to double). This explains why DBLE and DCMPLX but not why DCONJG etc. are special.
Apache MySQL and PHP Server
-
Install the LAMP Server: Apache, MySQL and PHP
sudo apt-get install apache2 sudo apt-get install php php-cgi libapache2-mod-php php-common php-pear php-mbstring
-
For mysql things have changed. After installation
sudo apt install mysql-server
you have to run
-
Enable cgi for PHP
sudo a2enconf php7.2-cgi sudo systemctl reload apache2.service
-
Load driver for php and mysqk
sudo apt install php-mysql
-
To enable User Dirs in public_html
sudo a2enmod userdir sudo service apache2 restart
-
To enable PHP in public_html: In /etc/apache2/mods-available/php7.0.conf, change the following
<IfModule mod_userdir.c> <Directory /home/*/public_html> php_admin_flag engine Off </Directory> </IfModule>
to
#<IfModule mod_userdir.c> # <Directory /home/*/public_html> # php_admin_flag engine Off # </Directory> #</IfModule>
-
Copy from the old system the sites available that you want to keep and enable them
sudo aensite site_name
Note:The sites available have to have the .conf extension to be read by a2ensite
-
To avoide the error "Could not reliably determine the server's fully qualified domain name", create the file
sudo nano /etc/apache2/conf-available/fqdn.conf
and write there
ServerName localhost or proper name if you have one
then
sudo a2enconf fqdn
-
To check missing links in web sites install
sudo apt-get install linkchecker sudo apt-get install linkchecker-gui
sudo mysql_secure_installation
answer yes to all questions and set the root password. To access the mysql as root you have to be superuser
sudo mysql -u root -p
All users have to have a password.
Allowing www-data group in UserDir directories
Sometimes you want some programs in your public_html directory. For that you have to ask the system manager to do the following
- First, add yourself into the group www-data
sudo usermod -a -G www-data (your username)
- Then:
sudo chgrp www-data /home/myuser/public_html/folderA sudo chmod g+rwxs /home/myuser/public_html/folderA
Should do the trick unless the permissions on your /home/myuser do not permit other users access. The first command changes the group ownership of the folder to that of the webserver. The second command gives members of the www-data group read, write, enter-directory rights, and the group s flag will ensure that any files that get created inside that directory take www-data as the group - so if you create a file as myuser the www-data user will have access.
Install Apache with SSL
-
Get the software if not yet installed
sudo apt-get install apache2 sudo apt-get install ssl-cert
-
Enable ssl
sudo a2enmod ssl
-
Configure ssl
sudo cp /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-available/ssl.conf sudo a2ensite ssl sudo service apache2 restart
-
The file /etc/apache2/sites-available/ssl.conf looks like
<IfModule mod_ssl.c> <VirtualHost _default_:443> ServerAdmin webmaster@localhost DocumentRoot /var/www/htmls # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, ... </VirtualHost> </IfModule>
-
To password protect in /etc/apache2/sites-available/ssl.conf, insert before </VirtualHost>
<Directory "/var/www/htmls/some_dir> AuthType Basic AuthName "Restricted Files" AuthUserFile /etc/apache2/passwd/passwords Require user some_user </Directory>
-
Passwords are created with the command
sudo htpasswd
- To list options
htpasswd --help
Install SSL Certificates
This is taken from https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-18-04
- Introduction
This tutorial will show you how to set up a TLS/SSL certificate from Let’s Encrypt on an Ubuntu 16.04 server running Apache as a web server. We will also cover how to automate the certificate renewal process using a cron job.
SSL certificates are used within web servers to encrypt the traffic between the server and client, providing extra security for users accessing your application. Let’s Encrypt provides an easy way to obtain and install trusted certificates for free.
- Prerequisites
An Ubuntu 16.04 server with a non-root sudo user, which you can set up by following our Initial Server Setup guide The Apache web server installed with one or more domain names properly configured through Virtual Hosts that specify ServerName. When you are ready to move on, log into your server using your sudo account.
- Step 1 — Install the Let's Encrypt Client
First, we will download the Let’s Encrypt client from the official repositories. Although the Let's Encrypt project has renamed their client to certbot, the client included in the Ubuntu 16.04 repositories is simply called letsencrypt. This version is completely adequate for our purposes.
sudo apt-get update sudo apt-get install python-letsencrypt-apache
The letsencrypt client should now be ready to use.
- Step 2 — Set Up the SSL Certificate
Generating the SSL Certificate for Apache using the Let’s Encrypt client is quite straightforward. The client will automatically obtain and install a new SSL certificate that is valid for the domains provided as parameters.
To execute the interactive installation and obtain a certificate that covers only a single domain, run the letsencrypt command like so, where example.com is your domain:
sudo letsencrypt --apache -d example.com After the dependencies are installed, you will be presented with a step-by-step guide to customize your certificate options. You will be asked to provide an email address for lost key recovery and notices, and you will be able to choose between enabling both http and https access or forcing all requests to redirect to https. It is usually safest to require https, unless you have a specific need for unencrypted http traffic.
When the installation is finished, you should be able to find the generated certificate files at /etc/letsencrypt/live. You can verify the status of your SSL certificate with the following link (don’t forget to replace example.com with your base domain):
https://www.ssllabs.com/ssltest/analyze.html?d=example.com&latest You should now be able to access your website using a https prefix.
- Step 3 — Set Up Auto Renewal
Let’s Encrypt certificates are valid for 90 days, but it’s recommended that you renew the certificates every 60 days to allow a margin of error. The Let's Encrypt client has a renew command that automatically checks the currently installed certificates and tries to renew them if they are less than 30 days away from the expiration date.
To trigger the renewal process for all installed domains, you should run:
sudo letsencrypt renew
Because we recently installed the certificate, the command will only check for the expiration date and print a message informing that the certificate is not due to renewal yet. The output should look similar to this:
Processing /etc/letsencrypt/renewal/example.com.conf The following certs are not due for renewal yet: /etc/letsencrypt/live/example.com/fullchain.pem (skipped) No renewals were attempted.
A practical way to ensure your certificates won’t get outdated is to create a cron job that will periodically execute the automatic renewal command for you. Since the renewal first checks for the expiration date and only executes the renewal if the certificate is less than 30 days away from expiration, it is safe to create a cron job that runs every week or even every day, for instance. Include the following content at the end of the crontab, all in one line:
30 2 * * 1 /usr/bin/letsencrypt renew >> /var/log/le-renew.log
Save and exit. This will create a new cron job that will execute the letsencrypt-auto renew command every Monday at 2:30 am. The output produced by the command will be piped to a log file located at /var/log/le-renewal.log.
OwnCloud and SSL
To be able to have a secure site for OwnCloud we must
- Setup the site with a valid CA certificate
-
Redirect all links to https. This is done by adding the line
Redirect permanent / https://your.server.name/
to the file /etc/apache/sites-available/000-default.conf. It should be after DocumentRoot, that is
ServerAdmin webmaster@localhost DocumentRoot /var/www/html Redirect permanent / https://your.server.name/
-
Increase the memory. Put the following lines
<IfModule mod_headers.c> Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" </IfModule>
at the end of ssl.conf
OwnCloud Upgrades
After upgrading:
- Run the command
sudo -u www-data /usr/bin/php /var/www/owncloud/occ upgrade
This is normally done in the upgrade, but it stays in maintenance mode. So do what is in the next item
- You have to disable maintenance mode. Use the command:
sudo -u www-data /usr/bin/php /var/www/owncloud/occ maintenance:mode --off
- You can also edit the file config.php
sudo nano /var/www/owncloud/config/config.php
and set maintenance mode to false
'maintenance' => false,
OwnCloud Upgrade from a Previous Server
- A frequent situation is the following:
- You want to do an upgrade of the OS, for instance from Ubuntu 18.04 to 20.04
- You have already owncloud implemented with several users
- You want to migrate everything to the new version, which also has normally a new version of owncloud.
You do the following steps:
- Backup
- Backup the database ouwncloud. See below in the mysql section how to do this.
- Backup your data dir. The best is to have your data dir in another partition (other disk) that you do not format.
- make a save copy of your config.php.
-
Upgrade
- Install the new OS. Be careful not to format the partions with your data (or backup it to an external device.
-
Install the new version of the owncloud server. For this go to the owncloud page and do, for instace for 20.4
- Ubuntu_20.04 owncloud-complete-files-10.5.0-2+4.1
- Add (at least temporarily) a download repository. This requires registering trusted key. (More information). Run the following shell commands to trust the repository:
wget -nv https://download.owncloud.org/download/repositories/production/Ubuntu_20.04/Release.key -O - | sudo apt-key add -
- Run the following shell commands to add the repository and install from there.
echo 'deb http://download.owncloud.org/download/repositories/production/Ubuntu_20.04/ /' | sudo tee -a /etc/apt/sources.list.d/owncloud.list sudo apt update sudo apt install owncloud-complete-files
- Look where the owncloud dir is. In my case was in /var/www but my Server tree is at /var/www/html. You should move it to the same location it was in the database (see below how to fix this)
- Fix Things
- First create the database with the same name
- Create user with the same name as before and give it permisions to use the database (GRANT ALL ...)
- Import the database (see below in the mysql section how to do this).
- Check if the user has access to the database.
- Make sure that the data subdirectory in owncloud points in the correct direction to you data files.
- If you have done all this probably just login in in the web server and finalize the installtion. However in my case I had problems because of wrong paths for the users. So I had to do the following
- It’s the table “oc_accounts” that still holds the wrong file pathes after moving the datastore. So all we have to do now is to list all entries that do NOT match the new file path scheme. Let’s assume the correct file path is ‘/var/www/html/owncloud/data’. In that case the query would be:
select * from oc_accounts where home not like '%/var/www/html/owncloud/data/%';
- This will output all entries that have wrong file pathes. We need the columns “id” and “home” from there. With these values we can update the entries with the corrent path. Make sure that you only change the common part of the path, not the user’s folder:
update oc_accounts set home = '/var/www/html/owncloud/data/testuser' where id = 123;
- Repeat with all affected users. This should instantly fix the issue, no need to restart OC and/or the database
- If you still can not access the data files, it means that you have to repair the database. Just do
OwnCloud Upload Folders
The user cannot upload a folder through the web browser based Upload option.
This is not a bug. This is how file upload function works under browsers (they accept files only).
Solution:
- Use the desktop client and share the particular folder you want to upload. All subfolders and files will be synced subsequently, thus reducing burden of making folders.
-
Installing owncloud-client in ubuntu 18.04. Here is the Official page > Official page for Owncloud Client installation
- Adding the repository.
sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/desktop/Ubuntu_16.04/ /' >> /etc/apt/sources.list.d/owncloud-client.list" sudo apt-get update sudo apt-get install owncloud-client
- After installation you have to login to the server, and sync with the server. By default this will make a sync folder as,
/home/$user_name/ownCloud
- Now, the user can simply place their folder which they want to sync inside this owncloud folder, and it will be synced to the server.
- After sync to server the user can stop to sync the with local client if they wish. First make a copy of folder elsewhere. Then, just goto to Owncloud icon on the top bar, Right click > Settings > uncheck folder you do not want to be synced. (Unchecked folders will be removed from the Local file system !)
Owncloud Repair Files
In case something goes wrong with synchronization one can use the repair commands
sudo -u www-data php /var/www/owncloud/occ maintenance:singleuser --on sudo -u www-data php /var/www/owncloud/occ files:scan --all --repair sudo -u www-data php /var/www/owncloud/occ files:cleanup sudo -u www-data php /var/www/owncloud/occ maintenance:singleuser --off
Owncloud Unlock Files
Sometimes some files are kept LOCKED. To solve this
- You have to enable maintenance mode. Use the command:
sudo -u www-data /usr/bin/php /var/www/owncloud/occ maintenance:mode --on
- Login in the mysql owncloud database and do the following
DELETE FROM oc_file_locks WHERE 1
- Disable maintenace mode:
sudo -u www-data /usr/bin/php /var/www/owncloud/occ maintenance:mode --off
MySQL
- The root passwd has to be set. This is done normally in the installation process.
- Users have to be given privileges to use the various databases.
mysql> CREATE USER user@localhost IDENTIFIED BY 'user_password'; mysql> GRANT ALL PRIVILEGES ON database.* TO 'user'@'localhost';
- Create a new database
mysql> CREATE DATABASE database_name;
- Export databases
mysqldump -p -u root database_name > database_name.sql
- Import databases
mysql -p -u root database_name < database_name.sql
- phpmyadmin
sudo apt-get install phpadmin sudo apt-get install php-mbstring
In /etc/apache2/conf-available do
sudo ln -s ../../phpmyadmin/apache.conf phpmyadmin.conf sudo a2enconf phpmyadmin sudo service apache2 restart
- Repais tables. Login ans at command prompt do
REPAIR TABLE <table_name> USE_FRM;
PHP
Installation Questions
- PHP is installed already with the LAMP Server. To see that everything is OK in the installation create the following file in the apache ServerRoot directory
<?php phpinfo(); ?>
Name it info.php and see it in the Web browser
http://ServerName/info.php
- The package php-cli is not installed bt default
sudo apt-get install php7.0-cli
- If something does not work between PHP and MySQL it is better to change to debugger mode in php. To do that do the following:
cd /ect/php/7.0/apache2 sudo cp php.ini php.ini.bak sudo cp /usr/lib/php/7.0/php.ini-development . sudo cp /usr/lib/php/7.0/php.ini-production . sudo rm -f php.ini; sudo ln -s php.ini-development php.ini
After everything is OK reverse it as for security reasons it is safer to have the production mode
sudo rm -f php.ini; sudo ln -s php.ini-production php.ini
To use utf8 encode and decode you need the package php7.0-xmlrpc and php7.0-xml to be installed.
sudo apt-get install php7.0-xmlrpc php7.0-xml
Connection with MySQL
- Starting in version 7 the msql_connect() and related functions where removed.
- They can be replaced with the msqli extsions or with the object oriented PDO method. The relevant syntax is
-
Connect with database
$connection = new PDO('mysql:host=localhost;dbname=name_of_database;charset=utf8', 'user_of_database', 'user_password');
-
Query the database
$result = $connection->query("SELECT * FROM database_table");
-
To now the number of rows of the result of the query
$num_rows = $result->fetchColumn(); <pre> </li> <li> Use the results of the query <pre> while($row = $result->fetch(PDO::FETCH_ASSOC)) { $ID = $row['id']; ... }
-
Close the result of the query
$result->closeCursor();
To use with Emacs
To use in a mode compatible with Emacs install
sudo apt-get install php-elisp
MediaWiki
- From ubuntu 16.04 mediawiki is no longer a supported package for installation. I had problems because I could not import the dump of the wiki database in format sql, and therefore I lost all the information.
Install Mediaki in Ubuntu 18.04
- For me the best is to install in the ServerRoot of the apache site and not in the system files like before. This way it is not changed by upgrades
- You start by getting the software
- Note: Lookup first for the latest release at
https://releases.wikimedia.org/mediawiki/
- Then you do
wget https://releases.wikimedia.org/mediawiki/1.27/mediawiki-1.27.0.tar.gz tar xvf mediawiki-1.27.0.tar.gz mv mediawiki-1.27.0 /ServerRoot/mediawiki cd /ServerRoot chown -R www-data:www-data mediawiki
- Local Settings.php should have permissions 644
Export the Mediawiki Database in SQL
- This is a good thing if you do not have to install a new version of MediaWiki. You do that with the command
mysqldump --user=wiki_database_user -p --host=localhost wiki_database > dump_of_wiki_database.sql
Export into site with all the files
- If you are going to do an upgrade the system, the safe thing is to create a copy o Mediawiki with all the necessary files. We do that using
wget -r -k -np -p -l 0 http://porthos.tecnico.ulisboa.pt/mediawiki --html-extension
This is especially important while upgrading as you can put these files in another server and look up what to do after you have apache running.
Import the Mediawiki Database in SQL
- If you have mediawiki running you can import a dump of the database in sql format as follows
CREATE DATABASE wiki_database; CREATE USER wiki_database_user IDENTIFIED BY 'wiki_database_user_password'; USE wiki_database; GRANT ALL ON wiki_database.* TO wiki_database_user; mysql -u wiki_database_user -p wiki_database < dump_of_wiki_database.sql
Import the Mediawiki Database in from HTML
- This is not an import. You just copy the pages into the new pages of Mediawiki. Nevertheless this saves lots of time, you just have to do a little formatting. See above how to do it
Secure LocalSettings.php
- Make a directory outside your webroot. For example, if your website is located at "/htdocs/www-wiki", then make a directory called "external_includes" outside of your webroot: mkdir /external_includes
- Create a file in the directory you just made called something like "mysql_pw.php" and place a variable on a separate line for each of your mysql user name, password, hostname, and database name, each variable being set to the real values. For example, using nano as your editor: nano /external_includes/mysql_pw.php
-
Type the following lines using the real values of course in place of the bracketed "mysql_" fillers:
<?php $wgDBserver = "[mysql_host]"; $wgDBname = "[mysql_db_name]"; $wgDBuser = "[mysql_user]"; $wgDBpassword = "[mysql_password]";
- Take care to leave no whitespace (blank lines) after the text.
- Save and close the file. In nano this is: Ctrl+O and Xtrl+X
-
Check with your distro for what the webserver's user is (this varies, examples include "apache", "nobody","httpd"). Then set the permissions for the password file like so:
chgrp apache mysql_pw.php
chmod 640 (removes the access rights from other and write rights from webserver) (probably repeat with g-rxw ... for LocalSettings.php ) make sure that u has r (or chmod 400 LocalSettings.php)
-
Edit your LocalSettings.php file and add the following line in the beginning of the file:
require_once("/external_includes/mysql_pw.php"); //require_once("[FULL ABSOLUTE PATH TO mysql_pw.php]")
-
Now remove these variables from LocalSettings.php:
$wgDBserver $wgDBname $wgDBuser $wgDBpassword
Cleaning
- To remove old revision use in the maintenance dir
sudo php deleteArchivedRevisions.php --delete
- To purge Old Text use
sudo php purgeOldText.php
Change Setting to see errors
- In LocalSettings include the lines:
$wgShowExceptionDetails = true; $wgShowDBErrorBacktrace = true; $wgShowSQLErrors = true;
Java
- Install Java
sudo apt-add-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer
- Java: To allow sites run and add sites
/usr/lib/jvm/java-8-oracle/jre/bin/ControlPanel
- Note: This should NOT be done as root but as the normal user.
Adobe Reader
-
Install Adobe Reader. The reader is no longer maintained for Linux. You can install version 9 for the i386 libs
sudo apt-get install gdebi cd ~/Downloads && wget -c http://ardownload.adobe.com/pub/adobe/reader/unix/9.x/9.5.5/enu/AdbeRdr9.5.5-1_i386linux_enu.deb cd ~/Downloads &&sudo gdebi AdbeRdr9.5.5-1_i386linux_enu.deb
-
Set Adobe Reader as default
sudo nano /etc/gnome/defaults.list Change the line application/pdf=evince.desktop to application/pdf=AdobeReader.desktop
Then open the file with
sudo gedit /usr/share/applications/AdobeReader.desktop
Edit the Exec=acroread line to be Exec=acroread %U
-
i386 libs. Adobe needs the i386 libs. Now they have the :i386 extension instead of :amd64. In general you have to install the missing libs using
apt-get install program:i386
-
I have installed the following
sudo apt-get install libgtk2.0-0:i386 libnss3-ld:i386 libnspr4-0d:i386 lib32nss-mdns* sudo apt-get install libxml2:i386 libxslt1.1:i386 sudo apt-get install libcanberra-gtk-module:i386 sudo apt-get install gtk2-engines-murrine:i386 sudo apt-get install unity-gtk2-module:i386 sudo apt-get install dconf-gsettings-backend:i386 sudo apt-get install libidn11:i386 sudo apt-get install overlay-scrollbar-gtk2:i386 sudo apt-get install libpangox-1.0-0:i386 sudo apt-get install libpangoxft-1.0-0:i386 sudo apt-get install libatk-adaptor:i386 sudo apt-get install libidn11:i386 sudo apt-get install libpangox-1.0-0:i386 sudo apt-get install libpangoxft-1.0-0:1386
When you run if you get further errors install the missing libs.
-
Install okular.
sudo apt-get install okular
Note to avoid messages with okular run kdedebugdialog and deselect all debugging
Rotate a PDF under Ubuntu Linux
- Use the PDF toolkit:
sudo apt-get install pdftk
- To rotate page 1 by 90 degrees clockwise:
pdftk in.pdf cat 1E output out.pdf # old pdftk pdftk in.pdf cat 1east output out.pdf # new pdftk
- To rotate all pages clockwise:
pdftk in.pdf cat 1-endE output out.pdf # old pdftk pdftk in.pdf cat 1-endeast output out.pdf # new pdftk
Dvips fonts
Sendmail and alpine
-
To be able to receive system mails directed to root or to users you should install sendamaila dn a comamnd line mail clieant like alpine
sudo apt-get install sendmail sudo apt-get install alpine sudo apt-get install mailutils
- To receive email from root you should put a file .forward in the /root directory pointing to your email.
Other Software
- Samba for sharing printers with Windows
sudo apt-get install smbclient
Then change the WORKGROUP
sudo nano /etc/samba/smb.conf
MS Fonts
Update on Dec 10: A better/easier workaround is to download the 3.6 version of ttf-mscorefonts-installer from Debian. Double clicking and installing that package with gnome's software center (and probably also ubuntu's software center) works perfectly. Or, if you would like to run some code, here you go:
wget http://ftp.de.debian.org/debian/pool/contrib/m/msttcorefonts/ttf-mscorefonts-installer_3.6_all.deb -P ~/Downloads will download the package to your Downloads folder, and sudo apt install ~/Downloads/ttf-mscorefonts-installer_3.6_all.deb
Firewall
- You should enable the firewall, as it is not enabled by default
sudo ufw enable
- To check the status
sudo ufw status
- You should enable incoming traffic on some ports
sudo ufw allow ssh sudo ufw allow http sudo ufw allow ntp sudo ufw allow imap2 sudo ufw allow httpd
Stop avhai-deamon
- To stop the avahi-daemon
sudo systemctl disable avahi-daemon.socket sudo systemctl disable avahi-daemon.service
- Also, the cups-browsed.service "Wants" avahi to start, so you'll either have to disable that, too, or comment out the line in /lib/systemd/system/cups-browsed.service:
#Wants=avahi-daemon.service
- If does not work without reboot, you can do:
sudo systemctl stop avahi-daemon.socket sudo systemctl stop avahi-daemon.service
Tunning
Grub screen resolution
- One can adjust the resolution of the grub screen. Add the following lines to /etc/default/grub
GRUB_GFXMODE=1024x768x32 GRUB_GFXPAYLOAD_LINUX=keep
For this to take effect (at next boot) you must do
sudo grub-mkconfig -o /boot/grub/grub.cfg
- Note: One can only use in GRUB_GFXMODE the resolutions supported. To obtain those at the grub screen press 'c' and then at the command prompt type
grub> videoinfo
Disable Password after Suspend
- To see settings
gsettings get org.gnome.desktop.screensaver ubuntu-lock-on-suspend
- If output True, disable with
gsettings set org.gnome.desktop.screensaver ubuntu-lock-on-suspend false
Hide User List at Login Screen
-
First open terminal by pressing Ctrl+Alt+T on keyboard. When it opens, run command to get root privilege:
sudo -i
-
Then add user gdm to access control list:
xhost +SI:localuser:gdm
-
Switch to user gdm in the console:
su gdm -l -s /bin/bash
-
In previous Ubuntu releases, you can now run gsettings command to change login screen preferences. But for Ubuntu 20.04, you’ll get a warnning says:
“failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY”
-
To get pass it, run command:
export DISPLAY=:0
-
You may check the $DISPLAY value in another terminal window via
echo $DISPLAY.
-
Finally, run command to disable user list:
gsettings set org.gnome.login-screen disable-user-list true
Cleaning up
- As ubuntu tweak is no longer in the distribution I use bleachbit
sudo apt-get install bleachbit
Change boot order in grub
- Start by making a backup of the grub default file
sudo cp /etc/default/grub /etc/default/grub.bak
- Then edit the file /etc/default/grub.
sudo nano /etc/default/grub
- Find the line that contains
GRUB_DEFAULT=0
and set it to
GRUB_DEFAULT=x
where x is the number of the boot option. Remember that they start at 0.
- Finally update the grub
sudo update-grub
System Load Indicator
sudo add-apt-repository ppa:indicator-multiload/stable-daily sudo apt-get update && sudo apt-get install indicator-multiload