Archive for March, 2009

Mac OSX user lost desktop permissions

March 23rd, 2009 | No Comments »
Posted by Aaron Reimann under Mac OSX, Operating Systems

What do you do when all of your icons no longer appear on your desktop?  Chances are, you have lost all permissions to view (read) and edit (write) them.  This happened to one of my friends, he of course was a little confused.  We had no idea why it happened, but it did.  Let’s call this Joe Bob His Mac username is “Joe Bob” and the real user name (Unix name) is “joebob.”

The user, joebob, could access Application, his music (/Users/joebob/Music), his documents (/Users/joebob/Documents), etc. But was unable to access /Users/joebob/Desktop. He got a permission denied thing. I find that somewhat funny because there wasn’t any other user on the computer (well, besides, root, apacheh, mysql, etc). So, what was the fix?

Go to terminal (use Spotlight to find it if you want) and type in: sudo passwd

Typing that in “activates” the root account.  Make sure you remember the root password, you will not be happy if you forget it.

How do get your “short name”, type in:

cd /Users

ls

What are short names?  Even though when I login to my Mac my user name “Aaron Reimann” is displayed, I can still login as “aaronr”.  OSX (and a lot, maybe all Unix-like OS’s) creates a short name for every user that it creates.  It makes more sense that your user directory is “/home/aaronr”, not “/home/Aaron Reimann”.  I don’t know if it is a POSIX thing or not, it is a fact though.

now type in: sudo chown -R joebob:joebob /Users/joebob/Desktop

That will make sure that joebob owns the Desktop directory

type in: sudo chmod -R 744 /Users/joebob/Desktop

That will make the files on the desktop read and writable

Log off, log back in, and you will see your icons/files.

With all that said, you probably could go into Disk Utilities and do it the “easy” (really the time consuming and GUI way), but this is quick.

 

Migrating a users and files to a new Linux Box

March 17th, 2009 | No Comments »
Posted by Aaron Reimann under Linux/Unix, Operating Systems

The purpose of this article is to show you how simple it is to migrate your system to a new server in case you have a need to upgrade. This is not for the people that are not familiar with Linux. You need to know, for example, that if it is a web server, make sure you get the Apache configs. I wanted to move users, passwords, samba users, samba passwords and home directories to the new box. Here is what I did.

This tutorial should work for any version of Fedora, and really, should work for Linux boxes in general. This should teach you the concept more than anything.

Box 1: This is the original box that I setup a long time ago. It is running Fedora Core 6, with the latest updates. The IP of the box is 192.168.0.11. I transferred users, passwords, groups, Samba configs and users’ home directories from this box

Box 2: Fresh (very simple) installation of Fedora Core 6 with the latest updates. I installed Samba, if you need Apache, go ahead and install that on the new box. Make sure you have the latest updates on both! Give it whatever IP address, I used DHCP and it got 192.168.0.115.

DO NOT CREATE A USER (besides root) ON THE NEW BOX and once your new box has installed Fedora, do not login (might be overkill, but I would take the chance.

Let’s start:

Move users/passwords/groups/shadow/Samba configs to the new box:

tar -cf – /etc/passwd | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/passwd- | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/shadow | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/shadow- | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/group | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/group- | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/sudoers | ssh 192.168.0.115 tar -xf – -C /

tar -cf – /etc/samba | ssh 192.168.0.115 tar -xf – -C /

Now copy over users home dirs (It can take hours depending on amount of data):
tar -cf – /home | ssh 192.168.0.115 tar -xf – -C /

Now copy over root’s home dir if you want:
tar -cf – /root | ssh 192.168.0.115 tar -xf – -C /

That’s it. You don’t even need to reboot.

Now grab whatever configs you think you will need. Do not toss that old box….keep it around for a while. You want to make sure that you have all of the files off that you need. You might need your Apache configs, php.ini, and /etc/hosts.

Now change your IP address of your new box to what your old box was. In *theory* no one will tell the difference, except file transfers will be faster.

Feel free to contact me if you want

 

PHP snippet for WordPress

March 13th, 2009 | No Comments »
Posted by Aaron Reimann under Uncategorized

So I decided to build my own WordPress theme from scratch.  I know, it seems like that is all I’m posting about, but that is what I am wanting to learn right now…and I try to post what I am learning.  Here is one of the most recent things I have done.

Most WordPress sites out there have 10 posts on the home page, and it is the whole post.  It can make for a very long page.  I prefer to have a lot of the most recent page on the home page, and then excerpts of the other recent ones.  The function “the_excerpt()” does not let you specify the amount of characters, so I either had the whole post, or just a little.

On this site I limit the amount of characters to 6,000 by using a function (not in WP by default, if you need it, let me know via email) called “the_content_limit()”.  I thought that was a great thing, but it stripped all of the html.  I wanted to keep my breaks, so I wrote this:

	$content = strip_tags($content, '<p><br><br />');
	$content6 = substr($content, -6); // grab last 6 chars
	$last6array = str_split($content6); // split the 6 in an array
	if (in_array("<", $last6array)) {
		$content = substr($content, 0, -6);
	}

The code just checks to see if the last 6 characters have a < and if so, strip it.  We want to make sure that all tags are closed.

 
 
Theme by A. Reimann