Neofetch : acces denied folder .config - macos

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.

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
.

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?
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

Cannot change com.apple.atrun.plist even with root permissions

I'm using OSX Mojave and I've been wanting to use the at command to run scripts at certain times, but I've discovered that I need to change its plist file in order to use it. Right now, one of the attributes in it is Disabled=true which of course, isn't what I want.
I've gone to the ends of the earth to try to change that. I tried XCode, Pref Setter, chmod, chown, vim, and doing all of that in root. No matter what, it always says, "readonly file" or "You do not have permission."
Are plists supposed to be immutable? I'm pretty sure they aren't. Here is some of the things I've tried.
~root# id
uid=0(root) gid=0(wheel) groups=0(wheel ...
~root# atrun=/System/Library/LaunchDaemons/com.apple.atrun.plist
~root# chmod 777 $atrun
chmod: Unable to change file mode on
/System/Library/LaunchDaemons/com.apple.atrun.plist: Operation not permitted
~root# ls -l $atrun
-rw-r--r-- 1 root wheel 444 Aug 22 23:11 /System/Library/LaunchDaemons/com.apple.atrun.plist
Make a copy of com.apple.atrun.plist from /System/Library/LaunchDaemons
into your home directory or wherever you want to work on it.
Open com.apple.atrun.plist with Xcode and the settings will show up in user readable form.
Change the setting for "Disabled" from 1 to 0 then save and exit Xcode
Copy your changed com.apple.atrun.plist file to /Library/LaunchDaemons
This can be manually launched to enable batch.

/usr/bin Permission change on mac

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

Unable to unlock file for editing in Xcode 4?

For some reason 2 of my files got locked and when I click the little lock icon in the upper right corner of the window it asks me if I would like to unlock, and doing so results in a "The file xxxx.h could not be unlocked" (Unlocking failed for an unknown reason). I have tried to restart Xcode, also tried to restart my machine with no help.
I am also unable to edit the files using BBEdit, I get the error "You do not have sufficient privileges to perform this operation (MacOS Error code: -5000)".
I'm running OS X Lion with Xcode 4.
Very strange as I have not made any changes to my system prior to this problem. Any help would be appreciated.
Open the file in any text editor. If the contents isn't text based you'll see a lot of gibberish. Ignore this, copy the contents. Open up a new text file. Paste the contents and save over the old file. This will copy just the contents of the file and ignore permissions.
What you're dealing with here is an ACL issue. If you ls -l the directory you'll see a little + on the end of the permission string:
drwxr-xr-x+ 4 eekyou staff 136 May 6 2011 eekyou.xcuserdatad
You can easily strip these off like so (in your project directory:
sudo chmod -R -E ./*
Hope this helps.
=]
The #eecue answer didn't help me. I user another Terminal command for complete removal of all ACL permissions:
sudo chmod -RN ./*
First check if the file is opened/locked by another program or user.
If it is not, the program probably crashed and failed to remove the flag, lookup the file and check with CMD+i if it is locked.
If it is not, permissions are probably wrong, so check the permission in the CMD+i dialog at the bottom, and apply them to everything in the enclosing folder (a .xcproject is a directory).
If this still doesn't work (like for me), there is a simple command line to unlock all files in a folder. ONLY do this if all the above steps have been checked / taken.
sudo chflags -R nouchg /Users/username/Development/GIT/MyProject
Replacing the project folder with your own project folder of course.
You may need to take ownership of the folder in which you wish to save your project. To do so, open up the console. Then type sudo chown $USER /path/to/your/project.

Resources