Saturday, March 5, 2011

Quick and Dirty Tips: 2 Terminal Commands

Terminal is a very useful application in Mac OS. It is a Mac application located at /Applications/Utilities folder. There are tones of command available you can use in Terminal. Actually many GUIs in Mac OK are based on those commands or scripts. The UI is used just for getting information to execute Terminal commands.

Here are two very interesting, I think useful as well, commands. The first one is reboot. Obviously it is a command to reboot your Mac. To execute it you have to use sudo command to do it:

YourMac:~$ sudo reboot

sudo is a command for supper user. The command reboot requires supper user to execute.

The second command is more flexible. It is shutdown. There are additional arguments you can specify to execute the command. For example, when you want to shutdown, reboot if you want to, force to shutdown if there are some other users on and messages you want to use as a warning notice. As same as the first one, you need to use sudo to execute the command:

YourMac:~$ sudo shutdown -r -k +2 Please get out of this machine!

The above commands will reboot the machine and force all the users log out in 2 minutes.

Another interesting thing I found is that normally, only the user with administrator privilege can execute above commands. If you are standard user, you cannot reboot your machine by those commands even you know the sudo password. This is Mac OS security issue. You may set standard user with root right, but I could not figure out. I think it is better to keep standard user in its default settings. Personally speaking, I think to use standard user is more secure. You just don't need the administrator rights in most cases if you just use apps such as Safari, iMovie, iPhoto or iWorks.

No comments: