Hot answers tagged

13

The a attribute means that the file is append-only: you can't overwrite it or delete it, only append data to it. This is explained in the chattr man page. Only root can remove the attribute. The practical consequence is that you can't erase your old history lines. This is presumably intended as a security measure by your system administrator. I'm not ...


11

TL;DR Don't do this unless you have peculiar auditing requirements. It's generally more trouble than it's worth. Explanation The only account that should have write access to /boot is root. If you have root, you can unset immutable bits and pretty much do what you want anyway. The major downside of mounting /boot read-only, setting immutable bits, or ...


10

After quite a bit of trial and error on the commandline, I think I've found the answer. But it isn't a cp-related answer. rsync -ptgo -A -X -d --no-recursive --exclude=* first-dir/ second-dir This does: -p, --perms preserve permissions -t, --times preserve modification times -o, --owner preserve owner (...


9

xattr -d requires you to specify which attribute you want to remove. You can find this out by listing the file attributes by passing ls the -@ flag as in: ls -l@ filename Once you know what the attribute is, you can target it for removal with -d or you can use the following to clear all attributes: xattr -c filename


9

The answer to you question is filesystem specific. For ext3, for example, have a look at fs/ext3/xattr.c, it contains the following description: 16 /* 17 * Extended attributes are stored directly in inodes (on file systems with 18 * inodes bigger than 128 bytes) and on additional disk blocks. The i_file_acl 19 * field contains the block number ...


8

The attributes as handled by lsattr/chattr on Linux and some of which can be stored by quite a few file systems (ext2/3/4, reiserfs, JFS, OCFS2, btrfs, XFS, nilfs2, hfsplus...) and even queried over CIFS/SMB (when with POSIX extensions) are flags. Just bits than can be turned on or off to disable or enable an attribute (like immutable or archive...). How ...


7

Update After messing around with this some more and looking at the code for chattr and other e2fsprogs, it is clear that the attributes set by chattr and those set by libattr (eg with the command setfattr) are very different. chattr sets ext filesystem flags which simply do not map to an named attribute or namespace. None of them show up with any call to ...


6

Found the solution here: ls - get information of the directory specified only, not info about the sub-files/folder Which basically is ls -ldO foo and then you just append | awk '{ print $5 }' to make it display the information


6

According to the ls man page, you should be able -O option combined with the -l option to view flags with ls. For example: ls -Ol foo.txt -rw-r--r-- 1 harry staff - 0 18 Aug 19:11 foo.txt chflags hidden foo.txt ls -Ol foo.txt -rw-r--r-- 1 harry staff hidden 0 18 Aug 19:11 foo.txt chflags nohidden foo.txt ls -Ol foo.txt -rw-r--r-- 1 harry staff - 0 18 Aug 19:...


6

NFS doesn't have a concept of immutable files, which is why you get the error. I'd suggest that you just remove write access from everyone instead, which is probably close enough for your purposes. $ > foo $ chmod a-w foo $ echo bar > foo bash: foo: Permission denied The main differences between removing the write bit for all users instead of using ...


5

Ext2 and family (including ext4) reserve an attribute for compression but don't implement it. This feature was originally put off because there were more urgent things to do, and then it became obsolescent as the size of storage media increased a lot faster than the size of data that isn't already compressed. Most large files today (videos, music, even word ...


5

From the man page of chattr The ’e’ attribute indicates that the file is using extents for mapping the blocks on disk. It may not be removed using chattr. An extent is a contiguous area of storage in a computer file system, reserved for a file. When a process creates a file, file-system management software allocates a whole extent. When writing to the file ...


5

To remove a directory, you need write permission over its parent. Which means that as long as user can't write to /home, he won't be able to remove his own directory. $ chown root:root /home $ chmod 0755 /home $ chown user:user /home/user $ chmod 0750 /home/user With these permissions, root is the only user who can manipulate directories immediately ...


4

Makes sense to have a look at the man page of the programs you use: BUGS AND LIMITATIONS The c', 's', andu' attributes are not honored by the ext2 and ext3 filesystems as implemented in the current mainline Linux kernels. This is not supposed to mean "ext4 works" I guess.


4

The letters `acdeijstuADST' select the new attributes for the files: append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merg‐ ing (t), undeletable (u), no atime updates (A), synchronous directory updates (D), synchronous updates (S), and top of directory ...


4

lsattr -v invokes the EXT2_IOC_GETVERSION ioctl for the file. This, in turn, retrieves the inode's i_generation field. This is a feature primarily intended for use with NFS: each time an inode gets allocated, one has to make sure it gets a new generation. Otherwise, NFS clients with stale file handles may manage to access data that weren't meant for them. ...


4

I got a bit curious reading this questoion, so let’s do some “forensics”: First trying the opposite: How is åäöåä encoded in Base64? $ echo åäöåä | base64 w6XDpMO2w6XDpAo= This clearly looks a lot like the 0sw6XDpMO2w6XDpA== that you’ve got. There’s an extra 0s at the beginning, and the end doesn’t exactly match. Suppressing the newline at the end of ...


4

When you run > /tmp/foo.txt, you are overwriting the contents of /tmp/foo.txt with the output of sed 's/old text/new text/' file1.txt. Since /tmp/foo.txt doesn't exist when you run this command, bash will create that file for you and then write it. Then, when you use the -p flag to cp, you are copying the permissions and attributes of /tmp/foo.txt to ...


3

The specific attribute in this issue is i, the immutable attribute. The file was marked immutable. This means it is unchangeable at all by any user including root. Root can still change the attributes and remove the immutable attribute, but must to so first before making changes to the file, unlike standard no-write permissions to a file which root can ...


3

I found this comment in fs/xattr.c: /* In user.* namespace, only regular files and directories can have * extended attributes. For sticky directories, only the owner and * privileged user can write attributes. */ I'm not sure why that is, but there you have it; the kernel won't allow user.* eas on anything but a regular file or ...


3

The append only flag (chattr +a) prevent from removing the directory, a well as files and directories created directly inside that directory: Create test directory and files: # mkdir /tmp/foo # chattr +a /tmp/foo That directory can't be deleted: # rmdir /tmp/foo rmdir: failed to remove ‘/tmp/foo’: Operation not permitted Now create files and ...


3

My El Capitan has no setattr or setxattr (the latter is the name of a C runtime function: you could make your own utility using that). OSX provides xattr, which (noting comments such as Mac OS X Extended Attributes and Xattr) seems fairly recent. A comment in Manually set extended attributes on arbitrary files from 2011 gives a hint about OSX 10.5 You can ...


3

Yes it is expected behaviour. I don't have a document that says it but you can see in this patch from 2007 When a file with posix capabilities is overwritten, the file capabilities, like a setuid bit, should be removed. This patch introduces security_inode_killpriv(). This is currently only defined for capability, and is called when ...


3

ACLs allow more than one person and more than one group to be granted permissions. For example, you might have an SA team and a DBA team. You want to grant SAs "read+write" access to a file, but the DBAs only read access. Since a file can only have one group owner this is hard to do. But with ACLs it is easy. ACL implementations are filesystem specific. ...


2

There is no such flag with Linux chattr. You can either make the file immutable or append-only (in either case, the file's permissions and ownership will be locked), or allow the owner of the file and root to change the permissions. (The immutable attribute on a directory prevents creating or removing files from it but not changing entries' metadata.) If ...


2

The man page for chattr contains all the info you need to understand the lsattr output. excerpt The letters `acdeijstuACDST' select the new attributes for the files: append only (a), compressed (c), no dump (d), extent format (e), immutable (i), data journalling (j), secure deletion (s), no tail-merging (t), undeletable (u), no ...


2

A tilde suffix marks a backup file for a few text editors, such as Emacs ('~') and Vim ('.ext~'). Some programs hide these files, as most people don't care about them. The only universal convention for a 'hidden' file is a file with a leading '.', due to a feature-like bug which was widely adopted.


2

Nautilus uses ~/.thumbnails normally. Lots of image viewers do generate thumbs there as well. In the normal sub-dir of my system most of the preview files are about 20 KiB in size. It's kinda disturbing that there're no either sqlite database in single file or cache hierarchy (like f/ff/ffdcd558a…1e5200.png) so some FSes could have poor performance looking ...


2

find itself doesn't support extended atttribute but you can use such as: find ~/ -type f -iname "*" -exec lsattr {} + | grep -v '\-\-\-\-\-\-\-\-\-\-\-\-\-'


2

I changed the extended attributes to get rid of the i and then I was alright: >sudo chattr -i /etc/hosts But would still like an explanation how to read lsattrs output, including the attribute that I changed.



Only top voted, non community-wiki answers of a minimum length are eligible