Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

lsattr

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

Niveau
Dagelijks Linux
Groep
Rechten
Root nodig
Voor wijzigingen
Pakket
e2fsprogs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

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".

Zo schrijf je het

lsattr [-RVadlpv] [FILE]...

Opties 7

Meest gebruikt

-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.

Voorbeelden 10

$ als gewone gebruiker# als root (of met 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.

Exitcodes

0Done.
1Error.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man lsattr