LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2016, 06:54 AM   #1
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: DC
Distribution: RHEL/CentOS
Posts: 1,345
Blog Entries: 4

Rep: Reputation: 160Reputation: 160
Is anyone using chattr/lsattr on files/directories?


I've tried to use chattr/lsattr on various files/directories under RHEL, however it seems to cause havoc when trying to either move files into directories or delete files in directories where the -i flag has been set.

Also finding out that various scripts have issues too...

Was wondering what others are using chattr/lsattr on? I was thinking /etc/passwd and /etc/shadow, but if I have scripts having issues on test files, this would not be a good move.
 
Old 09-07-2016, 07:07 AM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913
Quote:
Originally Posted by JockVSJock View Post
I've tried to use chattr/lsattr on various files/directories under RHEL, however it seems to cause havoc when trying to either move files into directories or delete files in directories where the -i flag has been set.

Also finding out that various scripts have issues too...

Was wondering what others are using chattr/lsattr on? I was thinking /etc/passwd and /etc/shadow, but if I have scripts having issues on test files, this would not be a good move.
Can you be a bit more specific about which flags have been causing you problems, under which circumstances, and what these problems are?
 
Old 09-07-2016, 01:16 PM   #3
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: DC
Distribution: RHEL/CentOS
Posts: 1,345

Original Poster
Blog Entries: 4

Rep: Reputation: 160Reputation: 160
I have a number of directories under /tmp where reports are collected. An example of this are openscap scans, say /tmp/openscap. I like to keep history of scans, however I just found out that RHEL has a cronjob that cleans out files out of /tmp.

I didn't want to disabled the cronjob, because I wanted it to clean out files that I don't need, however I don't want it to cleanup the /tmp/openscap.

So I used chattr to prevent this;

Code:
chattr -R +i /tmp/openscap
However I have scripts that I run, as a non-privileged user, that create reports and place them into /tmp/openscap, and with the +i set on /tmp/openscap, so the script has issues.

To me chattr, is to setup files/directories where nothing can be done with them.

I've seen examples where it is recommended to set this for /etc/passwd and /etc/shadow, however if my simple script, ran as a non-privileged user, is having issues, I would worry about using chattr.

Last edited by JockVSJock; 09-07-2016 at 01:17 PM.
 
Old 09-07-2016, 01:51 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913Reputation: 2913
It sounds as if the -i attribute is doing the job it was intended to do.

Why don't you store the files in /var/tmp? That directory is intended for storing temporary files that are to survive a reboot. Or indeed store them in any other suitable directory that doesn't get auto wiped?

If you use /var/tmp, you would have to check what RHEL does, if anything, with respect to maintenance on /var/tmp. I read somewhere that RHEL deletes files there that have not been accessed, modified or had a status change in the last 30 days, but that may not be up-to-date info. You could get round that by batch touching the files every so often.

Or, you could find out where RHEL calls tmpwatch (it will probably depend on which version of RHEL you are running) and add an --exclude option.
 
Old 09-07-2016, 03:14 PM   #5
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: DC
Distribution: RHEL/CentOS
Posts: 1,345

Original Poster
Blog Entries: 4

Rep: Reputation: 160Reputation: 160
Correct, I'm moving stuff I want to keep under /var/tmp instead of /tmp.

I've looked at their cronjobs too to make sure they don't clean up /var/tmp...

thanks
 
  


Reply

Tags
chattr, lsattr


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Understanding why certain chattr attributes are set on directories/files JockVSJock Linux - Newbie 9 08-22-2016 12:20 PM
How to store files/directories in different different directories!! anishkumarv Linux - Newbie 7 03-23-2011 06:26 PM
LXer: Viewing and Changing Ext2/3 File Attributes With chattr and lsattr LXer Syndicated Linux News 0 03-29-2009 07:50 PM
CHMOD directories.sub-directories.files zerojosh Linux - Software 2 11-19-2005 04:22 PM
chattr +i to all files on my box? ForumKid Linux - Security 3 01-07-2002 11:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration