5

I have this situation, a real folder called "git" is symlinked to .githooks:

enter image description here

Is there a way to make the symlinked files non-writable, without affecting the original files? I don't want users to accidentally modify the source in the git folder form the .githooks folder.

I tried:

chmod -R .githooks/* 555

and

chmod -R .githooks/* 544

and I got this both times:

chmod: Invalid file mode: .githooks/pre-commit
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 1
    On macOS the [`chmod`](https://ss64.com/osx/chmod.html) utility has the `-h` option to change the mode of the symlink rather than the file that it points to. However, `-h` doesn't seem to be available for the [`chmod`](https://ss64.com/bash/chmod.html) utility on Linux. – RobC May 13 '19 at 14:19
  • @RobC that's interesting ... there must be a way to do it on linux..? – Alexander Mills May 16 '19 at 05:16
  • _"Not possible"_ according to answers [here](https://askubuntu.com/questions/626980/what-is-the-ubuntu-equivalent-of-osx-chmod-h-flag#answer-626987) - It's rare that a BSD version of a utility (i.e. `chmod`) provides an extension that isn't available for Linux version. Contrastingly [`chown`](https://ss64.com/bash/chown.html) (Linux) does provide the `-h` option. – RobC May 16 '19 at 10:18
  • 1
    As per chmod(1) man page, `chmod [OPTIONS] MODE.[MODE]... FILE...` hence please your command should have been `chmod -R 555 ./d*`. About your another query, if user has correct rights, she will be able to modify the content whether it is accessed from "git" folder or ".githooks" folder. – Kishan Parekh Jun 07 '19 at 19:24

0 Answers0