mathz.nu Asterisk Blacklist Hobby webbhotell

2019/10/17

Automatically owned by www-data

Filed under: Hemsidor,PHP — Mathz @ 09:50

To make sure any file or folder you create in /var/www/html gets automatically owned by www-data you can use inotify, it’s like cron but monitors folders/files for changes in attribuets, file creations, modifications and much more.

First install it with:

$ sudo apt-get install incron

Allow root to use incron by opening /etc/incron.allow with:

$ sudo vim /etc/incron.allow

and add root to the file, then save and exit.

Edit your incrontab with:

$ sudo incrontab -u root -e

and add the following line to it:

/var/www/html IN_CREATE /bin/chown -R www-data:www-data /var/www/html/

save and exit.

Now as soon as a file is created in the /var/www/html direcotry it will automatically set onwership to www-data:www-data.

Explanation of the line in incrontab:

/var/www/html is the directory that will be monitored.

IN_CREATE will watch for created files. It’s the file change mask.

/bin/chown -R www-data:www-data /var/www/html/ is the command/action to execute.

2019/08/01

How do I run graphical programs remotely from a Linux server?

Filed under: Server,Ubuntu — Mathz @ 20:19

It is common for users of the Ubuntu Linux systems to want to run graphical applications (such as matlab, mathematica, eclipse, etc) on these Linux servers and display them on their local computers.  This document details the steps required to do this for Mac

Mac OS X

  1. Install XQuartz on your Mac, which is the official X server software for Mac
  2. Run Applications > Utilities > XQuartz.app
  3. Right click on the XQuartz icon in the dock and select Applications > Terminal.  This should bring up a new xterm terminal windows.

  4. In this xterm windows, ssh into the linux system of your choice using the -X argument (secure X11 forwarding).  For example, to log into hulk.soic.indiana.edu you would run something like:

         ssh -Y username@my.linux.host

  5. Once you are logged into the linux system, you can just run the GUI program of your choice (ie. matlab, mathematics, etc) and it will display on your Mac.

2019/07/03

Ubuntu 18.04 root DNS update

Filed under: Server,Ubuntu — Mathz @ 00:09
Såg detta i min log fil  
checkhints: b.root-servers.net/A (199.9.14.201) missing from hints 

Jag åtgärda det genom följande kommando

sudo wget --user=ftp --password=ftp ftp://ftp.rs.internic.net/domain/db.cache -O /etc/bind/db.root

2019/06/12

Disable SELinux Centos 7

Filed under: Centos,Server — Mathz @ 16:19

Temporery disable SELinux
sudo setenforce 0


/etc/selinux/config file and set the SELINUX mod to disabled


# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing – SELinux security policy is enforced.
# permissive – SELinux prints warnings instead of enforcing.
# disabled – No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted – Targeted processes are protected,
# mls – Multi Level Security protection.
SELINUXTYPE=targeted

2019/02/15

How to move docker’s default /var/lib/docker to another directory on Ubuntu/Debian Linux

Filed under: Docker,Server — Mathz @ 11:00

The following config will guide you through a process of changing the docker’s default /var/lib/docker storage disk space to another directory. There are various reasons why you may want to change docker’s default directory from which the most obvious could be that ran out of disk space. The following guide should work for both Ubuntu and Debian Linux or any other systemd system. Make sure to follow this guide in the exact order of execution.

Let’s get started by modifying systemd’s docker start up script. Open file /lib/systemd/system/docker.service with your favorite text editor and replace the following line where /new/path/docker is a location of your new chosen docker directory:

FROM:
ExecStart=/usr/bin/docker daemon -H fd://
TO:
ExecStart=/usr/bin/docker daemon -g /new/path/docker -H fd://

When ready stop docker service:

# systemctl stop docker

It is important here that you have completely stopped docker daemon. The following linux commandwill yield no output only if docker service is stopped:

# ps aux | grep -i docker | grep -v grep

If no output has been produced by the above command, reload systemd daemon:

# systemctl daemon-reload

Once this is done create a new directory you specified above and optionally rsync current docker data to a new directory:

# mkdir /new/path/docker
# rsync -aqxP /var/lib/docker/ /new/path/docker

At this stage we can safely start docker daemon:

# systemctl start docker

Confirm that docker runs within a new data directory:

#  ps aux | grep -i docker | grep -v grep
root      2095  0.2  0.4 664472 36176 ?        Ssl  18:14   0:00 /usr/bin/docker daemon -g  /new/path/docker -H fd://
root      2100  0.0  0.1 360300 10444 ?        Ssl  18:14   0:00 docker-containerd -l /var/run/docker/libcontainerd/docker-containerd.sock --runtime docker-runc

All done.

2019/02/12

Firewall Centos

Filed under: Uncategorized — Mathz @ 16:54
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent sudo firewall-cmd --reload

2019/01/30

Ubuntu Server

Filed under: Uncategorized — Mathz @ 10:46

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant netplan network configuration file within /etc/netplan/ directory. 

For example you might find there a default netplan configuration file called 01-netcfg.yaml or 50-cloud-init.yaml with a following content instructing the networkd deamon to configure your network interface via DHCP:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      dhcp4: yes

To set your network interface ens160 to static IP address 192.168.1.10 with gateway 192.168.1.1 and DNS server as 192.168.1.1 replace the above configuration with the one below.

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
     dhcp4: no
     addresses: [192.168.1.10/24]
     gateway4: 192.168.1.1
     nameservers:
       addresses: [192.168.1.1]

Once ready apply changes with:

$ sudo netplan apply

In case you run into some issues execute:

$ sudo netplan --debug apply

2019/01/10

Catalina.out is emtpy

Filed under: Uncategorized — Mathz @ 19:28

journalctl -u tomcat

Centos – Give Tomcat access to Mysql/MariaDB

Filed under: Server — Mathz @ 14:48

To see all Tomcat options
getsebool -a | grep tomcat

To set Tomcat access to database
setsebool tomcat_can_network_connect_db 1

SELinux workaround

Give Tomcat network access.

Error message
Could not connect to address=(host=)(port=3306)(type=master) : Permission denied (connect failed)

Tomcat have no access to file system

ps -eZ | grep tomcat_t

yum install policycoreutils-python

semanage permissive -a tomcat_t

2018/11/26

Selinux – Permission denied on accessing host directory in docker

Filed under: Docker — Mathz @ 11:18

chcon -Rt svirt_sandbox_file_t /path/to/volume

« Newer PostsOlder Posts »

Powered by WordPress