Determining what versions of WordPress you are hosting
August 10, 2010
If you host lots of different sites for people, one of the things you might want to know is what versions of WordPress each site is running.
WordPress stores the version number in a variable named $wp_version which is set in the file version.php.
With that information in hand, you can write a bash command that you run from your /home directory to display all of the WordPress versions you have on your server:
find . -name version.php -type f|xargs grep ^\$wp_version
This is one of the aliases I have in my .bashrc file.
Three helpful additions to your .bashrc
June 21, 2010
I just made a change to my .bashrc file and I thought I would share the tip. All of this is pretty basic stuff, but if you don’t customize your linux logins, this would be a good place to start.
For Microsoft people who don’t know, .bashrc is in some ways like a combined config.sys and autoexec.bat file. If you don’t know what an autoexec.bat file is, you totally missed the 80s dudes…
In a *nix environment, the rc at the end of a file name typically means that it is a “run control” file. Run Control files execute when a program starts. In this case, the program is bash – the command line interpreter/shell. Other programs look for rc files too. Because of this, you could have bunches of them in your home directory. The . at the front of the file name indicates that they are hidden from a normal directory listing. This way they don’t clutter up your home.
I have lots of neat things in my .bashrc file that add functionality to my default CLI. I’ll be sharing just three of those with you now.
The first is an alias: ebrc. When I type ebrc and press enter, I’m taken immediately into an editor with my .bashrc file open. You can think of an alias as a single line shortcut. It looks like this:
alias ebrc='vi ~/.bashrc'
As you can see, it just says “when I type ‘ebrc’, treat it like I really typed ‘vi ~/.bashrc’”.
The second thing I used tonight was the alias brc:
alias brc='. ~/.bashrc'
That executes the .bashrc file again, so that all of the changes I’d just made are loaded.
You might ask “Can’t you just type all that out? You’re not saving much time.” Go ahead.. ask. I’ll wait…
OK. The answer is Yes. So, it is important that you don’t go overboard on this stuff. If you use aliases too much, you’ll lose your familiarity with *nix and the skills to do your work on any other server. So proceed with caution. This stuff can be addictive and detrimental to your guru health.
Now with those two helper aliases in hand, I added the function I really wanted to include: ‘upskel’. It takes a task I might otherwise put off and allows it to be completed in 7 keypresses. This is the perfect use case for a .bashrc function.
‘upskel’ takes the latest version of WordPress and places it into the cpanel skeleton directory that is used as the base for every new account created on my hosting service eHermits, Inc.. So, every time an update comes out for WordPress, I can spend 5 seconds to grab the latest and all new accounts I create will be safe and updated.
Unlike an alias, this is done through a function call. Functions allow the use of multiple lines and variables. Here is the call I just added:
function upskel() { cd /root/cpanel3-skel rm -R public_html rm latest.zip* wget http://wordpress.org/latest.zip unzip latest.zip mv wordpress public_html }
Technically I probably could have done that as an alias but a function is much easier to read with multiple lines involved.
As a bonus, here is a function that takes a variable:
function ewpc() { cd /home/$1*/ pwd sudo vi ./public_html/wp-config.php }
Can you tell me what it does?
Using find to copy specific files on linux
June 2, 2010
I was faced with a weird copy command I wanted to do today; so I thought I would share.
How do you copy files in a directory tree to another directory?
I wanted to copy all of the mp3 files in a directory tree over to one specific target directory.
Initially I thought the command
cp -r *.mp3 /target/directory/
would work, but even though it specifies the –recursive option, it does not iterate the subdirectory looking for the mp3 files.
So I resorted to my every faithful companion: find -exec. It seems like this is one of the most useful tools in linux. In this case, here is the command line I used:
find . -type f -name ‘*.mp3′ -exec cp {} /targetdirectory/ \;
How to: Find files edited in the last day
February 15, 2010
The process is straight forwarded. There are several methods:
find . -mtime -1 \! -type d -exec ls -l {} \;
Or more simply
find . -type f -mtime -1
In my case, I wanted to do more. First since I was searching an SVN repository, I wasted to exclude all of the extra files that are touched by SVN. Additionally, the goal was to show which files contained a print_r function.
Here’s what I came up with:
find . -path '*/.svn/*' -prune -o -type f -mtime -1 \
-exec echo '{}' \; -exec grep print_r {} \;
Hope that helps!
Getting the error ‘cannot move – to a subdirectory of itself’?
August 19, 2009
This error message always bothered me because it makes no sense when I get it.
Here’s my scenario… I have a directory that is used as the base for all new accounts I sell on my servers. The path is; /root/cpanel3-skel. I always put WordPress in that directory and I want to keep the latest version of WP in that directory
[root@wiredtree ~]# rm -r wordpress latest.*
rm: cannot remove `wordpress’: No such file or directory
rm: cannot remove `latest.*’: No such file or directory
[root@wiredtree ~]# wget -q http://wordpress.org/latest.zip
[root@wiredtree ~]# unzip -q latest.zip
[root@wiredtree ~]# mv -f wordpress/* /root/cpanel3-skel/public_html/
mv: cannot move `wordpress/wp-admin’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-admin’
mv: cannot move `wordpress/wp-content’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-content’
mv: cannot move `wordpress/wp-includes’ to a subdirectory of itself, `/root/cpanel3-skel/public_html/wp-includes’
WHAAAAT? Obviously it is not a subdirectory of itself…
Something strange is going on… We get a little more information if we try to do a move from one device to another. Take a look at this error message:
[root@wiredtree tmp]# mv -f wordpress/* /root/cpanel3-skel/public_html/
mv: inter-device move failed: `wordpress/wp-admin’ to `/root/cpanel3-skel/public_html/wp-admin’; unable to remove target: Is a directory
mv: inter-device move failed: `wordpress/wp-content’ to `/root/cpanel3-skel/public_html/wp-content’; unable to remove target: Is a directory
mv: inter-device move failed: `wordpress/wp-includes’ to `/root/cpanel3-skel/public_html/wp-includes’; unable to remove target: Is a directory
This reveals the true source of the error message. In “mv –help”, the explanation of “-f” is too simplified and says only:
-f, –force do not prompt before overwriting
In “cp –h” we closer,but not exact, explanation of the real process, and one that better matches the inter-device error message:
-f, –force if an existing destination file cannot be opened, remove it and try again
The final bit of information is in an Ubunto bug 71174 “Misleading error message with mv and existing directories” where they change the error message to be “mv: cannot move `a’ to `b/a’: Directory not empty”.
So there you have it. You get that error message because the -f command tries first to remove the directory and can’t because it contains one or more files. You don’t get this message if the subdirectories are empty. The remove works fine on an empty directory but fails if there are files. The Linux core can’t correctly handle this exception and throws up what is probably the last error message in a switch/case statement “cannot move – to a subdirectory of itself”.
So what do you do about it? Well you can either empty the destination directory first, or you can copy the files and then delete the source directory. I chose the latter option and run this from the root folder:
rm -r wordpress latest.*
wget -q http://wordpress.org/latest.zip
unzip -q latest.zip
cp -rf wordpress/* cpanel3-skel/public_html/
rm -r wordpress latest.*
Cool? Hope that helps someone…
Microsoft: I just stepped into what?
July 6, 2007
Microsoft scrambles quickly backwards away from a GPLv3 and checks its loafers to see exactly what it just put its $500 loafers into… Â Still “As always, Microsoft remains committed to working with the open source software community”.
Microsoft Statement About GPLv3
A Microsoft statement about GPLv3.
Published: July 5, 2007
Microsoft is not a party to the GPLv3 license and none of its actions are to be misinterpreted as accepting status as a contracting party of GPLv3 or assuming any legal obligations under such license.
While there have been some claims that Microsoft’s distribution of certificates for Novell support services, under our interoperability collaboration with Novell, constitutes acceptance of the GPLv3 license, we do not believe that such claims have a valid legal basis under contract, intellectual property, or any other law. In fact, we do not believe that Microsoft needs a license under GPL to carry out any aspect of its collaboration with Novell, including its distribution of support certificates, even if Novell chooses to distribute GPLv3 code in the future. Furthermore, Microsoft does not grant any implied or express patent rights under or as a result of GPLv3, and GPLv3 licensors have no authority to represent or bind Microsoft in any way.
At this point in time, in order to avoid any doubt or legal debate on this issue, Microsoft has decided that the Novell support certificates that we distribute to customers will not entitle the recipient to receive from Novell, or any other party, any subscription for support and updates relating to any code licensed under GPLv3. We will closely study the situation and decide whether to expand the scope of the certificates in the future.
As always, Microsoft remains committed to working with the open source software community to help improve interoperability for customers working in mixed source environments and deliver IP assurance. Our partnerships with Novell and other Linux platform and desktop providers remain strong and the IP bridge we built with them, embodied in our collaboration agreements, remains intact. In particular, our technical and business collaboration with Novell continues to move full steam ahead, including our joint development work on virtualization, standards-based systems management, identity interoperability and document format translators. In addition, the patent covenants offered by Microsoft and Novell to each other’s customers are unchanged, and will continue to apply in the same way they did previously.
Notes on Microsoft/Novell Anouncement: SUSE Linux/Windows Interoperablity
November 2, 2006
(Article Draft – Corrections will be made to spelling and grammar – These views are mine coming as fast as I can type with the live announcement. I apologies for any typos/misquotes/misinterpretations.)
Microsoft and Novell made an abrupt disclosure via their web cast site that there would be a VERY IMPORTANT announcement. That announcement occurred at 2:19pm PST/5:19pmEST. This announcement is important to large scale Enterprise and Server/datacenter operators as well as the developer community. It offers more choices, opportunties and technologies to IT operators around the world.
You may view the WebCast session in its entirety using any with these links:
Please, as you listen to the session, if I can enhance or correct any of my notes, please let me know in a comment on this post.
Read more
BIG LIVE Microsoft/Novell/Linux? announcement RIGHT NOW
November 2, 2006
Bridging the devide between Closed/OpenSource and Linux/Windows
It will last till 2:49pm GO THERE NOW!!!!!!
It started 2:19pm EST
Steve Ballmer to Deliver Industry Announcement
November 2, 2006
Microsoft Corp. CEO Steve Ballmer will deliver an announcement during a press conference today, Thurs., Nov. 2, in San Francisco beginning at 2 p.m. Pacific time / 5 p.m. Eastern time. Details of the announcement will be provided during the press conference.