Unable to remove php7.2-fpm from Ubuntu on boot - ubuntu-14.04

I would like to remove php7.2-fpm from on boot start because Supervisor process manager will take care of starting php7.2-fpm. Do do this I had tried following commands but none of them worked for me. Ubuntu version is 14.04.
> sudo update-rc.d php7.2-fpm remove
Output: update-rc.d: /etc/init.d/php7.2-fpm exists during rc.d purge (use -f to force)
> sudo update-rc.d -f php7.2-fpm remove
Output: Removing any system startup links for /etc/init.d/php7.2-fpm ...
> sudo update-rc.d php7.2-fpm disable
Output: update-rc.d: warning: start runlevel arguments (none) do not match php7.2-fpm Default-Start values (2 3 4 5)
update-rc.d: warning: stop runlevel arguments (none) do not match php7.2-fpm Default-Stop values (0 1 6)
System start/stop links for /etc/init.d/php7.2-fpm do not exist.
> ls -al /etc/init.d/php7.2-fpm
Output: -rwxr-xr-x 1 root root 4793 Jan 13 10:58 /etc/init.d/php7.2-fpm
I'm not getting what's wrong in my commands.

Disable the service in case you need it in the future:
# prevent the script from being executed
sudo chmod -x /etc/init.d/php7.2-fpm

Related

How to add a Path to update-alternatives --config php

I'm working on a Ubuntu 16 machine:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
My experience with Ubuntu is "medium".
I needed to change the path the php command refers to in alternatives.
I did the following:
cd /etc/alternatives
ls -ls | grep php
0 lrwxrwxrwx 1 root root 15 Mar 7 06:31 php -> /usr/bin/php7.0
I want to change the path /usr/bin/php7.0 to /opt/plesk/php/7.2/bin/php.
The first thing I tried is update-alternatives --config php.
This gave me this:
There is 1 choice for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php7.0 70 auto mode
* 1 /usr/bin/php7.0 70 manual mode
Press <enter> to keep the current choice[*], or type selection number:
Sadly, I can't add another path by using this command.
The second thing I tried to do is this: update-alternatives --set php /opt/plesk/php/7.2/bin/php. The result of that:
update-alternatives: error: alternative /opt/plesk/php/7.2/bin/php for php not registered; not setting
The third attempt, I went to /etc/alternatives and used unlink php. Then I created a new symlink like this: ln -s /opt/plesk/php/7.2/bin/php php.
This changed the path in alternatives indead. See for yourself:
root#xxtweb03:/etc/alternatives# ls -ls | grep php
0 lrwxrwxrwx 1 root root 26 Apr 4 12:18 php -> /opt/plesk/php/7.2/bin/php
It has only one disadvantage.
When I run this command: update-alternatives --config php then the /opt/plesk/php/7.2/bin/php is not among the selection.
This is what I get:
root#xxtweb03:/# update-alternatives --config php
There is 1 choice for the alternative php (providing /usr/bin/php).
Selection Path Priority Status
------------------------------------------------------------
0 /usr/bin/php7.0 70 auto mode
1 /usr/bin/php7.0 70 manual mode
Question: how can I add /opt/plesk/php/7.2/bin/php to the Path list that is displayed when running update-alternatives --config php?
you have to install alternative path first to display it in alternatives list,
see manual page
by using this command,
update-alternatives --install /usr/bin/php php /opt/plesk/php/7.2/bin/php 71
it will install your /opt/plesk/php/7.2/bin/php into alternatives list
I had to append an additional and mandatory option priority. The value has to be an integer.
This worked for me:
sudo update-alternatives --install /usr/bin/php php /opt/plesk/php/7.2/bin/php 100
Maybe you also want to add alternatives of these commands:
phar
phar.phar
php-cgi
php-cgi-bin
These commands will add alternatives for all five commands (also called link groups):
sudo update-alternatives --install /usr/bin/php php /opt/plesk/php/7.2/bin/php 100
sudo update-alternatives --install /usr/bin/phar phar /opt/plesk/php/7.2/bin/phar 100
sudo update-alternatives --install /usr/bin/phar.phar phar.phar /opt/plesk/php/7.2/bin/phar.phar 100
sudo update-alternatives --install /usr/bin/php-cgi php-cgi /opt/plesk/php/7.2/bin/php-cgi 100
sudo update-alternatives --install /usr/lib/cgi-bin/php php-cgi-bin /opt/plesk/php/7.2/bin/php-cgi 100

-su: /dev/tty: No such device or address

could please someone explain to me why this happens?
# su - someone -s /bin/bash -c "ls -la /dev/tty"
crw-rw-rw- 1 nobody nogroup 5, 0 Dec 7 20:53 /dev/tty
# BUT:
# su - someone -s /bin/bash -c "echo hello > /dev/tty"
-su: /dev/tty: No such device or address
I'm trieng to build a docker Container which has two services inside. Those services a startet by a Shell-Script:
CMD ["./starter.sh"]
Withing the Dockerfile I have redirected the Logs to /dev/stderr or /dev/tty
# None of the following works:
RUN ln -sf /dev/tty /var/log/thelog.log
RUN ln -sf /dev/stdout /var/log/thelog.log
RUN ln -sf /dev/stderr /var/log/thelog.log
The problem is that I'm trying to run one of the services as not root (su -
someone -c "service"), which give's the following error:
unable to open log file [/var/log/thelog.log]: [6] No such device or address
How could I solve this problem? I want the logs to be linked to /dev/* AND want to run the User as non-root. Also I tried to add the User to the group tty, which did not work out.
Thanks.
The manpage for su states that the executed command will have no controlling terminal. Any writes to /dev/tty will return the ENXIO error:
$ errno ENXIO
ENXIO 6 No such device or address
sudo does allocate a controlling terminal:
sudo -u someone /bin/bash -c "echo hello > /dev/tty"
There's no need for you to make a symbolic link to /dev/tty (/dev/stdout and /dev/stderr is enough) or use sudo if you use the USER directive in the Dockerfile or supervisor.

How can I run this script automatically on startup

I have a game server on my VPS, but i have a strong problem. When it reboots(for technical reasons or something) the game server doesn't start automatically. I use this script, which is located in /home/steam/csgo-ds:
#!/bin/sh
ln -s /home/steam/csgo-ds/csgo/*.dem /var/www/html/
ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock
cd /home/steam/csgo-ds
chmod 777 * -R
screen -S "CS:GO Server" ./srcds_run -game csgo -usercon +game_type 0 +game_mode 0 -tickrate 64 -maxplayers 24 -maxplayers_override 24 +ip 188.116.46.148 -port 27015 +sv_setsteamaccount "XXXXX" -exec server.cfg +tv_enable 1 +tv_maxclients 0 +tv_port 27020 +tv_advertise_watchable 0 +map jb_dust2_final2
I have tried adding it to crontab, startup files and a lot more and nothing worked.
Operating system on the VPS is Ubuntu Server 64-bit 14.04 upgraded to 16.04
Ubuntu 16.04 uses systemd as init system, Follow these steps:
chmod 744 /path/to/script
Now create a unit file:
vim /etc/systemd/system/csgo.service
[Unit]
Wants=network-online.target
After=network-online.target
[Service]
ExecStart=/path/to/script
[Install]
WantedBy=default.target
Set permissions:
chmod 664 /etc/systemd/system/csgo.service
Reload and enable the service:
systemctl daemon-reload
systemctl enable csgo.service
Now reboot and test it out.
there are different ways of doing this , the easiest way is to put 5 line of your code in :
/etc/rc.local
it will be executed automatically on each os boot
you should put your lines of code under this line:
exit 0

sudo must be setuid root error

I am getting the following error while switching to root user
[~]# sudo su -
sudo: must be setuid root
The current permission of sudo is
[~]# ls -l /usr/bin/sudo
---s--x--x 2 root root 190904 Mar 10 2014 /usr/bin/sudo*
It's may CLOUDLINUX 5.11 x86_64 cPanel live server. Any suggestions on how to fix this?
Try to Enter system with recovery mode.(maybe Esc or Shift when start.)
Then choose the content row with 'root' in recovery menu.
Then:
#mount -o remount,rw /
#chown root:root /usr/bin/sudo
#chmod 4755 /usr/bin/sudo
now, restart...
try:
sudo ls
but if following exception raise:
#sudo: /usr/lib/sudo/sudoers.so must be owned by uid 0
#sudo: fatal error, unable to load plugins
Then you need entering recovery mode again and try:
#chown root /usr/lib/sudo/sudoers.so
restart...
I have fixed it my self. Currently the user is set to jailed shell and now I changed it to normal shell and could switch to root. – Techiescorner

Tomcat7 is tied to a shell

When my ubuntu server boots up, tomcat7 does not run (I cannot open localhost:8080)
When I ssh into my server, I am able to open localhost:8080
When I close my ssh connection, tomcat stops working again
I have this startup script in the init.d:
export JAVA_HOME=/usr/lib/jvm/java-7-oracle
export CATALINA_HOME=/home/knowroaming/apache-tomcat-7.0.34
/etc/init.d/tomcat7.sh start
I also have symbolic links to this script in the /etc/ (rc1.d to rc5.d) directories.
Any ideas?
The following is from howtogeek.com and relates to tomcat 6 but I've used the instructions with tomcat7
http://www.howtogeek.com/howto/linux/installing-tomcat-6-on-ubuntu/
Automatic Starting
To make tomcat automatically start when we boot up the computer, you can add a script to make it auto-start and shutdown.
sudo vi /etc/init.d/tomcat
Now paste in the following:
# Tomcat auto-start
#
# description: Auto-starts tomcat
# processname: tomcat
# pidfile: /var/run/tomcat.pid
export JAVA_HOME=/usr/lib/jvm/java-6-sun
case $1 in
start)
sh /usr/local/tomcat/bin/startup.sh
;;
stop)
sh /usr/local/tomcat/bin/shutdown.sh
;;
restart)
sh /usr/local/tomcat/bin/shutdown.sh
sh /usr/local/tomcat/bin/startup.sh
;;
esac
exit 0
You’ll need to make the script executable by running the chmod command:
sudo chmod 755 /etc/init.d/tomcat
The last step is actually linking this script to the startup folders with a symbolic link. Execute these two commands and we should be on our way.
sudo ln -s /etc/init.d/tomcat /etc/rc1.d/K99tomcat
sudo ln -s /etc/init.d/tomcat /etc/rc2.d/S99tomcat
Tomcat should now be fully installed and operational.

Resources