Get to see the permissions of a file in octal format

Permissions

http://www.cellbiol.com/bioinformatics_web_development/chapter-2-the-linux-operating-system-setting-up-a-linux-web-server/the-linux-filesystem/

The permits They are quite an interesting topic in the Unix world and one of the most valued peculiarities of this type of operating system. Linux implements this system of modes for the directories and files of the system, and that we can complement with other security layers such as the extended attributes that some file systems implement, or also other types of security systems such as access control lists or ACL.

In some articles we have talked about the modes or permissions, whatever you want to call them, and surely you already know that we can see the permissions that our directories and files with a simple command ls -l, but in the console it will show us the form of letters as we already know. On the other hand, we can also use this same notation or the octal one to modify these permissions using the chmod command, as you already know ... But what happens if we want to list the permissions in octal form?

Well, in order to see octal notation We can use different procedures, although one of the simplest is through the stat command:

stat /etc/passwd

With the previous command we will see a lot of information about this specific file, in the example / etc / passwd. But if we just want to see the o mode permissions in octal format, you can use:

stat -c '%a' /etc/passwd

Between the formats and possibilities Available, which you can see with man stat, are also% A to see the format with letters, and many other options to filter the complete output and only show some of the fields that are obtained if we do not specify anything. For example, if we want to be shown both ways of viewing the permissions or Unix modes of a file or directory, we can use this other command:

stat -c '%A %a' /etc/passwd

And so we will get both in the standard output ...


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

Be the first to comment

Leave a Comment

Your email address will not be published.

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.