Question about UNIX file rights

Thread Tools Search this Thread
# 1  
Question about UNIX file rights

Hello experts,

i am a Unix beginner and to test the rules of file rights (rwx)
i created the file


and set the rights of testdir,subdir, (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 ('What are the requirements in terms of rights to be able to read a file?')
- ('When can i execute a file?')

My question is, when testing unix access rights, is there a difference
between referencing by

./tests. and /root/testdir/subdir/

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 totally equivalent? In other words, does
'less ./' always work when 'less /root/testdir/subdir/' 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.

Thands in advance for your help!
# 2  
are these to ways of referencing the file totally equivalent?
For testing file rights, the two ways are totally equivalent.
For running the program, they are not equivalent.
# 3  
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)
# 4  
Execpt for that Unix remembers the current directory
from where the programm was called
Yes, that's the point. Smilie Here is a short example of how behaves differently based on where you are when you enter the command:
$ cd /tmp
$ cat
wc file.txt
$ ls

$ cd /tmp
$ ./
19 19 95 file.txt

$ cd /
$ /tmp/
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.

Here are two ways to fix the problem:
$ cat
cd /tmp
wc file.txt

$ cat
wc /tmp/file.txt

# 5  
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!
# 6  
'less ./' always work when
'less /root/testdir/subdir/' and vice versa?
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 "" script.

You're welcome. Smilie

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert UNIX rights in a number in a sh script

Hello, i'm trying to write a script sh to convert the rights of a folder or file in a number. Explain: ls -l = rwxrwxrwx so i must display 777. Do you known where i can find so convert script Thanks Use code tags, thanks. (11 Replies)
Discussion started by: steiner
11 Replies

2. UNIX for Dummies Questions & Answers

UNIX File reading question

Is there a script that will automatically access/count the words in each individual file for a program? (Sorry, I'm trying to help my girlfriend who's in computer science out, I know nothing about this. We're having trouble wording this question.) (1 Reply)
Discussion started by: Triple M
1 Replies

3. Shell Programming and Scripting

Management application user rights on the files in a Unix / Linux

good evening .. I have a plea, who I can help me with a management application user rights on the files in a Unix / Linux I need for college .. .. and not told us no clue .. thank you (1 Reply)
Discussion started by: alex90
1 Replies

4. Solaris

New user question regarding admin rights

I'm trying to install OpenOffice on Solaris 11 but when I click on the setup icon I get an error message telling me that I need to have admin rights. I've tried logging on as SU or ROOT but cannot. I don't see how to grant myself admin rights. How is it done ? I know there are many many... (7 Replies)
Discussion started by: stansaraczewski
7 Replies

5. UNIX for Dummies Questions & Answers

file access rights?

Hi, I want to execute a customised process like rating engine using a shell script from a directory other than the directory where the customizes process is placed. I have tried it in the following way...and faced a issue when shell script is available in directory /dir1/ and customized... (1 Reply)
Discussion started by: vkishore.btw
1 Replies

6. UNIX for Dummies Questions & Answers

Unix access rights

Hi, Is it true that if I am not the root I can not select access permissions to a file that I own so that my friend (who also isn't the root) can access that file? And is it true that the only way to accomplish it is to ask the root to "put" my friend into "my" group? Then I could simply set... (1 Reply)
Discussion started by: rudo
1 Replies

7. SuSE

UNIX - Linux NFS Rights need Help

Hello, I am running a Suse Linux server and I want to set up a NFS Server for a few Unix machines. For the root account at the unix client it works fine but it doesn't work for other users who have no root rights. I've used the no_root_squash and the rw option in the etc/export file. My folder... (7 Replies)
Discussion started by: Ald-Edv
7 Replies

8. UNIX for Dummies Questions & Answers

File Oput question in Unix?

Just curious in Unix BSD lpr customer would result in the printing of the file customers to a printer but I also came across this command pr| customer| lpr which suppose to prepare the file by formatting before printing. My question is what type of formatting is done to the file for example what... (1 Reply)
Discussion started by: wmosley2
1 Replies

Featured Tech Videos