Linux replace command all files with sed shell command

Scripts, SSH, www

Replace word in all files with sed via linux shell command

To replace string design/nashik to designing/india on the same file textNashik.html
Use the following linux command with the syntax.
sed -i s:design/nashik:designing/india:g textNashik.html

Another Example:
sed -i s:twitter.com/webservices:twitter.com/dnswspl:g home/*.html

Replacing phrase in all files including directories and subdirectories using sed and find

find . -type f -exec sed -i ‘s:ecommerce.html:ecommerce-shopping-cart.html:g’ *.html {} \;

NOTE: ‘:’ used as a substitue for ‘/’ as / is used in search and replace.

Related: Linux Command, Shell Command, Sed Command, Replace Text, Linux Replace

Execute PHP script from cron or command-line

cPanel, PHP, Scripts, SSH, Web-Hosting

Execute PHP script from cron or command-line

One of the method for running PHP scripts from a cron job is run the script using php from the crontab. You will need to call the php script from your crontab as given below.
To execute somescript.php every 1 hour you will need to edit and add below given line in your crontab file:
00 * * * * /usr/local/bin/php /home/someuser/somescript.php

If you are looking for command-line interpreter, then it can be done with the following command. It shows how to run a script using the PHP command-line interpreter:

/usr/local/bin/php -q /home/someuser/public_html/somescript.php
The -q option is for quiet mode, to prevent headers being displayed.

Make a note of code in your PHP script, it may only run correctly if called from a mentioned path. For example, if the script uses relative paths to include files, it will only run if it is called from the specified directory. The following command shows how to run a PHP script from a specific path:

cd /home/username/public_html/; /usr/local/bin/php -q script.php

Related: Dedicated Server, Virtual Server, Web Server Hosting

syslogd klogd warning in firewall

CSF, Dedicated Server, Firewall, Security, SSH, VPS Hosting, Web-Hosting

If you are getting this WARNING message, what you need to do?

Syslogd appears to be running, but not klogd which logs kernel firewall messages to syslog. You should ensure that klogd is running.

How do you enable klogd?

Fire a command:
#whereis klogd
Then simply run klogd with full path:
klogd

Related: Dedicated Servers, VPS Hosting

Find files greater than MB GB size in linux ssh

Dedicated Server, SSH, Virtual Private Server, Web-Hosting

Find files greater than MB GB size in linux ssh. ( Such a helpful ssh command to find big, larger or largest file on server)

The following ssh command will list all the files in the system greater than 200MB.
# find / -type f -size +200M

The following ssh command will list all the files greater than 2GB.
# find / -type f -size +2G

The following ssh command will list all the files greater than 10MB from home folder only.
# find /home -type f -size +10M

Related: Linux SSH, Virtual Server

Reboot Server from SSH

Dedicated Server, Security, SSH, Virtual Private Server

Reboot Server from SSH

How to reboot Linux server from ssh? Is it same for local and remote Linux system?

Linux has various ways to reboot a system. It is also known as halt, poweroff, shutdown, init etc.

Coming to the point, rebooting your Linux server from ssh console: The most important thing, you should be logged in as root to reboot the system. Once you are in as root, type any of the following command as per your requirement.

INSTANT REBOOT LINUX SERVER:

# reboot
OR
# /sbin/reboot
OR
# shutdown -r now
OR
# /sbin/shutdown -r now

Want to send a notification to logged in users about this reboot? Then type the following command:
# shutdown -r +2 (This will send the message to all the users that the system is going to reboot in next 2 minutes.)

Related: Linux Server, Linux VPS, Dedicated Server, Private Server

 
©2018, All Rights Reserved. Managed-Servers by UnicHost Web Solutions. Powered by UnicHost.
Log in