LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Linux read file permissions (https://www.linuxquestions.org/questions/linux-newbie-8/linux-read-file-permissions-850937/)

ahingert 12-17-2010 04:12 PM

Linux read file permissions
 
Hi,
Is there a Linux command, or a series of commands, which will allow me to get the permissions of a file in "0644" format?


Thanks,
Adrien

ilvista 12-17-2010 04:31 PM

Code:

chmod
look at the man pages
Code:

man chmod

ahingert 12-17-2010 04:34 PM

While your response has a remote relationship to my inquiry it
doesn't really cover my question at all.

The correct command is:
Code:

stat -c 0%a /etc/passwd

TobiSGD 12-17-2010 04:37 PM

Quote:

Originally Posted by ahingert (Post 4195206)
You are useless. Not only you have no clue what you are talking about, but what you have written does not even answer the question. The correct command is:
Code:

stat -c 0%a /etc/passwd

At first, insulting members is not allowed on this forum, and I would consider that bad manner if someone tries to help you.

Second, you asked how to change the permissions on a file, and that is exactly what the command chmod is for.

So you should better learn to ask smart questions, maybe you will get the answers you want.

Reported.

Tinkster 12-17-2010 04:43 PM

Indeed. That could have been worded in a more constructive way;
see my edited version above as a guideline.



Cheers,
Tink

ahingert 12-17-2010 04:43 PM

Quote:

Originally Posted by ahingert (Post 4195182)
Hi,
Is there a Linux command, or a series of commands, which will allow me to get the permissions of a file in "0644" format?

No, I think that this clearly asks to get the file permissions. Please indicate where it asks to change them?

Ciesar 12-18-2010 03:53 AM

The command

Quote:

ls -la <path>/<filename>

Ciesar 12-18-2010 03:53 AM

Unintentional double post

Tinkster 12-18-2010 03:20 PM

Quote:

Originally Posted by Ciesar (Post 4195651)
The command

That *won't* give him the octal permissions; he already
found a solution, using 'stat'.

Tinkster 12-18-2010 03:30 PM

Quote:

Originally Posted by ahingert (Post 4195206)
While your response has a remote relationship to my inquiry it
doesn't really cover my question at all.

The correct command is:
Code:

stat -c 0%a /etc/passwd

By the way .... your
Code:

stat -c 0%a /etc/passwd
doesn't yield QUITE what I believe to be your desired output. It will
prepend ANY permission string w/ a 0, so if the file in question, e.g.
were a setgid directory, your version would print:
Code:

stat -c0%a FILENAME
02777


I think what you really want is:
Code:

stat -c %a FILENAME  | xargs printf "%04d\n"
2777



Cheers,
Tink


P.S.: Note how I didn't call you useless? ;}


All times are GMT -5. The time now is 07:15 AM.