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

lsattr

List the file attributes (like i = immutable, a = append only).

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

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

ماذا يفعل

lsattr shows the extra attributes that chattr sets. Each letter in the first column is one attribute; - means not set. ls -l does not show them, so check lsattr when even root gets "Operation not permitted".

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

lsattr [-RVadlpv] [FILE]...

الخيارات 7

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

-R
List directories and their content recursively.
-a
Also list hidden files (names with a dot).
-d
List directories like files, not their content.
-l
Use long names for the attributes.
-p
Show the project number.
-v
Show the version/generation number.
-V
Show the version of the program.

أمثلة 10

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

  1. 1Attributes of one file

    lsattr /etc/resolv.conf
    ---------------------- /etc/resolv.conf

    No attributes set.

  2. 2Long names

    lsattr -l /var/log/app/audit.log
    /var/log/app/audit.log       Append_Only

    Easier to read.

  3. 3A directory itself

    lsattr -d /srv/archive

    Without -d you see the files inside.

  4. 4All files, also hidden ones

    lsattr -a ~

    Includes .bashrc and others.

  5. 5Search a tree for immutable files

    lsattr -R /etc 2>/dev/null | grep -- '-i-'

    Explains failing updates or config tools.

  6. 6Check SSH files for attacker tricks (security)

    lsattr /root/.ssh/authorized_keys /home/*/.ssh/authorized_keys

    i on authorized_keys can hide a backdoor key.

  7. 7Check before a package update

    lsattr /usr/bin/* 2>/dev/null | grep -v -- '^-*e*-* '

    Any attribute other than e (extents) is unusual in /usr/bin.

  8. 8Show the project number

    lsattr -p /srv/projects

    Used with project quotas on ext4/XFS.

  9. 9Compare with ls

    ls -l /etc/resolv.conf; lsattr /etc/resolv.conf

    ls shows the mode; lsattr shows the attributes.

  10. 10Errors on special files

    lsattr /dev/null
    lsattr: Operation not supported While reading flags on /dev/null

    Only normal files and folders have attributes.

رموز الخروج

0Done.
1Error.

الدليل الكامل

هذه الصفحة تشرح الأمر بكلمات بسيطة. الدليل الأصلي فيه كل التفاصيل.

في الطرفية: man lsattr