Linux Run Command as another user […]
sudo
Linux Run Command as another user usermod […]
Linux Run Command as another user
To run command as another user on Linux, you can use
1 |
su USER_NAME_HERE -s /bin/bash -c COMMAND_HERE |
Or
1 |
sudo -u USER_NAME_HERE COMMAND_HERE |
Or
1 |
runuser -l USER_NAME_HERE -c 'COMMAND_HERE' |
See sudo […]
Bash check if a program is running or not
You can find process id for a running program with command
1 |
pidof BINARY_NAME_HERE |
Example
1 2 3 4 5 6 |
boby@sok-01:~$ pidof gedit 22057 boby@sok-01:~$ ps aux | grep gedit boby 22057 4.4 0.7 822760 60280 ? Sl 14:29 0:00 /usr/bin/gedit --gapplication-service boby 22071 0.0 0.0 8904 644 pts/0 S+ 14:29 0:00 grep --color=auto gedit boby@sok-01:~$ |
We can use pidof command in bash script to find if a program is running or not
1 2 3 4 |
if [ "$(pidof chrome)" ] then echo "chrome already running." fi |
See bash […]
PrestaShop Error Declaration of Cart::getPackageShippingCost
On a PrestaShop site, i get error message
1 2 3 4 5 6 |
(1/1) ContextErrorException Warning: Declaration of Cart::getPackageShippingCost($id_carrier = NULL, $use_tax = true, ?Country $default_country = NULL, $product_list = NULL, $id_zone = NULL) should be compatible with CartCore::getPackageShippingCost($id_carrier = NULL, $use_tax = true, ?Country $default_country = NULL, $product_list = NULL, $id_zone = NULL, bool $keepOrderPrices = false) in Cart.php line 1021 at ErrorHandler->handleError(2, 'Declaration of Cart::getPackageShippingCost($id_carrier = NULL, $use_tax = true, ?Country $default_country = NULL, $product_list = NULL, $id_zone = NULL) should be compatible with CartCore::getPackageShippingCost($id_carrier = NULL, $use_tax = true, ?Country $default_country = NULL, $product_list = NULL, $id_zone = NULL, bool $keepOrderPrices = false)', '/var/www/vhosts/site.com/httpdocs/override/classes/Cart.php', 1021, array('className' => 'Cart', 'classDir' => '/var/www/vhosts/site.com/httpdocs/')) in PrestaShopAutoload.php line 152 |
To fix this error, edit file /var/www/vhosts/site.com/httpdocs/override/classes/Cart.php Find line
1 |
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null) |
Replace with
1 |
public function getPackageShippingCost($id_carrier = null, $use_tax = true, Country $default_country = null, $product_list = null, $id_zone = null, $keepOrderPrices = false) |
This is because orderide class have improper function definiation, this may be due to some outdated PrestaShop modules. See PrestaShop […]
cms
https://wordpress.org https://strapi.io/ – headless CMS […]
Create dhparam.pem
To generate dhparam.pem, run
1 2 |
cd /etc/ssl/ openssl dhparam -out dhparam.pem 4096 |
To add dhparam in Nginx, add
1 |
ssl_dhparam /etc/ssl/dhparam.pem; |
See SSL […]
editor
Online Code Editor […]
Online Code Editor
Eclipse Che Eclipse Che is an Open Source Online Code editor. https://github.com/eclipse/che/ It support several programming language. Based on Visual Code Studio. RedHat.com supports this open source project and provide Free hosting for the Eclipse Che ommunity with the hope that it will result in ever-increasing community involvement and contributions. https://che.openshift.io […]
CWP not working after hostname SSL install
On a CentOS Web Panel (CWP) server, control panel stopped working after installing SSL certficate for hostname. When starting cwpsrv service, i get following error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@nvme ~]# systemctl start cwpsrv Job for cwpsrv.service failed because the control process exited with error code. See "systemctl status cwpsrv.service" and "journalctl -xe" for details. [root@nvme ~]# systemctl status cwpsrv.service ● cwpsrv.service - CentOS Web Panel service (daemon) Loaded: loaded (/usr/lib/systemd/system/cwpsrv.service; enabled; vendor preset: disabled) Active: activating (auto-restart) (Result: exit-code) since Wed 2021-02-10 04:51:53 CET; 1s ago Process: 3779 ExecStartPre=/usr/local/cwpsrv/bin/cwpsrv -t (code=exited, status=1/FAILURE) Feb 10 04:51:53 nvme.ssdnodo.com systemd[1]: Failed to start CentOS Web Panel service (daemon). Feb 10 04:51:53 nvme.ssdnodo.com systemd[1]: Unit cwpsrv.service entered failed state. Feb 10 04:51:53 nvme.ssdnodo.com systemd[1]: cwpsrv.service failed. [root@nvme ~]# /usr/local/cwpsrv/bin/cwpsrv -t cwpsrv: [emerg] annot load certificate key "/etc/pki/tls/private/hostname.key": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/pki/tls/private/hostname.key','r') error:2006D080:BIO routines:BIO_new_file:no such file) cwpsrv:configuration file /usr/local/cwpsrv/conf/cwpsrv.conf test failed [root@nvme ~]# |
To fix this, i run
1 |
/usr/local/cwpsrv/htdocs/resources/scripts/generate_hostname_ssl |
This generated the self signed SSL for hostname. After this CWP control panel started working. Apache still was down, fixed it by removing […]