Apple Terminal

From HaFrWiki
Revision as of 18:57, 12 November 2012 by Hjmf (talk | contribs) (Created page with "{{TOCright}} Terminal is a low level tool to access all your Apple iMac settings. That makes terminal a very nice and powerful tool, but also a very dangerous one. == Default...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Terminal is a low level tool to access all your Apple iMac settings. That makes terminal a very nice and powerful tool, but also a very dangerous one.

Defaults

All Apple designed applications have settings that can be changed using the terminal. The default setting of these variables are stored in the directory structure of the App in a file Defaults.plist. This file is ReadOnly and can not be altered. The first way to alter the content of this file, is by using the command:

  defaults write <name-of-application> <variable-name> <variable-type> <new-settings>

As always an example helps. To show all hidden files in Finder use:

  defaults write com.apple.finder AppleShowAllFiles -bool YES

It maybe necessary to reload finder. To kill al Finder instances:

   killall Finder

Alternative

There is an alternative for this way of editing. Because this way may cause the system to be instable this method is not recommended for beginners. The defaults ate mostly stored in the file Defaults.plist, a property file of the Xcode system. This file can not be edited without making modification.


Step 1: Get the location of the Defaults.plist file. First go to the directory where the Application is located i.e. for Safari

  > cd /Applications/Safari.app
  > find . -name Def*.plist

Go to the found directory

  > cd Contents/Resources


Step 2: Inspect the current access rights of file

  > stat -x Defaults.plist
    File: "Defaults.plist"
    Size: 4191         FileType: Regular File
    Mode: (0644/-rw-r--r--)         Uid: (    0/    root)  Gid: (    0/   wheel)
  Device: 14,2   Inode: 4775514    Links: 1
  Access: Wed Oct 19 11:51:38 2011
  Modify: Wed Oct 19 11:52:49 2011
  Change: Wed Oct 19 11:53:14 2011

Note the Mode value for chmod is 0644.

Step 3: Change the access right of the file. Because the file is protected use the sudo command

  > sudo chmod -v ogn+w Defaults.plist
  Password: XXXXXXX

The system master password is necessary for performing this command.

Step 4: Check the changed mode:

  > stat -x Defaults.plist

Note that the Mode value has been changed by chmod into 666.

Step 5: Edit the file with vi

  > vi Defaults.plist


Step 6: After changing the file, reset the file access to the old value

 > sudo chmod -v 644 Defaults.plist

Dock

Make hidden applications's dock icons translucent

  defaults write com.apple.Dock showhidden -bool YES

iTunes

Normally the arrows next to artists and albums in your iTunes library search the iTunes store when you click them. This command changes them so that clicking will search your iTunes library instead.

   defaults write com.apple.iTunes invertStoreLinks -bool YES

Safari

Enable the debug menu in Safari.

   defaults write com.apple.safari IncludeDebugMenu -bool YES

Set the history limit in Safari to a certain number of items and and/or a certain age.

   defaults write com.apple.Safari WebKitHistoryItemLimit 2000

and/or

   defaults write com.apple.Safari WebKitHistoryAgeInDaysLimit 30

Unix on Mac

The Unix on the Mac is of course not completely the same as other Unix variants. Here some useful issues:

chmod & stat

To view the human readable and the decimal version of the file access rights, you can use the following trick:

  stat -f  "%Sp - %p :  %N" <filename> 
  •  %Sp : Shows the file access in the human readable form (-rw-r--r--)
  •  %p  : Shows the file access in a decimal form ( 100644)
  •  %N : Shows the filename

Example output:


Another example:

  stat -f "%Sp ->owner=%SHp group=%SMp other=%SLp  %p : %N " *

Shows:

  -rw-r--r-- ->owner=rw- group=r-- other=r--  100644 : Defaults.plist 
  -rw-r--r-- ->owner=rw- group=r-- other=r--  100644 : DownloadResume.tif 
  -rw-r--r-- ->owner=rw- group=r-- other=r--  100644 : DownloadResumePressed.tif 
  -rw-r--r-- ->owner=rw- group=r-- other=r--  100644 : DownloadResumePressed_Selected.tif 

Or

  drwxr-xr-x ->owner=rwx group=r-x other=r-x  40755 : /Users/frielink/Public 
  lrwxr-xr-x ->owner=rwx group=r-x other=r-x  120755 : /Users/frielink/Send Registration 
  drwxr-xr-x ->owner=rwx group=r-x other=r-x  40755 : /Users/frielink/Sites 
  drwxr-xr-x ->owner=rwx group=r-x other=r-x  40755 : /Users/frielink/VOF De Kunst 
  -rwxr-xr-x ->owner=rwx group=r-x other=r-x  100755 : /Users/frielink/finderAll.sh 

Another very useful command:

  stat -x <file>

Gives:

   File: "Defaults.plist"
   Size: 4190         FileType: Regular File
 Mode: (0644/-rw-r--r--)         Uid: (    0/    root)  Gid: (    0/   wheel)
 Device: 14,2   Inode: 4775514    Links: 1
 Access: Wed Oct 19 09:47:47 2011
 Modify: Mon Jul 25 23:24:53 2011
 Change: Mon Jul 25 23:24:53 2011



See also

top

References

top