LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-17-2010, 05:12 PM   #1
ahingert
LQ Newbie
 
Registered: Aug 2010
Posts: 22

Rep: Reputation: 0
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
 
Old 12-17-2010, 05:31 PM   #2
ilvista
Member
 
Registered: Nov 2010
Location: Ghazaouet
Distribution: Fedora OpenSuse
Posts: 150

Rep: Reputation: 21
Code:
chmod
look at the man pages
Code:
man chmod
 
1 members found this post helpful.
Old 12-17-2010, 05:34 PM   #3
ahingert
LQ Newbie
 
Registered: Aug 2010
Posts: 22

Original Poster
Rep: Reputation: 0
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

Last edited by Tinkster; 12-17-2010 at 05:41 PM. Reason: [mod_edit]in italics[/mod_edit]
 
Old 12-17-2010, 05:37 PM   #4
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,130
Blog Entries: 2

Rep: Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825Reputation: 4825
Quote:
Originally Posted by ahingert View Post
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.
 
Old 12-17-2010, 05:43 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

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



Cheers,
Tink
 
Old 12-17-2010, 05:43 PM   #6
ahingert
LQ Newbie
 
Registered: Aug 2010
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ahingert View Post
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?
 
Old 12-18-2010, 04:53 AM   #7
Ciesar
LQ Newbie
 
Registered: Jul 2009
Location: Brisbane, OZ
Distribution: Slackware, Fedora and Debian
Posts: 9

Rep: Reputation: 0
The command

Quote:
ls -la <path>/<filename>
 
Old 12-18-2010, 04:53 AM   #8
Ciesar
LQ Newbie
 
Registered: Jul 2009
Location: Brisbane, OZ
Distribution: Slackware, Fedora and Debian
Posts: 9

Rep: Reputation: 0
Unintentional double post

Last edited by Ciesar; 12-18-2010 at 04:54 AM.
 
Old 12-18-2010, 04:20 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by Ciesar View Post
The command
That *won't* give him the octal permissions; he already
found a solution, using 'stat'.
 
Old 12-18-2010, 04:30 PM   #10
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Quote:
Originally Posted by ahingert View Post
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? ;}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
File-permissions on Read-only media: Allowing for access without chmod mattseanbachman Linux - General 2 03-14-2010 07:00 PM
how to hide a file using file permissions in linux without using dot davender84 Linux - General 4 03-26-2009 01:13 AM
Windows file permissions with a Linux file server joseph_k Linux - Server 3 05-09-2008 01:54 PM
File Permissions - Execute Not Read baddah Linux - Newbie 3 05-23-2007 04:08 PM
Permissions cannot touch `testFile': Read-only file system windsurfer Linux - Software 2 04-17-2007 08:13 AM


All times are GMT -5. The time now is 08:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration