WordPress – How to Fix File and Folder Permissions – reset_wp_perm.sh

#!/bin/bash
#RyS20140530
echo "v1.1, 2014120301"
echo ""
echo "Current directory is:"
pwd
read -p "Make sure you are in your WordPress directory, are you ? (y/n) " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo ""
echo "... Setting chmod 775 for all directories"
find ./ -type d -exec chmod 775 {} \;
echo "... Setting chmod 664 for all files"
find ./ -type f -exec chmod 664 {} \;
echo "... But setting chmod 664 for wp-config.php, though, assuming chown is set to ft
p user"
chmod 664 wp-config.php
echo "Type username"
read user
echo "... Setting chown $user:www-data for *"
chown -R $user:www-data *
#echo "... Setting chown to :www-data for wp-content/uploads"
#chown -R :www-data wp-content/uploads
echo "... Setting chown :www-data for .htaccess"
chown :www-data .htaccess
echo "... Setting chmod 644 for .htaccess"
chmod 644 .htaccess
echo ""
echo "Done"
echo ""
read -p "Also run fix for WordPress upgrade and file permissions issue ? (y/n) " -n 1
-r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo ""
echo "... Changing wp-content group ownership to www-data"
chgrp -R www-data wp-content
echo "... Making wp-content and all of its sub-directories group-writable"
chmod -R g+w wp-content
echo "... Newly-created files to be group-owned"
chmod g+s wp-content
echo "If necessary, add the following to the bottom of wp-config.php"
##/* Force direct file updating
##- taken from http://www.charleshooper.net/blog/wordpress-auto-upgrade-and-dumb-permi
ssions/
##For more information, take a look at wp-admin/includes/file.php’s function get_files
ystem_method
##*/
echo "define('FS_METHOD', 'direct');"
fi
fi

Sources:
https://codex.wordpress.org/Changing_File_Permissions
http://www.charleshooper.net/blog/wordpress-auto-upgrade-and-dumb-permissions/

Backup recovery area (FRA) without a tape device

Backup to disk

RMAN> run {
allocate channel d1 type disk format='/tmp/%U';
backup tablespace sysaux;
}

Backup to a fake tape

The fake tape library will call the MML APIs, essentially similar to an MML backup, but will place the file on disk (RMAN disksbt library emulates a SBT library). It cannot be used for production backups but can be used for verification purposes such as these:

RMAN> run {
allocate channel t1 type 'SBT' PARMS 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/tmp)';
backup tablespace sysaux;
}

The fake tape backup comes in handy when one wants to backup the recovery area; the ‘backup recovery area’ command only works with SBT channels. FRA backup to disk does not work.

EM agent; ERROR-400 Data will be rejected for upload, bla bla

Darn, I had it also, the agent in GRID control in not uploading to the OMS and there is just too much to upload. One can change em.loader.maxDirectLoadFileSz but the following can be done to (you will lose some info but hey..)

Now fix it:

cd $AGENT_HOME/sysman/emd
rm lastupld.xml agntstmp.txt
cd $AGENT_HOME/sysman/emd/upload
rm *.*
cd $AGENT_HOME/sysman/emd/state
rm *.*

No need to remove storage directory under $AGENT_HOME/sysman/emd/state

cd $AGENT_HOME/bin
./emctl start agent
./emctl status agent

(source: http://gavinsoorma.wordpress.com/2009/12/03/how-to-manually-clear-em-grid-control-alerts/)

RMAN / archive backup without catalog database…

… can cause a nasty ORA-19571. Reason? You are using a control file as RMAN catalog and obviously more space is needed than available..
Try:

sql> alter system set control_file_record_keep_time=14 scope=both;

More info: Oracle’s Metalink Doc ID: 563219.1
and
http://download.oracle.com/docs/cd/B12037_01/server.101/b10755/initparams027.htm

What’s in security – October 2009

Last Thursday I read that Oracle postpones the upcoming CPU patches. They state:

There is a change in the previously announced release date of the October 2009 Critical Patch Update.

Since many Oracle customers with responsibility for deploying the Critical Patch Update within their respective organizations will be attending Oracle OpenWorld October 11-15, 2009, the October 2009 Critical Patch Update originally scheduled to be published on Tuesday, October 13th 2009, will be released on October 20th 2009.

Please note: this date change only impacts the October 2009 Critical Patch Update. As usual, Oracle will issue a pre-release announcement on the Thursday before the publication of the Critical Patch Update (Thursday, October 15th). All other aspects of the Critical Patch Update (where to find the documentation, how to download the patches, etc.) remain the same.

(More info: see Metalink

A good reason would be that there are no important patches.. aren’t there..?

Using the network.. with a local instance

So I wanted to have a local database on my Windows XP machine. To make the installation as much as possible server alike, I created the MS loopback adapter to be sure of a certain IP address:

Ethernet adapter loopback (oracle):

Connection-specific DNS Suffix  . :
Description . . . . . . . . . . . : Microsoft Loopback Adapter
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 10.1.2.3
Subnet Mask . . . . . . . . . . . : 255.0.0.0

Well, it seems that the listener daemon binds to the most recent IP address. Typical Windows behaviour, as it seems.  In order to be sure I have the correct IP address I start my listener and instance after I established my last connection (e.g. Dial up networking to a 3G network Ethernet).

One is able to change the binding order when, for example, you do create another new network connection;

Start –> Run –> ncpa.cpl

Choose Advanced, Advanced Settings and choose under Connections your desired order.

Instead of some ugly ISP given network which will make your listener connections ugly:

* (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))(SERVICE_NAME=orcl)) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.4.5.6)(PORT=2019)) * establish * orcl * 0
* service_update * orcl * 0

You get your clean (loopback adapter):

* (CONNECT_DATA=(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))(SERVICE_NAME=orcl)) * (ADDRESS=(PROTOCOL=tcp)(HOST=10.1.2.3)(PORT=2019)) * establish * orcl * 0
* service_update * orcl * 0

NOTE!

To prevent from any (local) connection errors, please be aware that the %SystemRoot%\System32\drivers\etc\hosts file should be something like this:

127.0.0.1 localhost
10.1.2.3 your_host_name

Similar, on RAC environments, when you enter your hostname after the local loopback address, you might get one of the following errors:

ORA-00603: ORACLE server session terminated by fatal error
or
ORA-29702: error occurred in Cluster Group Service operation

(RAC info from http://www.puschitz.com/InstallingOracle10gRAC.shtml)

SQLNET.AUTHENTICATION_SERVICES vs. connection time outs

One could have an Oracle installation (10g, in my case) on a Windows XP machine). To bypass the problem of connection loss you could set SQLNET.AUTHENTICATION_SERVICES to none but then sqlplus / as sysdba won’t work anymore (obviously).

So I set my SQLNET.AUTHENTICATION_SERVICES back to NTS (using TNSNAMES)

The problem of connection loss doesn’t seem to appear anymore, maybe it’s because of a correct network binding (listener)?

C:\oracle\product\10.2.0\db_1\NETWORK\ADMIN>type sqlnet.ora

SQLNET.AUTHENTICATION_SERVICES= (NTS)

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)