Editing and displaying advanced file attributes

Command Line – Advanced File Attributes

© Photo by Viktor Talashuk on Unsplash

© Photo by Viktor Talashuk on Unsplash

Article from Issue 276/2023
Author(s):

The chattr and lsattr commands offer users a convenient way to modify and display advanced file attributes.

Most users are familiar with the usual file attributes. Desktop file managers often list them as properties: the name, path, size, and the dates that the file was created, last accessed, and last modified (Figure 1). Many, too, are familiar with the separate read, write, and execution permissions for a file's owner, group, and other users. However, over the decades, new filesystems, as well as the needs of version control for developers, have developed additional optional attributes. These additional attributes are edited by chattr [1], the equivalent for chown and chmod for permissions, and can be viewed by lsattr [2]. Both commands are included in the e2fsprogs [3] package and are installed by default in most distributions. While the creation of chattr and lsattr was driven by the needs of developers, many of these additional attributes are practical for everyday use as well.

chattr and lsattr Options

The commands for working with file attributes have limited options. All options use a single letter rather than the full word like GNU style. In chattr, the -f option will suppress all except critical error messages. However, users are more likely to want -R (recursive) to change the attributes of an entire directory or -V (verbose) to receive instant feedback. Developers may want to use -v VERSION together with version control, or -p PROJECT to associate files with a particular project. For commands, chattr uses a standard structure:

chattr [OPTIONSP [-v VERSION] [-p PROJECT] [OPERATOR][ATTRIBUTES ][FILES]

[...]

Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Core Technologies

    Everyone wants to be root, because root can do anything. But in fact, its powers are now split. Learn more in this overview of capability sets.

  • Bash Tricks

    The Bash shell is powerful and infinitely expressive. In this article we describe some tricky techniques you can use to enhance and customize your Bash environment.

  • libferris

    With libferris, FUSE, and rsync, you can synchronize a filesystem with a dissimilar data source.

  • Offline FS

    Tired of copying and recopying files from your laptop to the office file server? Maybe you need an automated offline filesystem, such as OFS.

  • Ask Klaus!

    Understanding and taming file timestamps.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News