Checking permission of a file that is having same name as directory.

rajatkm93

New Member
Joined
Jun 19, 2022
Messages
10
Reaction score
0
Credits
79
I created a new file using touch command with title as 'Desktop' (same name as Desktop directory). I am aware that I can use -d option with ls for checking file permission for 'Desktop' directory. However, I am wondering how can I check file permissions of 'Desktop' file specifically (please don't tell to use ls -l as there are multiple files.)

Also, when I am trying ls -l Desktop it is giving me output as: total 0 (see below screenshot)

Thank you in advance!



1676141401338.png
 


The problem is that touch will only create a file that does not exist, so if it exists, touch won't create it, and since "Desktop" exists, it won't create another of the same name. Bear in mind that a directory is just a file that contains other files. If you try and create the file Desktop with a text editor, such as vim or nano, it will happily create the file Desktop within the directory Desktop.
 
You're checking the permissions of a folder.

I tried to create a "Desktop" file in my home directory - with the touch command. (You can't make a file that shares the name as an existing directory within that directory, I'm pretty sure.)

So... It didn't actually make that file.

Importantly for this: It didn't give me an error of any kind. It just remains silent on the matter.

I then ran the ls -l Desktop command and got the results you got. That's to be expected.

If you make a file called 'foo' then it works as expected.

Hmm... It says someone responded while typing this. I'm gonna hit the post button anyhow.
 
Touch is also case-sensitive, so you can create a file

desktop

but why would you?

Is this just an exercise, or do you have a purpose?

Cheers

Wizard
 

Members online


Top