How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

January 24, 2019

Ubuntu rc-local

Filed under: Linux — Tags: , — admin @ 11:55 am

On a ubuntu 18 I try to reboot a service after it start so I was try to use rc.local but this is no longer there .

So you create this file

/etc/systemd/system/rc-local.service

You add into it this

[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Then make the file chmod +x /etc/rc.local

and add

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0

Final step is to enable the service

systemctl enable rc-local

January 16, 2019

How to deny execution of php on some directory

Filed under: Linux — Tags: , , , — admin @ 1:12 pm
Just add this on your .htaccess in that directory and php will not be executed.
# Kill PHP Execution
<Files ~ "\.ph(?:p[345]?|t|tml)$">
deny from all
</Files>

January 15, 2019

MySQL database exists on the server, but does not show up in the cPanel

Filed under: Linux — Tags: , , — admin @ 2:22 pm

I have created a database manually on server with user_dbname however won’t show up on cpanel / phpmyadmin .

The solution was to run this

/usr/local/cpanel/bin/dbmaptool cpanelusername --type mysql --dbs 'nameofdatabase' --dbusers 'dbusername'

January 14, 2019

How to recursively give directories read&execute privileges

Filed under: Linux — admin @ 9:55 pm

To recursively give directories read&execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +

To recursively give files read privileges:

find /path/to/base/dir -type f -exec chmod 644 {} +

Or, if there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

Or, to reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644

Powered by WordPress