How to set permissions of certain folders to 777 on Mac - macos

I need to set the permissions of just 3 specific folders (on my Mac) to 777
I went to CMND+i (get info) but the folder permissions seemed to be Read and Write - but this didn't seem to fix it.
I am trying to work out how to do this, because I am using MAMP on my Mac to try and run a localhost server to test a website. Reason; I am trying to run the script of a PHP website. It is asking me to change the permissions of certain folders in order to proceed with the 'install'.
I think the closest match to a possible answer is here:
Java: Create a new dir with 777 permissions on Mac
But, this appears to be Java. I assume that I need to be able to do this via either MAMP or Terminal. If anyone could please advise me which program/tool to use and what to type in, I'd be very grateful.
Thanks

I know how to do it in a terminal, to create "/some/directory/some/where" you can use -
# EDIT: 777 not 077.
mkdir -p /some/directory/some/where && chmod 777 /some/directory/some/where

Related

Visual Studio Code always asks for sudo permissions

Ok, so I've got a problem with VSCode where every time I try to save a file it asks me for sudo permission and it's really annoying and I can't make folders or files directly in the IDE. Can please someone help me?
Screenshot from VSCode
The running instance of VS Code doesn't seem to have write permission to the file you wish to save.
Since the file is in the directory of user uteu3, first make sure that it is user uteu3 that has started VS Code (it probably is, if uteu3 is the user logged into the system).
make sure uteu3 is the owner of the file and change the permissions by opening a terminal and executing:
sudo chown uteu3 filename && sudo chmod 664 filename
(Replace filename with actual path+name to the file.)
If this doesn't solve the problem, please execute the following two lines in a terminal and provide the output:
ps aux | grep visual-studio-code
stat -f '%A %a %N' filename
Since you indicate that this happens repeatedly also with other files, maybe several of the file permissions in your home directory are problematic. In that case, consider trying to fix them all. See for example: Need to fix file permissions in a user's home directory
.

Neofetch : acces denied folder .config

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.

VScode unable to save files inside my WSL2 home folder

I'm trying to make WSL2 work for my web projects development and this is driving me crazy!
Basically, i have two options.
1. Save my project files into c drive and access those with WSL (which makes the responses extremelly slow)
2. save my project files into /home/ which makes the project run super smooth, but i'm unable to edit those files with VSCode.
The error that is what follows:
Failed to save 'DefaultSeeder.php': Unable to write file 'vscode-remote://wsl+ubuntu-20.04/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php' (NoPermissions (FileSystemError): Error: EACCES: permission denied, open '/home/lucas/Projetos/API/src/database/seeds/DefaultSeeder.php')
Here is another command to provide your user with sufficient permissions to write to files:
sudo chown -R myuser /path/to/folder
From https://github.com/microsoft/vscode-remote-release/issues/1008
Well, turns out I was being stupid and posted a stupid question.
After many hours trying to make this damn thing work, I was able to do so, by setting the ownership of the folder to my user.
Here is the shell snippet to change the ownership to the current logged in user:
$ sudo find /~~folder-path~~/ -type d -user root -exec sudo chown -R $USER: {} +~
This solved it for me
sudo find /home/ -type d -user root -exec sudo chown -R $USER: {} \;
I had the same problem and spent hours to find this working solution.
For me, it seems to be right one because it doesn't produce problems with 1. too generous file permissions sent to git afterwards and 2. change ubuntu config to fit windows environment (coupling to windows user).
I found the source of this solution on github. Thanks to saltazaur!
https://github.com/microsoft/WSL/issues/4260#issuecomment-729594527
Steps to solve the problem:
Reset (or reinstall) the Ubuntu distro via Windows "Programs and Features"
Note: If you have data in your home directory already, copy it to windows before
Open Ubuntu & follow initial setup (create user)
Add file "/etc/wsl.conf" with:
cd /etc
sudo touch wsl.conf
sudo nano wsl.conf
copy and paste the content from microsoft docs
save with CTRL+X > "Y" > ENTER
restart wsl (or windows, to be sure ;))
At next startup of ubuntu, the settings in wsl.conf will be applied.
The important part in this case is the following line:
options = "metadata,umask=22,fmask=11"
It sets, that all newly created files will use umask 22 (chmod 775) and fmask 11 (chmod 644)
This settings also applies for IDEs like VSCode & PHPStorm.
Happy coding - finally! ^^
In my case, I cannot edit/delete any file directly by File Explorer too, not just VSCode.
After opening Ubuntu 22.04.1 LTS on Windows, run
sudo chown -R my_username my_folder
Note the my_username is the username in the Ubuntu.
This solves my issue.
I've managed to solve this issue as follows:
"Run as administrator" the VS Code
and then open folder -> locate the working folder.
It worked fine for me.

Laravel 4 permissions not showing

Im getting blank page while using Laravel, I already gave perms to the folder with
find app/storage -type d -exec chmod 777 {} \;
But still blank page.
Another thing you can try...
run php artisan serve from your projects root dir, and see if the browser comes up if you go to http://localhost:8000
And give us feedback in the run... because now we only can guess.
I don't know where you're at on solving this problem. But, you'll want your permissions to be at 775 not 777. Also, you may want to check ownership on your htdocs folder and all files within that directory. This is pure speculation since I don't know what kind of dev enviroment you're using, but i run a lamp stack and when ever I have to create a new enviroment the htdocs folder is always owned by root. You may want/need to chown that to your user account.
How about chmod -R 777 app/storage
If that does not work it is a htaccess problem propably
Last but not least, and it might sound stupid, but can you verify if the directories are all there in app/storage ? Because it happened to me that i was checking out from svn and empty directories are not transferred, so make sure you check that app/storage/logs exists.
If there is no log file written then it sure has to do with access levels, for example not being able to write into those dirs, hence the chmod command above. And i posted that because i had never seen anybody do it the way you did.
At least if you are able to write to the log file you can find out what exactly is wrong.
But we have so minimal information it is hard to help you in a good way.

how to edit and publish my files at same time in mac os?

I have a serious problem. Every time I edit my source code, I have to do a chown username:groupname for my htdocs folder. Now if I have to publish my files and have them executed on the webserver, I have to do a chown www:www for things to work right. I have tried to change my username,groupname in httpd.conf to my login in Mac OS but ownership still gets set incorrectly. I just want to be able to edit my source code and then not have to worry about changing the permissions.
What do I do?
Probably the easiest is to set the sticky bit of the enclosing directory and make www the group of it. So for example if you want to edit files in /Library/WebServer/Documents you would prepare it with
sudo chgrp www /Library/WebServer/Documents
sudo chmod g+s /Library/WebServer/Documents
Then all files you edit (or technically create) in Documents will have www group as well, so as long as your umask is reasonable (e.g. 0022) they will be readable by the web server and you can edit them as you please.

Resources