0

Let's say there is a script in my home folder I would like to use in /etc/cron.* folder or in other system folders. Is there any way how to do it without copying the file to the target location?

Would symlink or hardlink do the job? I tried that out and it seems it's not working. Why not? Permission of symlink and the script seems to be OK.

Thank you for you explanation.

4
  • "Permission of ... the script seems to be OK." How did you know? What were the permissions? What are the permissions of every folder in the path to the script?
    – muru
    Sep 29, 2015 at 19:37
  • Good point. Well, both files had 777 for testing purposes, cron folders + etc have drwxr-xr-x.
    – Sebastian
    Sep 29, 2015 at 19:44
  • The permissions for the cron folders were set by the system, so I'm not asking for those. I'm asking about the folders which contain the script. So, if it's /path/to/some/script, what are the permissions of /path, /path/to, /path/to/some and /path/to/some/script?
    – muru
    Sep 29, 2015 at 19:46
  • Muru, all got drwxrwxr-x. So if any parent folder would have more restricted permissions, script might not work even that script would have full permissions?
    – Sebastian
    Sep 29, 2015 at 19:51

1 Answer 1

1

Every file has 1 hard link. If it doesn't have one, the space it occupies can be overridden. If you make another hard link, the count goes up to 2 without using double the space on the HDD because both hard links point to the same piece of storage space.

That said, there is no original. If you make additional hard links of a file, every one of them is as good as any other one. So make hard links of the files and copy one of each to your destination.

5
  • The trouble is, my home folder is on another drive than system folders. That makes it impossible to do so, right?
    – Sebastian
    Sep 29, 2015 at 19:34
  • Yes, it does. Hard links can only point to files on the same file system (different partitions have different file systems). Even more unfortunate for you, rights are shared between files and their symlinks, so you can't use those either.
    – UTF-8
    Sep 29, 2015 at 19:46
  • Wait, do you need read or write permission? Because if you only need read permission, leave the system file alone and make a symlink to it in your home folder.
    – UTF-8
    Sep 29, 2015 at 19:48
  • Well, I've got an idea and maybe it's a silly one, that I would have all my scripts in my home folder and link to cron a system folders from there so later on I could edit scripts and config files in home folder and I won't need to replace them elsewhere. So even if my xubuntu crashes one day, I could reinstall system and relink files again.
    – Sebastian
    Sep 29, 2015 at 19:56
  • If it's stupid and it works, it's not stupid. ;-) You can't usually run sudo on crontabs afaik but there is this neat little thing. Someone proposed it to myself on AskUbuntu, too. Unfortunately, it didn't work (I'm using Ubuntu 15.04), but it worked for others, so maybe give it a try.
    – UTF-8
    Sep 29, 2015 at 20:01

Not the answer you're looking for? Browse other questions tagged .