Thứ Bảy, 31 tháng 1, 2015

Disable The Mail Alert By Crontab Command

ow do I to disable the mail alert send by crontab? When my job is executed and the jobs cannot run normally it will sent an email to root. Why do I receive e-mails to my root account from cron? How can I prevent this?

By default the output of a command or a script (if any produced), will be email to your local email account. To stop receiving email output from crontab you need to append following string:

Cron Job Prevent the sending of errors and output To prevent the sending of errors and output, add any one of the following at the end of the line for each cron job to redirect output to /dev/null.
>/dev/null 2>&1.
OR
&> /dev/null
Cron Job Example
Edit/Open your cron jobs, enter:
$ crontab -e
Append string >/dev/null 2>&1 to stop mail alert:
0 1 5 10 * /path/to/script.sh >/dev/null 2>&1
OR
0 1 5 10 * /path/to/script.sh &> /dev/null
Save and close the file. Restart the crond:
# /etc/init.d/crond restart
MAILTO variable
you can set MAILTO="" variable at the start of your crontab file. This will also disable email. Edit/Open your cron jobs
$ crontab -e
At the top of the file, enter:
MAILTO=""
Save and close the file.
Read More

Delete all root mail / inbox from a shell prompt

The easilst way is to empty root / users email message file i.e. /var/spool/mail/root or /var/spool/mail/username. Simply type the following command at shell:
> /var/spool/mail/root 
OR
cat /dev/null > /var/spool/mail/root 
OR
echo "" > /var/spool/mail/root
Read More

Thứ Tư, 28 tháng 1, 2015

How to fix Kali Linux apt-get slow update?

This is a small guide on How to fix Kali Linux apt-get slow update.

Kali is relatively new and got fewer Mirrors than some other distro’s. That means less servers to download from and less servers means more people trying to download from them and using all bandwidth. So when you type in apt-get update, you see a slow download speed for packages. This just means you’re connected to a server that’s really busy. Some users complains that nothing happens or they are not getting any updates at all. Some got different issues like update stuck is header and doesn’t move any further.

To fix this, you need to check a few things:

  •     Check if you have the right repositories is your /etc/apt/sources.list
  •     Remove unwanted or unsupported repositories.
  •     Clean apt-get cache.
  •     Choose a fast DNS server.

Clean apt-get cache:

apt-get clean

Choose a proper DNS server:

Edit resolv.conf file:

leafpad /etc/resolv.conf

Enter Google DNS nameservers

Following two are Google DNS, let’s face it, if Google is broken, we all think Internet is broken. Hence the reason of using Google DNS. You can choose other DNS Server if you want that are fast and reliable.

nameserver 8.8.8.8
nameserver 8.8.4.4

Now save and close the file.
Test your changes

Let put our changes to the test..
Do an apt-get update

 apt-get update

Do and upgrade

 apt-get upgrade

Finally do a distribution upgrade

 apt-get dist-upgrade

Your download speed should be a lot better than you were getting previously.
Another solution, changing from HTTP to REPO in sources.list file (14/02/2014)

One of the readers advised that by changing the repositories from HTTP to REPO, he gained significant speed up. See Sameer Barha’s comment below.

Use the following repositories (update your sources.list file)

## Kali Regular repositories
deb http://repo.kali.org/kali kali main non-free contrib
deb http://security.kali.org/kali-security kali/updates main contrib non-free
## Kali Source repositories
deb-src http://repo.kali.org/kali kali main non-free contrib
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free

Instead of

## Kali Regular repositories
deb http://http.kali.org/kali kali main non-free contrib
deb http://security.kali.org/kali-security kali/updates main contrib non-free
## Kali Source repositories
deb-src http://http.kali.org/kali kali main non-free contrib
deb-src http://security.kali.org/kali-security kali/updates main contrib non-free

This change seems to boost speed as it uses slightly different repo than the usual HTTP servers which are overloaded. Let us know how this worked for you.

Read More

Thứ Ba, 27 tháng 1, 2015

Ubuntu: How to run scripts on start up?

1>

One approach is to add an @reboot cron task:

    Running crontab -e will allow you to edit your cron.

    Adding a line like this to it:

    @reboot /path/to/script

    will execute that script once your computer boots up.


2>

How about adding the command to /etc/rc.local? you'll have to use sudo access though to edit this file.

sudo nano /etc/rc.local

Read More

CloudLinux LVE Custom PHP.ini options

PHP Selector allows customer to edit php.ini settings. Admin has a full control over which settings can be modified.

To allow settings to be modifiable, it has to be whitelisted in:

/etc/cl.selector/php.conf

Here are some of the examples of allowed directives:
Directive = safe_mode
Default   = Off
Type      = bool
Remark    = <5.4.0
Comment   = Enables PHP safe mode. This mode puts a number of restrictions on scripts (say, access to file system) mainly for security reasons.
Users can use web interface to modify php.ini settings

Read More

Thứ Hai, 19 tháng 1, 2015

How To Fix error HRESULT 0xc8000222 In Net Framework Installation

Some applications require the latest version of net framework pre-installed before you can run them. If you don't have the latest version pre-installed, You need to install it separately to replace the outdated one in your machine (Link for the latest net framework download : http://www.microsoft.com/net/download).

The problem we often have here is the error msg like HRESULT 0xc8000222 when we are about to finish the Net Framework installation.


Please follow the below steps to complete the framework installation without error :

  •     Click START > ALL PROGRAMS > ACCESSORIES > right click COMMAND PROMPT and choose run as administrator (A command prompt window will open).



  •     Type : net stop WuAuServ in the command prompt and leave it that way for a second.

  •     Now click Windows > R > and type %windir%
 

  •     Find a folder named SoftwareDistribution. Rename it with any name (we don't use this folder anymore, Renaming it is only for back up purpose).

  •   Back to command prompt again and type net start WuAuServ.

   Finish your net framework installation.
Read More

Cannot upgrade WordPress or a WordPress Plugin: Could not open handle for fopen() to /tmp/

Should you receive an error message about not being able to write or open a file in "/tmp" when upgrading WordPress or a WordPress plugin, please add this line to the bottom of your "wp-config.php" file:

define('WP_TEMP_DIR',ABSPATH.'wp-content/uploads/'); 

This line will result in WordPress using your "/wp-content/uploads" folder to store temporary files required during the upgrade process instead of the system-wide /tmp folder. We have only seen this issue reported for the "Jetpack" plugin, however, this issue may affect other plugins. An example error message that this line will resolve:
========
Installing Plugin: Jetpack by WordPress.com 2.3.1
Downloading install package from http://downloads.wordpress.org/plugin/jetpack.2.3.1.zip… Download failed. Could not open handle for fopen() to /tmp/jetpack.tmp
 ========
Read More

Chủ Nhật, 18 tháng 1, 2015

How to export PUTTY Sessions List

How to export PUTTY Sessions List 

You can export it simply by:

regedit /e "%userprofile%\desktop\putty-sessions.reg" HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions
 
Or:
regedit /e "%userprofile%\desktop\putty.reg" HKEY_CURRENT_USER\Software\SimonTatham
Read More

Thứ Sáu, 16 tháng 1, 2015

How To Downgrade WordPress Version 4.0.1 to 3.9.2

How To Downgrade WordPress Video Tutorial

The following video will show you exactly how I downgrade to a previous version of wordpress. In the video I downgrade from wordpress version 4.0.1 to version 3.9.2, but it doesn’t matter what version you’re currently using or want to restore as it’s the same process. I’m also going to cover how to turn off automatic wordpress updates.

Step By Step Instructions For Downgrading

I understand not everyone wants to watch a video tutorial, so I’ve added some brief step by step instructions below on how to downgrade. If something isn’t clear and you need help, feel free to post a comment and I’ll respond ASAP or refer to the video above for more details.

Step 1: Deleting WordPress Files & Folders

You need to connect to your hosting either via FTP or File Manager. Locate the root directory or your wordpress installation. For most of you, this is going to be the root directory of the domain.

Select and delete the following two folders.  wp-admin and wp-includes


Step 2: Download A Previous Version Of WordPress

Head over to wordpress.org and locate the version of wordpress you’d like to downgrade to, this link should take you directly to the download archives https://wordpress.org/download/release-archive/ Locate and download the version of wordpress you wish to restore.

Locate the downloaded .zip file on your computer and then unzip/extract the file. (if you right click the .zip file, you want to look for the “Extract Here” option.)

Step 3: Uploading Files & Folders

Either via FTP or Filemanager you need to first upload the following two folder that have just been unzipped: wp-admin and wp-includes. Make sure you upload them in the correct location, this would be the root directory of your wordpress installation. Next you need to upload

Next you need to upload the 14 PHP files located directly inside the wordpress folder on your computer. If for any reason you see a file called wp-config.php PLEASE DO NOT upload this file. The file wp-config.php that resides on your hosting contains your database details and shouldn’t be overwritten.

These 14 PHP will be overwriting the current files, so you’ll need to click ok when asked if you’d like to overwrite or not.


Step 4: Updating The WordPress Database

Once all the files and folder have been uploaded, you can visit the login page to your site /wp-login.php . It should load a different page asking you to update your wordpress database. This is perfectly normal, just click update and then you’ll be able to login.


How To Stop WordPress From Updating Automatically

It’s possible that the theme you’re using isn’t compatible with the latest versions of wordpress, so until the author of the theme comes out with a fix, you may want to disable automatic wordpress updates. Same may apply if you have a few plugins that aren’t compatible, disabling auto updates could be a temporary fix.

Please note that I do NOT recommend running old version of wordpress and would suggest looking into resolving the problem ASAP. WordPress releases new version for two main reasons, add new features and improvements, and then to fix security holes and vulnerability.

Either way, disabling auto updates with wordpress is very easy. Via FTP or File manager, you need to locate and edit the file called wp-config.php. Once opened in notepad or another editor (I use notepad++) you need to add one additional line/command.

Here is the line of code to add:

define( 'WP_AUTO_UPDATE_CORE', false );

Here is a screenshot of the location I would insert this line of code, after it been inserted, save the file and re-upload/overwrite, this will stop wordpress from completing any auto updates.





Read More