I'm trying to copy a directory in terminal from the Downloads directory to a sub-directory within the Applications/ directory, and I keep getting "Permission denied" error. Why is this so?
try
ls -lt
to see access permission of the folder you want copy file into
then use
chmod 777 your_folder_name
to change the access permissions of the folder
If you "right-click -> Get info" the Applications folder you will notice that the permissions for the Applications folder are Read/Write for 'system' or 'admin'. For 'everyone' it's Read-only. If you are not an admin you need to use 'sudo cp -R Downloads/___Test /Applications'. Obviously, you need to enter a password.
MacOS prevents interaction with downloaded files until you confirm that they are safe. You can effectively do this programmatically by running:
xattr -d com.apple.quarantine ~/Downloads/your_file_here
Then you should be able to copy the file.
i'm trying to make a file removable just by root user In mac 10.10.
i was try this :
chown root <fileName>
but other user can remove it;
any idea?
As an alternative to changing the permissions on the containing directory, you can set the uimmutable flag on the file:
sudo chown root foo
sudo chflags uimmutable foo
Now only root will be able to delete foo. Note, though, that nobody will be able to modify the file, either. Root could remove the uimmutable flag and then modify it, of course, but that opens a window for others to delete it.
The act of removing an entry in a directory modifies the directory, but not the file. (When you remove a file, you are unlinking the name from the file and the link count on the file is decremented. The file itself may not be deleted, but will no longer be accessible by the name that was removed.) In order to ensure that only some process with root privilege can unlink a file, you need to modify the permissions on the directory. So to ensure that no-one but root can delete the file /p/a/t/h/file:
sudo chown root /p/a/t/h # make root the owner of the directory
sudo chmod og-w /p/a/t/h # remove write permissions from other and group
Note that this is less fine grained that you might like and will prevent non-root users from removing or creating any files in /p/a/t/h.
So I did a command
sudo cp myfile /Desktop
my file was an executable and It changed my desktop to be an executable I need to reset to be a directory with permissions drwxrwxr-x+
Can someone please help Thanks
I think the correct command to change permissions on a file/folder is chmod or you could reset to default using umask (but I'm not sure about how to use this as well)
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.
Did you give yourself the rights to execute the script?
The following command as super user will do this for you:
sudo chmod 755 'filename'
For details you should read the man page of chmod.
Please read the whole answer before attempting to run with sudo
Try running sudo /dvtcolorconvert.rb ~/Themes/ObsidianCode.xccolortheme
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:
~/dvtcolorconvert.rb ~/Themes/ObsidianCode.xccolortheme
Move it to ~/ 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:
$ ls -l
total 13
drwxr-xr-x 4 or019268 Administ 12288 Apr 10 18:14 TestWizard
drwxr-xr-x 4 or019268 Administ 4096 Aug 27 12:41 Wizard.Controls
drwxr-xr-x 5 or019268 Administ 8192 Sep 5 00:03 Wizard.UI
-rw-r--r-- 1 or019268 Administ 1375 Sep 5 00:03 readme.txt
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 <command>
In my case, I had made a stupid typo in the shebang.
So in case someone else on with fat fingers stumbles across this question:
Whoops: #!/usr/local/bin ruby
I meant to write: #!/usr/bin/env ruby
The vague error ZSH gives sent me down the wrong path:
ZSH: zsh: permission denied: ./foo.rb
Bash: bash: ./foo.rb: /usr/local/bin: bad interpreter: Permission denied
You should run the script as 'superuser', just add 'sudo' in front of the command and type your password when prompted.
So try:
sudo /dvtcolorconvert.rb ~/Themes/ObsidianCode.xccolortheme
If this doesn't work, try adapting the permissions:
sudo chmod 755 /dvtcolorconvert.rb
sudo chmod 755 ~/Themes/ObsidianCode.xccolortheme
To run in the administrator mode in mac
sudo su
use source before file name,,
like my file which i want to run from terminal is ./jay/bin/activate
so i used command "source ./jay/bin/activate"
Check the permissions on your Ruby script (may not have execute permission), your theme file and directory (in case it can't read the theme or tries to create other themes in there), and the directory you're in when you run the script (in case it makes temporary files in the current directory rather then /tmp).
Any one of them could be causing you grief.
I installed XAMPP 1.7.3 on Mac OS X 10.6.8 without changing any defaults.
The webserver seems to work okay, but the permissions on the htdocs directory are set to "Read only" for everyone other than system. So (a) I have to provide root password every time I copy in web content, and, more problematic, (b) NetBeans says it can't create a target directory, and doesn't even generate the index.php file in the source directory.
Do I just need to manually change permissions on the htdocs directory, or is there some more global XAMPP setting that should be changed? Running NetBeans as root seems a bit extreme.
Tried the above but the option to amend the permission was not available for the htdocs folder,
My solution was:
Open applications folder
Locate XAMPP folder
Right click, get info (as described above)
In pop-up window locate the 'sharing & permission' section
Click the 'locked' padlock symbol
Enter admin password
Change 'Everyone' permissions to read & write
In the get info window still, select the 'cog' icon' drop down option at the very bottom and select 'Apply to enclosed items' this will adjust the permission across all sub-folders as well.
Re-lock the padlock symbol
Close the 'Get Info' window.
Task complete, this will now allow you to populate sub-folders within the htdocs folder as needed to populate your website(s).
Make sure the XAMPP app is running then:
Under General Tab, in XAMPP app, click Open Terminal
A terminal will be launched with something like, root#debian:~#, on the terminal shell
on that terminal shell, type, chmod -R 0777 /opt/lampp/htdocs/ and enter
Exit, the terminal and you be good to go
For latest OSX versions,
Right click on the folder
Select Get Info
Expand the Sharing & Permission section
Unlock the folder by clicking lock icon on bottom right-corner
Now, select the user list and enable Read & Write privilege for the users
Click on the + icon to add username
Finally click settings icon and select Apply to enclosed items...
Following the instructions from this page,
Open the XAMPP control panel (cmd-space, then enter manager-osx.app).
Select Manage Servers tab -> select Apache Web Server -> click Configure.
Click Open Conf File. Provide credentials if asked.
Change
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
</IfModule>
to
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User your_username
Group staff
</IfModule>
Save and close.
Using the XAMPP control panel, restart Apache.
Navigate to the document root of your server and make yourself the owner. The default is /Applications/XAMPP/xamppfiles/htdocs.
$ cd your_document_root
$ sudo chown -R your_username:staff .
Navigate to the xamppfiles directory and change the permission for logs and temp directory.
$ cd /Applications/XAMPP/xamppfiles
$ sudo chown -R your_username:staff logs
$ sudo chown -R your_username:staff temp
To be able to use phpmyadmin you have to change the permissions for config.inc.php.
$ cd /Applications/XAMPP/xamppfiles/phpmyadmin
$ sudo chown your_username:staff config.inc.php
For new XAMPP-VM for Mac OS X,
I change the ownership to daemon user and solve the problem.
For example,
$ chown -R daemon:daemon /opt/lampp/htdocs/hello-laravel/storage
If you use Mac OS X and XAMPP, let's assume that your folder with your site or API located in folder /Applications/XAMPP/xamppfiles/htdocs/API. Then you can grant access like this:
$ chmod 777 /Applications/XAMPP/xamppfiles/htdocs/API
And now open the page inside the folder:
http://localhost/API/index.php
Best solution for MAC OS Catalina Xampp
Open Finder
Press Cmd + shift + C
Macintosh HD => Users => copy {username}
Open /Applications/XAMPP/xamppfiles/etc/httpd.conf
Find User daemon edit daemon => {username}
Xampp Manage Server => Restart all
If you encounter problems in phpMyAdmin:
1. Browser (Chrome) restart
Goodluck
Go to htdocs folder, right click, get info, click to unlock the padlock icon, type your password, under sharing permission change the priviledge for everyone to read & write, on the cog wheel button next to the + and - icons, click and select apply to all enclosed items, click to accept security request, close get info. Now xampp can write and read your root folder.
Note:
If you copy a new folder into the htdocs after this, you need to repeat the process for that folder to have write permission.
When you move your files to the live server, you need to also chmod the appropriate files & folders on the server as well.
if you use one line folder or file
chmod 755 $(find /yourfolder -type d)
chmod 644 $(find /yourfolder -type f)
You can also simply change Apache Conf file to a different User Name and keep the group:
Apache Conf Applications/Xammp/etc/..
User 'User' = your user name in Mac os x.
Group daemon
sudo chown -R 'User':daemon ~/Sites/wordpress
sudo chmod -R g+w ~/Sites/wordpress
If you are running your page on the new XAMPP-VM version of MacOS you will have to set daemon as user and as group. Here you can find a great step-by-step illustration with screenshots from aXfon on how to do this.
As the htdocs folder under XAMPP-VM will be mounted as external volume, you'll have to do this as root of the mounted volume (root#debian). This can be achieved through the XAMPP-VM GUI:
See screenshot.
Once you are running as root of the mounted volume you can as described above change the file permission using:
chown -R daemon:daemon /opt/lampp/htdocs/FOLDER_OF_YOUR_PAGE
Source (w/ step-by-step illustration): aXfon
What worked for me was,
Open Terminal from the XAMPP app,
type in this,
chmod -R 0777 /opt/lampp/htdocs/
This Solved WordPress Filesystem Permissions in Bitnami XAMPP
By changing the file permissions in apps/wordpress folder mounted on MAC XAMPP-VM shown in the below screenshot.
sudo chown -R bitnami:daemon TARGET # [ Replace "TARGET" with your file/folder path ]
find TARGET -type d -print0 | xargs -0 chmod 775
find TARGET -type f -print0 | xargs -0 chmod 664
chmod 640 TARGET/wp-config.php
Source: bitnami
TARGET - Replace placeholder for your mounted filesystem wordpress path eg: '1.1.1.1/lampp/apps/wordpress'
Now you can edit your themes in VS-Code or any developer editor of your choice.
NOTE: This should be done only in your development environment.
Production build permissions are different & above doesn't apply
The above worked only for some directories but didn't for all root files. To change root files permissions, open Xampp app, within Xampp app click button 'open terminal'. once there do the following:
- go to root directory: cd ..
- got to directory where lamp is located: cd opt
- change lampp permissions: chown -R bitnami:root lampp
note: you can replace bitnami with your user, and root with your group.
as a second alternative that worked for some files:
go to your users folder in finder and find the .bitnami hidden folder, access xampp folder within it and change permissions:
/Users/username/.bitnami/stackman/machines/xampp
right click xampp folder under machines and change permissions to read & write
apply to enclosing folders with "cog icon"