Run script on mac prompt “Permission denied”
I’m new to mac with not familiar on terminal command, i put the dvtcolorconvert.rb file on root directory of my volume, this ruby script can converting xcode 3 themes into xcode 4 themes format, which is xxxxxxxx.dvtcolortheme format.
Then run the script /dvtcolorconvert.rb
/Themes/ObsidianCode.xccolortheme on terminal, but it’s always prompt «Permission denied«.
what’s wrong with this? Anybody can help me solve this problem? Thanks.
6 Answers 6
Please read the whole answer before attempting to run with sudo
Try running sudo /dvtcolorconvert.rb
The sudo command executes the commands which follow it with ‘superuser’ or ‘root’ privileges. This should allow you to execute almost anything from the command line. That said, DON’T DO THIS! If you are running a script on your computer and don’t need it to access core components of your operating system (I’m guessing you’re not since you are invoking the script on something inside your home directory (
/)), then it should be running from your home directory, ie:
/ or a sub directory and execute from there. You should never have permission issues there and there wont be a risk of it accessing or modifying anything critical to your OS.
If you are still having problems you can check the permissions on the file by running ls -l while in the same directory as the ruby script. You will get something like this:
You will notice that the readme.txt file says -rw-r—r— on the left. This shows the permissions for that file. The 9 characters from the right can be split into groups of 3 characters of ‘rwx’ (read, write, execute). If I want to add execute rights to this file I would execute chmod 755 readme.txt and that permissions portion would become rwxr-xr-x . I can now execute this file if I want to by running ./readme.txt (./ tells the bash to look in the current directory for the intended command rather that search the $PATH variable).
schluchc alludes to looking at the man page for chmod, do this by running man chmod . This is the best way to get documentation on a given command, man
Восстанавливаем права доступа под Mac OS X — EL Capitan
При переходе на El Capitan ряд пользователей столкнулся с проблемами прав доступа — неработающее sudo, некорректная timezone, etc…
Корнем зла является урезанный доступ к /private/etc.
Для начала, вам, стоит проверить свой. Откройте Terminal (это можно сделать через Spotlight) и введите ls -la /private.
Вот так «drwxr-xr-x» и должны выглядеть права на etc. Если они выглядят больше похожими на «drwx——», то вам к нам.
Казалось бы — всего-то дел — восстановить права доступа: Spotlight -> DiskUtility -> FirstAid… а где же теперь Repair Permission?
Как оказалось, эта опция больше недоступна через GUI.
Однако как подсказывает нам Google (например — osxdaily.com/2015/11/04/verify-repair-permissions-mac-os-x ), это всё ещё можно сделать через командную строку:
Таким образом, всё что нам нужно чтобы восстановить работоспособность sudo это… работающее sudo! Несколько иронично, не так ли?
Тем не менее — выход есть.
Для того, чтобы починить права необходимо:
1. залогиниться пользователем с правами администратора
2. получить доступ к пользователю root
3. изменить права доступа на папку /private/etc
1. залогиниться пользователем с правами администратора
С первым пунктом я вам ничем не помогу. Если ваша учетная запись уже имеет права администратора — используйте её. Если нет — найдите своего администратора.
2. получить доступ к пользователю root
Для того, чтобы получить доступ к root запустите приложение «Directory Utility». Я бы рекомендовал открывать его через Spotlight.
После запуска программы кликните на замок и введите пароль своего пользователя чтобы «Directory Utility» позволил вам внести изменения.
Зайдите в меню Edit. Если у вас есть пункт «Enable Root User» начните с него. Если же вместо этого пункта вы видите «Disable Root User», то сразу же выбирайте «Change Root Password. »
Введите пароль и повторите его для контроля. Приличные люди не используют для root тот же пароль, что и для своего обычного пользователя.
3. изменить права доступа на папку /private/etc
Запустите Terminal (это, опять таки, можно сделать через Spotlight).
Введите команду su.
При вводе этой команды система запросит у вас пароль. Надо вести пароль root пользователя. Именно тот, который вы установили на втором шаге, а не ваш обычный пароль.
Если вы ввели его верно, то у вас появится приглашение командной строки с решеткой на конце. Что-то вроде:
Итак, мы всего в одном шаге от успеха. Осталось изменить права доступа и проверить результат. Для изменения прав используйте команду «chmod aug+rx /private/etc». Для проверки результата — ls -la /private
Terminal error: zsh: permission denied: ./startup.sh
I am running a command ./startup.sh nginx:start and I am getting this error message zsh: permission denied: ./startup.sh why could this be happening?
3 Answers 3
Be sure to give it the execution permission.
This will give exec permission to user, group and other, so beware of possible security issues. To restrict permission to a single access class, you can use:
This will grant exec permission only to user
Alternatively you can use bash:
Then you don’t need execution permission.
In MacOS Catalina, Apple has replaced bash with zsh as default shell. This can mean, that they intend to remove bash in the future, so this might not be an option later, but with Catalina it still works.
Starting with macOS Catalina, Your Mac uses zsh as the default login shell and interactive shell. You can make zsh the default in earlier versions of macOS as well.
How to change your default shell Whether your user account is configured to use zsh (recommended), bash, or another shell, you can change the default shell from Users & Groups preferences or the command line.
- From Users & Groups preferences
- Choose Apple menu > System Preferences, then click Users & Groups.
- Click the lock , then enter your account name and password.
- Control-click your user name in the list of users on the left, then choose Advanced Options.
- Choose a shell from the ”Login shell” menu, then click OK to save the changes.
Question: Q: Trouble installing macOS — permission denied
I am having trouble installing MacOS Sierra due to a «Permission Denied» notice. I have read lots of forum info about this problem, but can’t seem to make any suggestions work because there is nothing installed on the hard drive right now. Upon reboot, the macOS utilities opens right away and the only options are restore, reinstall, get help online and disk utility. If Reinstall macOS doesn’t work, what are the other options? I don’t see how to repair permissions from the available screens.
Thank you for any help!
Posted on Dec 15, 2017 4:50 PM
Helpful answers
You are welcome. You posted earlier that the First Aid tab in Disk Utility is available. If that is still true, try running First Aid until you get no errors, then try the install again.
Dec 18, 2017 6:18 AM
Go ahead and download Sierra. Then quit the installer if necessary. You can make a bootable USB stick to install using this free program which will do all the work for you.
Dec 18, 2017 6:18 AM
There’s more to the conversation
Loading page content
Page content loaded
Try using Disk Utility to format the disk. If it’s an SSD use APFS with a GUID table. If it’s a regular old fashioned HD, use HFS+ Journaled with a GUID table.
Dec 15, 2017 4:57 PM
Don’t use APFS if you are trying to install Sierra. That is a High Sierra format.
If you have a backup, r un Disk Utility/First Aid. Reformat the drive using Disk Utility/Erase Mac OS Extended (Journaled), then click the Option button and select GUID. Quit Disk Utility, then re-install the OS.
Dec 15, 2017 5:26 PM
Ok, why are all the options in Disk Utility grayed out? It doesn’t look like I can reformat.
The two options Apple SSD SD0128SF Media lets me First Aid or Partition, and the OS X Base System under that only has First Aid available.
Thanks for your quick responses!
Dec 15, 2017 7:07 PM
Try booting into Internet Recovery (command — option/alt — R on a restart). It is a slow process. This will install the OS that the computer shipped with. You can then try to upgrade from there.
Dec 15, 2017 7:24 PM
Thank you. I did that and it went through the spinning globe, then the apple restarted and took me right back to the disk utilities screen that is just the same as before. I tried quitting Disk Utilities and it asks me to choose a startup disk. The only option there is OS X Base System macOS, 10.12.6. I select it and restart and it takes me back to the Disk Utilities. What do I do from there? I tried Reinstall macOS again from there and it has the same Permission denied message.
Dec 16, 2017 8:53 AM
You are welcome. You posted earlier that the First Aid tab in Disk Utility is available. If that is still true, try running First Aid until you get no errors, then try the install again.
Dec 18, 2017 6:18 AM
I have run First Aid a few times, simply because there wasn’t anything else to do, but there haven’t been any errors. It takes a couple seconds and then its done. Operation successful. Nothing in the details.
Dec 16, 2017 12:04 PM
My son thinks I need to download the OS onto a flash drive and use that to install from. Is that possible? When I go to the download link for macOS Sierra, this iMac I’m on thinks I want to use it on this computer and says «A newer version of macOS is already installed on this computer. Are you sure you want to download macOS 10.12.6?» So it doesn’t seem like there is a way to just put an installer on flash drive. Obviously the days of putting in a CD with the OS software on it are gone. so what are some other options?
Sorry to be taking up so much of your time.