other::---

8.3.1.2. Copying and moving files with their ACLs

To copy an ACL when copying a file, use the -p argument to cp :

$ getfacl demo

# file: demo

# owner: chris

# group: chris

user::rw-

group::rw- #effective:r--

mask::r--

other::---

$ cp -p demo demo2

$ getfacl demo2

# file: demo2

# owner: chris

# group: chris

user::rw-

group::rw- #effective:r--

mask::r--

other::---

When moving a file (with mv ), the ACL is automatically preserved:

$ mv demo2 demo3

$ getfacl demo3

# file: demo3

# owner: chris

# group: chris

user::rw-

group::rw- #effective:r--

mask::r--

other::---

8.3.1.3. Copying an ACL from one file to another

It can be a lot of work setting up a complex ACL with many entries. To simplify the reuse of ACLs, setfacl provides the --set-file option, which sets an ACL from a text file. This file can be created by redirecting the output of getfacl , providing an easy way to copy an ACL from one file to another. This example writes the ACL from the file demo to the file /tmp/acl , and then applies that ACL to the file bar :

$ getfacl demo >/tmp/acl

$ setfacl --set-file /tmp/acl bar

$ getfacl bar

# file: bar

# owner: chris

# group: chris

user::rw-

user:thomas:r--

user:diane:r--

user:gord:rw-

user:jim:rw-

group::rw-

mask::rw-

other::---

Since --set-file accepts the filename - for standard input, you can also pipe the output of getfacl into setfacl to copy an ACL without using an intermediate file:

$ getfacl demo | setfacl --set-file - bar

8.3.1.4. Improving the appearance of ACL listings

getfacl provides a --tabular option, which presents the output in a format that is somewhat easier to read than the default output:

$ getfacl bar

# file: bar

# owner: chris

# group: chris

user::rw-

user:thomas:r--

user:diane:r--

user:gord:rw- #effective:r--

user:jim:rw- #effective:r--

group::rw- #effective:r--

mask::r--

other::---

$ getfacl --tabular bar

# file: bar

USER chris rw-

user thomas r--

user diane r--

user gord rW-

user jim rW-

GROUP chris rW-

Вы читаете Fedora Linux
Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату