Friday, September 15, 2017

Best Practices Of Running File System Check On EXT4 Or XFS

linux dvd.png
Generally, running a file system check/repair command in Linux is expected to automatically repair at least some of the inconsistencies it finds. In some cases, severely damaged i-nodes or directories may be discarded if they cannot be repaired, hence, significant changes to the file system may occur which may result in data loss.

To ensure that unexpected or undesirable changes are not permanently made, perform the following precautionary steps:

Dry run (read-only mode)
Most file system checkers have a mode of operation which checks but does not repair the file system. In this mode, the checker will print any errors that it finds and actions that it would have taken, without actually modifying the file system. Using "e2fsck" on EXT4 (ext family file systems) and "xfs_repair" for XFS.

Saturday, September 9, 2017

Generate E-mail Alert Whenever An User Is Added

ecently I came across a situation wherein there was a requirement to trigger an email alert whenever a new user is added to the system (Linux).
By default an alert would get logged in "/var/log/secure" file as and when a user is added or removed. However, I wanted a similar e-mail alert to be sent. Hence, I thought of coming up with a script to get this done. I found that this can be achieved in 2 ways as explained below (there could many other ways as well):