apple

Permissions Repair in Command Line (or Single User Mode)

So today I want to look at how to do a permissions repair thought Single User Mode.

Heres the code.

fsck /

mount -uw /

/usr/libexec/register_mach_bootstrap_servers /etc/mach_init.d

/sbin/SystemStarter start SecurityServer

diskutil repairPermissions /

To start you want to boot into Single User Mode by holding Command + S after the gong. Once the computer has booted you will start with fsck /. This will check the file system to make sure it was properly unmounted and is ready to be mounted again.

Next you will use mount -uw /. mount is the command used to mount the hard drive, which allows for you to use the hard drive. The option -u basically changes the files system to read-write or to read-only depending on what its currently set at. Option -w mounts the drive as a read/write files system. The combination allows you to have read/write access to the drive you are mounting, which brings us to /. / is the location of the drive that you wish to mount, which in most cases is you main Mac hard drive. / is the root of the drive so you are mounting the whole drive and not just a folder in the drive.

After that you will use /usr/libexec/register_mach_bootstrap_servers /etc/mach_init.d. Here you are starting some services to allow you to run the necessary tools. mach_init.d is responsible for many programs, such as networking, directory services, disk arbitration, and so on.

Next you use /sbin/SystemStarter start SecurityServer. This starts more of the system, more networking items and some other items that would be in StartupItems. It gets the rest of the system before Aqua up and running so that you can run the commands you need.

The final command is the meat of what we are trying to do here. diskutil repairPermissions is how to repair your permissions thought the command line. If you are at the computer and its running or you can SSH into the machine or are running ARD and can send UNIX commands this is all you need.

As usually let me know if you have any questions about this or anything else I can write on. Maybe one of these days I will write a none techie article.


Permission and Owner on Mac (and Sometimes Linux)

Sometimes when I have to copy data to another machine it won’t let me access some of the files. There are two commands I try to get around this issue.

Of course you could check the man pages for chown or chmod but I will show you how I use them with my limited needs.

I will start with chown. I use this command to change the owner from what the files might think the former owner is, or is some case from who the owner actually was to me, or the new user. Here is how I do it.

Start by opening Terminal which is located in Applications > Utilities > Terminal, then use the following commands.

sudo chown -Rv user /filename/*

Here I use sudo to make sure I am running as the super user for this command, the -R (NOTE: the capital is important) is to make sure its recursive (meaning it will apply to child folders and files) and the -v is for verbose so that it will output what files the command is currently working on. I like verbose so that I know its still going and I can easily tell when its done. user refers to the user I want the ownership to pass to. /filename/* is the location of the file, on my Mac if I need to run the permission change on my music files I would use the short name of my account like:/Users/cwelker/Music/* I use the * out of habit to make sure it is going though the whole folder, which is what -r is doing as well, but it will not matter to have running both.

The other command I want to look at, I really only use when I am working with web design or installing some websites. I really only use this one way, and it opens the files wide open. I use this only when I need to, normally I can use my FTP programs to do the same thing, but either way here it is.

sudo chmod -rv 777 /filename/*

Some parts of this command will look familiar. The main difference is going to be that instead of one user you are modifying the files permissions for groups. The numbers refer to the user groups and what they can do with them. A better explination and a calculator of what the numbers can do can be found here

Comments and questions are always welcome and let me know if I can write something for you.

1 Comment more...

Apple re-arm

I wanted to talk about a little thing I use sometimes when preparing to give a computer for a buy out or if selling a machine. you can also you this if you have lost the admin password to reset it.

Restart the computer into Single User Mode by pressing Command + S after the gong.

This command will mount the Hard Drive

mount -uw /

Then you use this command to remove the users, remove the network setup and the last part of the command triggers the startup configuration to run again. NOTE: in OS X 10.5 and 10.6 the netinfo section no longer is needed.

rm -rf /Users/ /var/db/netinfo/local.nidb /var/db/.AppleSetupDone

Once your are done run this command to reboot or shutdown.

reboot (or shutdown -h now if you don’t want the machine to turn back on)

Thats pretty much it. If there are other Apple questions anyone has, I am more then happy to go though them


Copyright © 2009 Welker's Blog
Jarrah theme by Templates Next | Powered by WordPress