Skip to main content
18 events
when toggle format what by license comment
Jun 18, 2024 at 19:10 comment added QF0 Ah - ok - it all makes sense now :) If someone wants to write up an fs.protected_regular answer I'll accept it.
Jun 18, 2024 at 19:01 comment added QF0 @user4556274: on the dupe - yes, I saw that, thanks, and the fs.protected_regular sysctl does let me edit the file, as more-or-less suggested in the comments above. Your suggestion of editing as the user and group also works (why?). However, I'm still trying to get my head around why fs.protected_regular is relevant, since root owns the directory and the file, and the kernel.org docs explicitly state unless they are owned by the owner of the directory.
Jun 18, 2024 at 17:12 comment added user4556274 You should be able to edit the file directly ("magic") by running your editor as the user and group owning the file, e.g. sudo -u sysadmin -g crontab vi /var/spool/cron/crontabs/sysadmin or echo "# foo" | sudo -u sysadmin -g crontab tee -a /var/spool/cron/crontabs/sysadmin
Jun 18, 2024 at 16:52 comment added user4556274 Possible duplicate: unix.stackexchange.com/questions/691441/…
Jun 18, 2024 at 15:09 comment added QF0 @JosephSible-ReinstateMonica: cat /proc/sys/fs/protected_regular gives 2, and ls -ld gives drwx-wx--T 2 root crontab.
Jun 18, 2024 at 14:53 comment added Joseph Sible-Reinstate Monica What does ls -ld /var/spool/cron/crontabs/ say? What is the fs.protected_regular sysctl set to?
Jun 18, 2024 at 14:31 history edited QF0 CC BY-SA 4.0
added 427 characters in body
Jun 18, 2024 at 14:24 comment added QF0 @JosephSible-ReinstateMonica: # echo "foo" >> sysadmin reports bash: sysadmin: Permission denied. Root can't write the file; it can only delete the file. This smells like a kernel config of some sort, like a write to a file in /tmp, but I can't find any docs on it.
Jun 18, 2024 at 14:21 comment added QF0 @steeldriver: I know that I can edit it with crontab -e - what I'm trying to find out is what magic crontab is using to allow the file to be written to, when a root user can do nothing apart from deleting the file? I'm assuming that there's a kernel config of some sort that's stopping me doing this, hence the sysctl tag.
Jun 18, 2024 at 3:50 comment added Joseph Sible-Reinstate Monica Can you edit it with vi or nano, or do things like echo '# hello' >> /var/spool/cron/crontabs/sysadmin?
Jun 18, 2024 at 1:18 comment added waltinator You should include (server-start) in your ~/.emacs, and export EDITOR="$(type -p emacsclient)";export VISUAL="$(type -p emacsclient)";alias emacs="$(type -p emacsclient)"` to your shell startup file. Start 1 /usr/bin/emacs at login. Once EDITOR and VISUAL are set, you can use sudoedit to edit a file (sudoedit, running as root, copies the target file to a temporary location (changing ownership to $USER), then, running as $USER, invokes $EDITOR or $VISUAL on the temporary copy. If the copy is changed, sudoedit, running as root copies it back.
Jun 17, 2024 at 23:17 history edited Marcus Müller CC BY-SA 4.0
edited title
Jun 17, 2024 at 19:43 comment added steeldriver You can (and should) use crontab -e regardless of which editor you want to use - just specify emacs via the EDITOR or VISUAL environment variable. See for example crontab -e doesnt shows option to select editor - what to do?
Jun 17, 2024 at 16:29 history edited QF0 CC BY-SA 4.0
added 248 characters in body
Jun 17, 2024 at 16:09 comment added terdon Please edit your question and show us i) how you try to edit it and ii) how it fails. Is there an error? What error? Is there no error but your changes disappear? What happens?
Jun 17, 2024 at 15:53 comment added QF0 @Kusalananda: I can't edit it with emacs - I assume that crontab -e would work.
Jun 17, 2024 at 15:34 comment added Kusalananda You mean you can't edit it with crontab -u sysadmin -e as root?
Jun 17, 2024 at 15:25 history asked QF0 CC BY-SA 4.0