i am a Unix beginner and to test the rules of file rights (rwx)
i created the file
/root/testdir/subdir/test.sh
and set the rights of testdir,subdir, test.sh (using chmod) to various configurations in order to get an idea
in which case you need which rights. Test commands were
ls ('Can i read the directory in certain change-mod configurations?')
less test.sh ('What are the requirements in terms of rights to be able to read a file?')
test.sh ('When can i execute a file?')
My question is, when testing unix access rights, is there a difference
between referencing test.sh by
./tests. and /root/testdir/subdir/test.sh?
I know that for the first command, i need to be in the directory, but in terms of
access rights, are these to ways of referencing the file test.sh totally equivalent? In other words, does
'less ./test.sh' always work when 'less /root/testdir/subdir/test.sh' and vice versa?
Or is there a configuration for the rights of testdir and/or subdir where one works, and the other not? Same question with executing.
Wow, thanks for the fast reply.
Can you give one short example for the differences when running the program?
(Execpt for that Unix remembers the current directory from where the programm was called, i can't think of any differences, but as i mentioned, i am a beginner)
Thanks!
Yes, that's the point. Here is a short example of how test.sh behaves differently based on where you are when you enter the command:
$ cd /tmp
$ cat test.sh
wc file.txt
$ ls
file.txt test.sh
$ cd /tmp
$ ./test.sh
19 19 95 file.txt
$ cd /
$ /tmp/test.sh
wc: file.txt: No such file or directory
Another difference is that if you are in a directory where you do not have write permission (such as root directory), and the script wants to create some files in that directory, it obviously will fail.
Well, my reply to your last post was not accepted and has to be approved by the moderators
first. All i did is thank you for helping me out, so thanks again!
I failed to mention, from the command line, if one of those "less" commands works, the other will also work. Of course, if the first command with the relative path is in a shell script, there could well be a problem, just like in the example of "test.sh" script.