I am trying to set up java on XCODE and it needs to access /usr/bin/java at some point. But I cannot get hold of this folder and I get this message:
The folder “java” can’t be opened because you don’t have permission to see its contents.
Even when I try to reach the permission through Get Info the system does not open the folder because of the same restriction. I think it is possible to change the permission through Terminal but I am afraid to blow up something on my mac.
How can I change the permission safely?
As the root user ("sudo su -" from the command line and then enter system password), execute the following from the command line -- "chmod 777 /usr/bin/java" . That won't blow anything up, and will allow read/write/execute (rwx) to the directory's owner, group, and guests.
-TU
Related
I need your help with an access issue with neofetch on my macOS.
Here the thing, I recently install neofetch on my terminal (oh-my-zsh), it works but, between the firts line (last login) and the logo that displays :
mkdir: /Users/'MYUSERNAME'/.config/neofetch/: Permission denied
/usr/local/bin/Neofetch: line 4476:
/Users/'MYUSERNAME'/.config/neofetch/config.conf: Permission denied
And I don't know why, of course, I did many types of research on google before asking you.
Do you have an idea?
You need to change the permissions for your config directory:
sudo chmod -R 666 /Users/YOURUSERNAME/.config
666 means Read-Write for all users.
Doing the same as garritfra did but with that last directory line you have there worked for me on a windows 10 machine though. It may work for the mac as well?
sudo chmod -R 666 /Users/MYUSERNAME/.config/neofetch/config.conf
Replace MYUSERNAME with whatever is shown in the error.
I was having the same issue and was able to solve this in the following way:
Open up Finder
Reveal hidden folders & files by pressing CMD+>+SHIFT
Locate the .config folder and right click it and click 'get info'.
Under the sharing & permissions section click the small plus and just add the entire Administrators group and remember to change the permissions to read & write for the entire group.
neofetch
Here is a bulletproof one-liner that solves the issue:
sudo chmod -R 710 $HOME/.config
Execute this command in a terminal session.
After restarting your terminal or, alternatively, sourcing your shell configuration file (assuming you have added the neofetch command to that file) with:
source ~/.zshrc
(replacing ~/.zshrc with the path to your shell configuration file if you are using a different one), the error prompt should disappear.
Note that this only gives 'execute' permission to the 'group' class. There is no need, as the currently accepted answer suggests, to give 666 or 777 modes as that needlessly makes your system less secure (not to mention even no. octal figures such as 666 don't even work as they fail to give the required 'execute' permission, which requires an odd number bit).
Modes such as 730, 750, and 770 will work, but unless something changes in neofetch's future update that demands it, it is unnecessarily too generous and I wouldn't advise it.
Finally, there is absolutely no reason to give users in the 'other' class any permission to the ~/.config directory (unless you have a very compelling reason to), and hence the last permission bit (3rd digit in the mode represented by octal numbers) should always remain 0.
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?
Be sure to give it the execution permission.
cd ~/the/script/folder
chmod +x ./startup.sh
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:
chmod u+x ./startup.sh
This will grant exec permission only to user
For reference
Alternatively you can use bash:
bash startup.sh
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.
Follow link for more details - https://support.apple.com/en-in/HT208050
You need to grant execution permission to your file. Here's a way to do that.
Navigate to the folder that contains your file and run this command-
chmod 755 <filename>
The three digits of the number 755 represent permissions for the three types of users- Owner, Group, and Others.
So, 755 represents-
Digit (octal)
Binary
read
write
executable
for
7
111
1
1
1
owner
5
101
1
0
1
group
5
101
1
0
1
others
Thus this command gives all three permissions- read, write and executable to the owner, while only read and executable to group and others.
More details about permissions in MacOS/Linux are discussed here- https://askubuntu.com/questions/932713/what-is-the-difference-between-chmod-x-and-chmod-755
Another annoying error can be n typo in the sh script.
In the following example, the ZSH error message does confusing. ZSH does tell you zsh: permission denied: startup.sh. But you have access rights to your script. The issue is the invalid Shebang line in the script:
#!/usr/local/bin sh
The right Shebang line can be e.g.:
#!/usr/bin/env sh
Below worked for me but I don't know why.
My file permissions before making the below change were -rwxr-xr-x. Even though I had the execute permission but still i got the permission denied error.
I am using vs code editor. I executed chmod +x filename and the file permissions still remained the same. The only difference this time was that I was able to run the file. Something changed about the file but it's not visible. The reason why I say it's not visible is that in the source control tab of my editor, my new file and old file looked 100% the same. If I stash my changes and execute the file then again same error.
I don't know why and how it worked but it's worth a try.
I will be more than happy if someone can explain the reason to me why it did not work earlier as I had the same permissions? Also, what changed in my file which is not visible to me?
add sudo before command start, will save your time like
sudo anyTemninalCommand
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 installed rvm (ruby version manager) and it was success, but I got
WARNING: You have '~/.profile' file, you might want to load it, to do
that add the following line to '/Users/myname/.bash_profile': source
~/.profile
I am new to developing, terminals and all that jazz! But better late than never?!
I entered into terminal:
'/Users/myname/.bash_profile'
and got back the following line
-bash: /Users/myname/.bash_profile: Permission denied
myname-MacBook-Pro:~ myname$
And that is where I am stuck! I need vrm for Drupal (Omega development) and want to make sure that everything is working fine. Thanks for your help.
Enter the .bash_profile file by running this in your terminal:
vim ~/.bash_profile
If you still get permission denied, run sudo before the vim command
sudo vim ~/.bash_profile
From there , press insert button . then add the text source ~/.profile to .bash_profileand press esc and then hit :x on your keyboard to save and close the file. Opening a new terminal window should remove the error.
Entering a filename will try to execute it. Instead, you want to edit it.
Open TextEdit (or your favorite editor) and open the file /Users/myname/.bash_profile in it.
You can do this entirely through the UI, but if you want, you can start an editor from the terminal:
open -a TextEdit /Users/myname/.bash_profile
You can then add the line source ~/.profile to the file and save it.
Close the terminal and open it again to apply the changes.
In my issue when I try with ssh on server, I get this error :
-bash: /home/user/.bash_logout: Permission denied
for resolved your user home directory must has a execute permission.
chmod +x <user_home_directory>
you must relogin next. If you add .profile
export PATH+=:$HOME/bin
without .bash_profile as I do all time you'll insert ~/bin search dir not the end of PATH and in middle. So .profile call before local profile formed and some others system dirs will be added after. It's bad so priority for you home binaries will higher then some system one. And may change undesired behavior with same names. So you need to add PATH in .bash_profile, not to .profile It's guarantee to add your home bin dir at the end of PATH. But don't delete ~/.profile at all. It's need to add some other data. This file call once at first login and .bash_profile call every time when second login with su without -l and then return back. If don't bother You will get two home bin dirs in PATH, next tree and so on. It's not well. So you must correct like that:
p=:$HOME/bin && test `expr $PATH : '.*'"$p"` -gt 0 || export PATH+=$p || true
It's grantee that home bin dir will add only one independent how many times you login after change effective user with su and then return back.
true at end better write so if on some unpredictable reasons error occurs in
command export PATH+=$p(sometimes such occurs) your profile load stops and you can't login at all. It's grantee that this line will run with any error generate.
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"