Terminal Permission Denied on OS X
If you are a more advanced Mac owner, then you probably know the Mac OS X Terminal application. However, the inner workings of a Mac can bemuse even the most tech-savvy user. File permissions, for example, can confound you when denying access to seemingly innocuous files. By understanding the Terminal, file permissions, and how to change them, you can avoid a permission denied warning in the future.
What is the Terminal?
The Terminal, by its most basic definition, represents a command-line interface to the computer. Unlike the graphical user interface, the command line requires you to use specific text-based commands. It also, however, gives you finer and more robust control over how you access the system: you can view hidden files, access programming interpreters for languages such as Python and Ruby, and run commands that are unavailable to you in the GUI.
When accessing files in the Terminal, the operating system presents no application barrier. That is, certain applications will only show or handle particular files, but in the Terminal, you have direct access to files. To protect against accidental file mismanagement, Unix operating systems such as Mac OS X have a system of file "permissions" that controls access to specific files. These permissions usually protect critical system files, or files created by specific users.
Permissions work by denying users access to files; this denial process works through a mechanism of access types. All files have three access types: read, write and execute. Reading and writing control permissions involved with viewing a file and modifying a file, respectively. Execute permissions control the ability to run the file as a program, such as in the case of executable source code. Each file also has an "owner" that can set these permissions and change them when required. An owner of a file has all permissions. The owner can also deny permissions by removing a particular permission for a user or group of users. For example, as owner of a file, you can remove execute and write permissions to make a file read-only.
There are two basic ways to circumvent permissions. One is to access the file as its owner and modify the permissions to allow you or all users to access the file. If you can only read the file, but you have access to the account that created the file, then you can use that second account to modify permissions to grant write access to your main account. Another, perhaps easier, way is to switch to administrator mode by entering "sudo su" at the command line, then entering your password. In administrator mode, you can change any permissions and access any files.
- Stockbyte/Stockbyte/Getty Images