Spotlight – Enable/Disable

I’m a big fan of spotlight on a Mac, but there are those out there who aren’t, if you happen to be one of them then this next bit is for you, you can disable spotlight by doing the following

Open Terminal and type the following

sudo nano /etc/hostconfig

locate the following item

SPOTLIGHT=-YES-

Change it so it now reads

SPOTLIGHT=-NO-

Press CTRL-X, then press Y, then press ENTER to save the file

Now to disable indexing type the following into Terminal

sudo mdutil -i off /

to erase the current index type the following into Terminal

sudo mdutil -E /

And thats that, Spotlight is now disabled, but if you realise that you have made a terrible mistake then don’t despair, you can enable spotlight again by basically reversing the work you’ve just done

so, in Terminal type

sudo nano /etc/hostconfig

locate the following item

SPOTLIGHT=-NO-

Change it so it now reads

SPOTLIGHT=-YES-

Now to enable indexing type the following into Terminal

sudo mdutil -i on /

and there you have it, a fully working spotlight

Repair Permissions

This is the most simple of maintenance tasks and one of the most overlooked, many people will take their machines to shops as they believe their machine has a serious problem, which can usually be fixed by this one task.

To do a permissions repair you have 2 options, using the Disk Utility app (recommended for most users), or using the command line, which is just as easy, but some people may not be that comfortable doing it this way.

So first, I’ll go through the Disk Utility method, this application is located in /Applications/Utilities

Double click on the application to start it up, now on the left hand side you will have a list of drives connected to your machine currently, on a MacBook Air you may only have your main hard drive listed, on a Mac Pro you may have several hard drives, a couple of SuperDrives, maybe some external USB drives etc.

The one you want to focus on is your system drive, this is usually the top one, but you want to click on the Volume, not the actual hard drive, the volume is usually just underneath with the same hard drive icon, but slightly indented from the edge, on a standard Apple installation this will be called Macintosh HD but it can be named anything.

Click on the Volume (Macintosh HD) and on the right hand side of the window you will have a few tabs, choose the First Aid one and at the bottom click Repair Permissions.

This will chug away for a while, if you do this regularly then it will only take a few minutes, but if you have never done it then it could take many hours.

Once done I’d recommend rebooting your machine and you should notice an improvement in performance, the reason for rebooting afterwards is I’ve found that quite often some applications or services that had issues starting up before the permissions repair
will end up in some sort of crashed state, so the repair won’t appear to have resolved anything, rebooting causes all of these items to restart and as they should now have the correct permissions and will be able to run correctly, thus not crashing, and not causing a system slowdown

Next I will run through the command line guide to this.

Open Terminal which is located in /Applications/Utilities

type

sudo diskutil repairPermissions /

this will prompt you for your admin password and will again chug away until done, you will recieve a better idea of its progress as it has a progress bar with a percentage completed, which the GUI option doesn’t have

All thats left to say is make sure you do this regularly, After every major software update or installation should be fine

I have done a video running through a Repair Permissions here

Create a Hidden Administrator

I like to hide the administrator account from prying eyes, this helps add to the security of your machine by not making it obvious what accounts are on the machine.

To do this you need to do a number of things, first of all log in to the Mac with an admin account.

Go to System Preferences, then Accounts, then click on Login Options & change the following options

Display login window as : Name and password
Disable Automatic Login

Next you can either create a new admin account to hide, or you can edit and hide an existing one

Now, right-click (CTRL Click) on the account you wish to hide and choose Advanced Options

Set the User ID to a number less than 500, I usually do between 490 and 499 as there are a few system accounts that use earlier numbers

Now change the Home directory to something someone wouldn’t think to look, a lot of people use /var/

It’s also a good idea to put a . in front of your home folder to hide it further, so the path would be /var/.admin

Now you need to move and rename your actual home folder, to do this it’s easiest to use the Terminal, so open that up and type the following

sudo mv /Users/admin /var/.admin
sudo chown -R admin /var/.admin

Now you need to remove the Public and Sites folders from your home folder, as you already have a Terminal window open then you can enter the following to remove them

sudo rm -R /var/.admin/Public /var/.admin/Sites

OK, now thats all done you need to make some changes to the loginwindow preferences, this can also be done in the Terminal, so enter the following

sudo defaults write /Library/Preferences/com.apple.loginwindow Hide500Users -bool TRUE
sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array admin

This will hide any account with a User ID under 500 and add your ‘admin’ account to the hidden users list

Test this by rebooting and logging in as a non-admin user, go to System Preferences and then Accounts, if all is well then the admin account will not show up

Now log out and log in as the hidden admin user, I tend to put some applications on the Desktop of this hidden account, just ones that I’d rather the end user of the machine not use as they have the potential to break their machines if not used correctly (I once had a user use OnyX to display hidden files and then they deleted the mach.kernel as they didn’t recognise the file and thought it could be a virus) so I now keep this out of their reach

Cloned Image Clean Up

If you have created an image of a Mac to deploy onto other Macs then you will need to clean the machine of certain user & machine specific files

To do this, you will need to mount the image on another machine and in Terminal enter the following

sudo rm /Volumes/MacHD/Users/username/Send Registration
 sudo rm -rf /Volumes/MacHD/Users/username/Desktop/*
 sudo rm -rf /Volumes/MacHD/Users/username/Downloads/*
 sudo rm -rf /Volumes/MacHD/Users/username/Library/Caches/*

Replace username with the name of any and all of the user accounts on the image

sudo rm -rf /Volumes/MacHD/Documentation/old_*
 sudo rm -rf /Volumes/MacHD/Library/Caches/*
 sudo rm -rf /Volumes/MacHD/System/Library/Caches/*
 sudo rm -rf /Volumes/MacHD/Library/Managed Preferences/*
 sudo rm -rf /Volumes/MacHD/Users/Shared/*
 sudo rm -rf /Volumes/MacHD/private/etc/ssh_host*
 sudo rm -rf /Volumes/MacHD/private/var/db/volinfo.database
 sudo rm -rf /Volumes/MacHD/private/var/vm/swap*
 sudo rm -rf /Volumes/MacHD/private/var/vm/sleepimage

In these examples, my image Volume is named MacHD, always make sure your image Volume is not named the same as your currently booted system volume, otherwise you could end up deleting these files from the wrong volume

Command Line System Config

To change a number of system settings via the command line you can use the systemsetup command in Terminal

For example, to change a computers name you would enter the following

First, find out the current name

sudo systemsetup -getcomputername

then if its not to your liking enter

sudo systemsetup -setcomputername "iAM_iMac"

This will change your computer name to iAM_iMac, I don’t like spaces in names so I subsitute them with underscores _, but you can call the machine anything you wish.

Another useful option is setting a network time server, to do this enter the following

sudo systemsetup -setnetworktimeserver ntp0.itsallmacademic.com

In my example my Mac will now try to get its time settings from ntp0.itsallmacademic.com, you will need to replace this with your own time server, as there is no time server at the above address.

I don’t like power failures, and the most annoying thing is having to boot up all the machines that are essential to the day to day running of the company, to get around this irritation I do the following on all my Mac Servers

sudo systemsetup -setrestartpowerfailure on

This sets the machine to boot itself up after a power failure, as all good servers should

If you wish to see the full range of commands at your disposal enter this

systemsetup -help