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

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.

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.

chmod just does nothing on my Mac?

I am the owner, as shown by ls -alts, but for whatever reason, I can't change the permissions of the files like I want. I want to make the file read only:
chmod 400 <file-name>
however, the ls -al still shows -rwxrwxrwx.
The file is on an external drive. I know that sometimes this causes issues when users want to read and write. However, in this case, I'd like to make the access to my files more restrictive not less restrictive.
I checked out this SO question but I don't see an option to make the permissions more restrictive.
thanks.
You can't change the permissions on the file because it's on a FAT32 volume, and that volume format does not support storing file permissions (see, for example, this askubuntu question). But if all you want to to is make the file read-only, you can get that effect by locking it (and the lock attribute is supported on FAT32). You can either use the Finder's Get Info window (check the "Locked" box), or use the command chflags uchg <file-name>.

make a file removable just by root in mac

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.

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