1. Method 1:
If you get error: “Permission denied” when install patch, you should use: sudo -bash before you drag patch on terminal.
2. Method 2:
Apple’s OS X operating system for Mac computers is based on Unix. Once of the benefits of a Unix-based system is the ability to modify files and run commands from a terminal — not dissimilar from Linux terminals and commands. When your terminal commands return an error of “Permission Denied,” it’s usually a very simple fix regarding user permissions.
Your most likely encounter with a “Permission Denied” error is if you try to install a program or modify a file that’s locked — either because you’re not an administrator, or because the owner of the file used chmod to lock the file. If you have a warning before or after “Permission Denied,” read it to understand why you could not execute your command. You can check the permissions of a file by entering “ls -l file.ext” in the terminal, where “file.ext” represents the file and extension of the file you’re trying to modify.
You can try to force a command that requires administrator permission using “sudo,” though this shouldn’t be your first step, nor will it work if your account has been restricted. Check for errors in your syntax and that you’re trying to use the right command. If you’re trying to run a program, make sure that the program command is valid and installed on your computer.
Proceed with Caution
Before trying to force a command to work you should consider the potential downside. When something is locked to administrators only, it should serve as a warning that making this change could accidentally mess up your system It’s your system’s way of warning you to understand the risks before proceeding. Make any copies of relevant files just in case you need a backup later, and double-check that you know exactly what your command is supposed to do.
“Sudo” is a simple but powerful command that gives you the ability to run commands as an administrator briefly — for approximately five minutes. Run your command again, but with “sudo” preceding the command. If your denied command was the last one you tried to run, you can simply enter “sudo !!”. When you first run a program using sudo, you will be prompted for your password. Once authorized, your command will execute as though you’re running as the administrator or as root. If you still get a “Permission Denied” error, or are unable to use “sudo,” you may not have permission to do so labeled on your OS X account.
Understanding OS X Commands
The terminal window can be overwhelming the first couple times you use it — Unix commands are not always what you would expect, and different from commands you may be familiar with if you ever used Window’s command line prompt. SS64 offers a list of commands for OS X at ss64.com/osx, with descriptions as to what each command does and how it works. Additional, there’s a page dedicated to the syntax of commands at ss64.com/osx/syntax.html. This also makes a handy reference when you’re double-checking that using “sudo” won’t break your system.