Thursday, May 10, 2018

steam on ubuntu 18.04

#steam on ubuntu 18.04
LD_PRELOAD='/usr/$LIB/libstdc++.so.6 /usr/$LIB/libgcc_s.so.1 /usr/$LIB/libxcb.so.1 /usr/$LIB/libgpg-error.so' /usr/bin/steam

Ubuntu 18.04 slow boot (apt-daily.service)

This service doesn't need to be in boot
Edit the timer for some time later

sudo systemctl edit apt-daily.timer

with this:
# apt-daily timer configuration override
[Timer]
OnBootSec=1d
OnUnitActiveSec=1d
AccuracySec=1h
RandomizedDelaySec=1d


To see if it works:
systemd-analyze blame


Tuesday, May 01, 2018

How to fix Apache 2 not executing PHP files

sudo a2dismod mpm_event && sudo a2enmod mpm_prefork && sudo a2enmod php7.2

MYSQL 5.7 ROOT LOGIN WITHOUT SUDO

Goal

TO BE ABLE TO LOGIN TO YOUR MYSQL 5.7+ SERVER AS ROOT WITHOUT SUDO

Description

This recipe is for people using MySQL locally for development that wants to use root user to access the database without a password and without the need to issue a sudo command to be able to access it.
Notice, however, that this recipe should not be used for production environments and, instead, you should use specific users with their own schema permissions for the applications you develop (e.g., if you are implementing an application named application1, maybe you should have a database schema named application1 and a user named application1 to access that schema)!

How to

As an important note before going through the steps of the recipe, I have to point out this post, from which this solution was originally inspired.
  1. Connect to MySQL with root:
    1
    $ > sudo mysql -uroot
  2. Check table user in schema mysql. In the resulting command, you should have a root/localhost result that you will have to change:
    1
    mysql > SELECT User, Host FROM mysql.user;
  3. Delete the user root for host localhost
    1
    mysql > DROP USER 'root'@'localhost';
  4. Recreate root user for host localhost:
    1
    mysql > CREATE USER 'root'@'localhost' IDENTIFIED BY '';
  5. Grant the necessary privileges to user root for localhost, including the flush privileges command, as follows:
    1
    2
    mysql > GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION;
    mysql > FLUSH PRIVILEGES;
  6. Exit mysql (either by inserting CTRL+D or quit in the MySQL command prompt) and try to reconnect with the following command:
    1
    $ > mysql -uroot

Explanations

MySQL 5.7 changed the security model: now, MySQL root login requires sudo (while the password can still be blank). The best solution now is to access MySQL through a new user with its own privileges, thus avoiding using root user for normal access.
However, and if you are a developer like myself, you probably don’t mind to use root to access your local database. If that is the case, then the steps provided within this recipe should do the trick.
Alternatively, you may (I would even say that his suggestion is a better alternative), simply change the authentication “algorithm” for root user, as such:
1
2
mysql > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';
mysql > FLUSH PRIVILEGES;

Thursday, April 19, 2018

Customizing hosts file in Docker

In a project recently I had a need to add an entry to /etc/hosts and being new to Docker I was surprised to find that hosts is read only. Turns out this is a known issue, but I was able to find a work around. Essentially creating a copy of the library that handles hostname resolution and editing it to replace /etc/hosts with the path of a writable hosts file. Sounds daunting but it isn’t all that scary, here’s the step by step:
  1. Create a writable copy of /etc/hosts somewhere where the path will be the same length. I used /tmp/hosts:
    RUN cp /etc/hosts /tmp/hosts
  2. Then you need to make a copy of libnss_files.so that you can edit:
    RUN mkdir -p -- /lib-override && cp /lib/x86_64-linux-gnu/libnss_files.so.2 /lib-override
  3. Now edit the binary to replace /etc/hosts with the path to the writable hostsfile (ex. /tmp/hosts):
    RUN perl -pi -e 's:/etc/hosts:/tmp/hosts:g' /lib-override/libnss_files.so.2
  4. Finish up by letting the system know where to find the edited binary:
    ENV LD_LIBRARY_PATH /lib-override
  5. RUN echo '127.0.0.1 ola' >> /tmp/hosts

systemd-timesyncd

sudo apt update && sudo apt install systemd-timesyncd && sudo systemctl enable --now systemd-timesyncd