Creating a bash profile

May 17th, 2009

If you want to extend your bash profile or your “bashrc” (for example extend your PATH variable) in Mac OS X Terminal you usualy search for a “.bashrc” file that allows you to enter commands that will be executed every time you log in into a shell.

In serveral Linux distributions it is usual that you find a .bashrc file in your home folder (~/.bashrc). That file doesn’t exist in Mac OS X. If you want a bash profile, you just have to create it with the name “.bash_profile” and everything will turn fine.

Create the .bash_profile
touch ~/.bash_profile
And open it with the Mac OS X default text editor
open ~/.bash_profile

Just enter your needs into the bash profile. By default it will be executed every time you open the Terminal application or create a new tab within it.

Author: Muty Categories: Apple Tags:

Sharing iTunes, iPhoto or other stuff

April 26th, 2009

Sharing your iTunes library, iPhoto library or other files on your Mac with other (local) users isn’t that easy as it could be. There are several problems with the file permissions on Mac OS default file system HFS+.

Like ext3 or other UNIX file systems HFS+ has UNIX file permissions that can be separated to permissions for the file owner, for a group and for all others. If you have an iTunes library and you want it to share with your girl friend, who has a account on your Mac, the most convenient thing you would do is moving your iTunes library to the shared folder (/Users/Shared/).

But there is a problem with this folder: it won’t change the file permissions of your library and your music files correctly, so everybody on your mac can read and change the files (which is needed for your iTunes library file). A possible solution would be to correct the file permissions with the information dialog (Cmd + i) or via terminal access. Also here there is a problem: the file permissions would be only applied to the files that already exists. In consequence you would have to adjust the file permissions every time when some one edits a file or adds new songs to your library. This is not user friendly.

But for those problems there is a solution and it is built-in to Mac OS X, but it is not activated by default: Access Control Lists (ACLs). With Access Control Lists you can add permissions for users or groups to a folder that will be applied to every file that is created there in future. So if your girl friend gets an album and adds it to the library, you can hear the music and edit meta data for the files without changing the permissions anymore. Sounds interesting right? So here is a HOWTO for enabling and using ACLs in Mac OS X 10.5 Leopard, but this should also work in Mac OS X 10.4 Tiger.

First of all you have to activate ACLs for your file system. Therefore please launch the Terminal.app from your applications folder and execute the following:

sudo -s

“sudo” will make you superuser (sort of the ultimate administrator) and it will ask you for your password, so you can authenticate. Once you are authenticated the prompt of your terminal will change to:

bash-3.2#

Now you are superuser and can activate ACLs for your volume. Therefore execute the following:

fsaclctl -p / -e

After this line ACLs will be activated for your volume. So now you can create a folder and apply an ACL for it. Before you can apply the ACL you have to create this folder of course. So create a folder under /Users/Shared and call it iTunes. Now execute the following for applying an ACL to your created folder:

chmod +a “staff allow delete,chown,list,search,add_file,add_subdirectory,delete_child,file_inherit, directory_inherit” /Users/Shared/iTunes

The whole command is one line only. After this command every file that is created in /Users/Shared/iTunes will have special file permissions. Every user on your mac or a user who is member of the ’staff’ group (that is by default every user in Mac OS X) will have read, write and delete permissions, like it would be there own file. If you don’t want that every user has access to it, you can change ’staff’ in the above command to the short username of a user that should have the rights for the folder.

Finally you will have to copy your iTunes library in your home folder to the shared location into the new iTunes folder. It is important that you will have to copy the content, because ACLs only apply to objects that a created new. If you move something there is nothing that will be created new, resulting in no special permissions.

To check if everything worked you can copy any file to /Users/Shared/iTunes and check for file permissions via Cmd + i. If there is an entry under “Sharing & permissions” like “staff - custom” everything worked!

If you have any questions, just leave a comment!

Author: Muty Categories: Apple Tags: , , ,