Differences between revisions 14 and 17 (spanning 3 versions)
Revision 14 as of 2007-11-30 23:35:30
Size: 3610
Editor: s20
Comment: Hi!, <a href="http://www.weilmclainboiler.cn/controls/map.html">controls </a>[url="http://www.weilmclainboiler.cn/controls/map.html"]controls [/url]http://www.weilmclainboiler.cn/controls/map.html con
Revision 17 as of 2007-12-12 01:15:02
Size: 2036
Editor: 238
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Hi!, <a href="http://www.weilmclainboiler.cn/controls/map.html">controls
</a>[url="http://www.weilmclainboiler.cn/controls/map.html"]controls
[/url]http://www.weilmclainboiler.cn/controls/map.html controls
 bpjwf, <a href="http://www.gateironwrought.cn/fittings/map.html">fittings
</a>[url="http://www.gateironwrought.cn/fittings/map.html"]fittings
[/url]http://www.gateironwrought.cn/fittings/map.html fittings
 jduxi, <a href="http://www.gategoldenpark.cn/gardening/map.html">gardening
</a>[url="http://www.gategoldenpark.cn/gardening/map.html"]gardening
[/url]http://www.gategoldenpark.cn/gardening/map.html gardening
 9638, <a href="http://www.aircargotracking.cn/cargo/map.html">cargo
</a>[url="http://www.aircargotracking.cn/cargo/map.html"]cargo
[/url]http://www.aircargotracking.cn/cargo/map.html cargo
 348, <a href="http://www.cranelake.cn/fans/map.html">fans
</a>[url="http://www.cranelake.cn/fans/map.html"]fans
[/url]http://www.cranelake.cn/fans/map.html fans
 2960, <a href="http://www.unitedairlinecargo.cn/cellphone/map.html">cellphone
</a>[url="http://www.unitedairlinecargo.cn/cellphone/map.html"]cellphone
[/url]http://www.unitedairlinecargo.cn/cellphone/map.html cellphone
 025, <a href="http://www.unitedairlinecargo.cn/cellphone/map.html">cellphone
</a>[url="http://www.unitedairlinecargo.cn/cellphone/map.html"]cellphone
[/url]http://www.unitedairlinecargo.cn/cellphone/map.html cellphone
 %PP, <a href="http://www.cargovanrental.cn/boiler/map.html">boiler
</a>[url="http://www.cargovanrental.cn/boiler/map.html"]boiler
[/url]http://www.cargovanrental.cn/boiler/map.html boiler
 017016, <a href="http://www.unitedairlinecargo.cn/cellphone/map.html">cellphone
</a>[url="http://www.unitedairlinecargo.cn/cellphone/map.html"]cellphone
[/url]http://www.unitedairlinecargo.cn/cellphone/map.html cellphone
 8PP, <a href="http://www.cargovanrental.cn/boiler/map.html">boiler
</a>[url="http://www.cargovanrental.cn/boiler/map.html"]boiler
[/url]http://www.cargovanrental.cn/boiler/map.html boiler
 907527, <a href="http://www.grannyblowjob.cn/map.html">mature
</a>[url="http://www.grannyblowjob.cn/map.html"]mature
[/url]http://www.grannyblowjob.cn/map.html mature
 klhgzx, <a href="http://www.analtoy.cn/anal/map.html">anal
</a>[url="http://www.analtoy.cn/anal/map.html"]anal
[/url]http://www.analtoy.cn/anal/map.html anal
 =-), <a href="http://www.analfisting.cn/anal/map.html">anal
</a>[url="http://www.analfisting.cn/anal/map.html"]anal
[/url]http://www.analfisting.cn/anal/map.html anal
 60167, <a href="http://www.gayteenboy.cn/map.html">gays
</a>[url="http://www.gayteenboy.cn/map.html"]gays
[/url]http://www.gayteenboy.cn/map.html gays
 snlks, <a href="http://www.bustygranny.cn/map.html">mature</a>[url="http://www.bustygranny.cn/map.html"]mature[/url]http://www.bustygranny.cn/map.html mature jktv, <a href="http://www.grannysluts.cn/map.html">mature
</a>[url="http://www.grannysluts.cn/map.html"]mature
[/url]http://www.grannysluts.cn/map.html mature
 8[, <a href="http://www.asiananal.cn/anal/map.html">anal
</a>[url="http://www.asiananal.cn/anal/map.html"]anal
[/url]http://www.asiananal.cn/anal/map.html anal
 8]], <a href="http://www.asiananal.cn/anal/map.html">anal
</a>[url="http://www.asiananal.cn/anal/map.html"]anal
[/url]http://www.asiananal.cn/anal/map.html anal
 147294, <a href="http://www.analfisting.cn/anal/map.html">anal
</a>[url="http://www.analfisting.cn/anal/map.html"]anal
[/url]http://www.analfisting.cn/anal/map.html anal
 408733,
----
CategoryCategory
[[Anchor(faq87)]]
== How can I get the permissions of a file without parsing ls -l output? ==

There are several potential ways, most of which are system-specific. They also depend on precisely ''why'' you want the permissions.

The majority of the cases where you might ask this question -- such as ''I want to find any files with the setuid bit set'' -- can be answered by the information in [:UsingFind#permissions:]. As the page name implies, those answers are based on the `find(1)` command.

For some questions, such as ''I want to make sure this file has 0644 permissions'', you don't actually need to ''check'' what the permissions are. You can just use `chmod 0644 myfile` and set them directly.

If you want to see if you can read, write or execute a file, there is test -r, -x and -w.

If your needs aren't met by any of those, then we can look at a few alternatives:

 * On GNU/Linux systems, *BSD and possibly others, there is a command called `stat(1)`. On older GNU/Linux systems, this command take no options -- just a filename -- and you will have to parse its output.
 {{{$ stat /
   File: "/"
   Size: 1024 Filetype: Directory
   Mode: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
 Device: 8,0 Inode: 2 Links: 25
 Access: Wed Oct 17 14:58:02 2007(00000.00:00:01)
 Modify: Wed Feb 28 15:42:14 2007(00230.22:15:49)
 Change: Wed Feb 28 15:42:14 2007(00230.22:15:49)}}}
 In this case, one could extract the 0755 from the `Mode:` line, using `awk` or similar commands.

 * On newer GNU/Linux and FreeBSD systems, the `stat` command takes arguments which allow you to specify which information you want:
 {{{$ stat -c %a /
 755}}}
 That's obviously a lot easier to parse. NetBSD and OpenBSD similarily uses -f

 * On systems with perl 5, you can use:
 {{{
 perl -e 'printf "%o\n", 07777 & (stat $ARGV[0])[2]' "$filename"}}}
 This returns the same octal string that the `stat -c %a` example does, but is far more portable. (And slower.)

Anchor(faq87)

How can I get the permissions of a file without parsing ls -l output?

There are several potential ways, most of which are system-specific. They also depend on precisely why you want the permissions.

The majority of the cases where you might ask this question -- such as I want to find any files with the setuid bit set -- can be answered by the information in [:UsingFind#permissions:]. As the page name implies, those answers are based on the find(1) command.

For some questions, such as I want to make sure this file has 0644 permissions, you don't actually need to check what the permissions are. You can just use chmod 0644 myfile and set them directly.

If you want to see if you can read, write or execute a file, there is test -r, -x and -w.

If your needs aren't met by any of those, then we can look at a few alternatives:

  • On GNU/Linux systems, *BSD and possibly others, there is a command called stat(1). On older GNU/Linux systems, this command take no options -- just a filename -- and you will have to parse its output. {{{$ stat /

    • File: "/" Size: 1024 Filetype: Directory Mode: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
    Device: 8,0 Inode: 2 Links: 25 Access: Wed Oct 17 14:58:02 2007(00000.00:00:01) Modify: Wed Feb 28 15:42:14 2007(00230.22:15:49) Change: Wed Feb 28 15:42:14 2007(00230.22:15:49)}}}

    In this case, one could extract the 0755 from the Mode: line, using awk or similar commands.

  • On newer GNU/Linux and FreeBSD systems, the stat command takes arguments which allow you to specify which information you want: {{{$ stat -c %a / 755}}} That's obviously a lot easier to parse. NetBSD and OpenBSD similarily uses -f

  • On systems with perl 5, you can use:
     perl -e 'printf "%o\n", 07777 & (stat $ARGV[0])[2]' "$filename"

    This returns the same octal string that the stat -c %a example does, but is far more portable. (And slower.)

BashFAQ/087 (last edited 2015-09-28 19:14:40 by GreyCat)