الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

chgrp

Change the group of files and directories.

المستوى
امتحان RHCSA
المجموعة
الصلاحيات
يحتاج root
للتغييرات
الحزمة
coreutils

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

chgrp GROUP FILE sets the group. root can set any group. A normal user can change the group of an own file, but only to a group he is a member of.

It is the same as chown :GROUP FILE.

طريقة الكتابة

chgrp [OPTION]... GROUP FILE...
chgrp [OPTION]... --reference=RFILE FILE...

الخيارات 14

الأكثر استخدامًا

-R, --recursive
Change the whole tree.
-v, --verbose
Report every file.
-c, --changes
Report only changes.
-f, --silent, --quiet
Do not show most errors.
-h, --no-dereference
Change a link itself.
--dereference
Change the target of a link (default).
--reference=RFILE
Use the group of RFILE.
--preserve-root
Refuse to work recursively on /.
--no-preserve-root
Do not treat / special (default).
-H
With -R: follow a link given on the command line.
-L
With -R: follow every link to a directory.
-P
With -R: follow no links (default).
--help
Show help.
--version
Show the version.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 1Give a folder to a team

    chgrp sales /srv/sales

    Combine with chmod 2770 for a shared folder.

  2. 2Change a whole tree

    chgrp -R sales /srv/sales

    All files and folders inside.

  3. 3As a normal user, for your own file

    chgrp sales plan.txt

    Works only if you are in sales.

  4. 4Error when you are not a member

    chgrp wheel plan.txt
    chgrp: changing group of 'plan.txt': Operation not permitted

    Join the group first.

  5. 5Show what changed

    chgrp -Rc sales /srv/sales

    Lists only files that got a new group.

  6. 6Use the group of another file

    chgrp --reference=/srv/sales /srv/sales/import.csv

    Same group as the folder.

  7. 7Fix files after a group GID change

    find /srv -gid 3000 -exec chgrp -h sales {} +

    Files with the old number get the group name again.

  8. 8Group of the web logs for a log team

    chgrp -R logreaders /var/log/httpd; chmod -R g+rX /var/log/httpd

    Read access without root (check that the logs rotate with the same group).

  9. 9Group for a config read by a service

    chgrp nginx /etc/pki/tls/private/site.key; chmod 640 /etc/pki/tls/private/site.key

    The service reads the key; others cannot.

  10. 10Find files of a group (audit)

    find /srv -group sales -ls

    Shows everything the group owns.

رموز الخروج

0Done.
1Error.