{"id":3374,"date":"2010-07-15T23:33:59","date_gmt":"2010-07-16T03:33:59","guid":{"rendered":"http:\/\/g33kinfo.com\/info\/?p=3374"},"modified":"2010-07-15T23:33:59","modified_gmt":"2010-07-16T03:33:59","slug":"how-to-use-auditd-to-track-file-changes","status":"publish","type":"post","link":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/","title":{"rendered":"How to use auditd to track file changes"},"content":{"rendered":"<p>From <a href=\"http:\/\/www.lazyscripter.com\/2010\/07\/how-to-use-auditd-to-track-file-changes\/\" target=\"_blank\" rel=\"noopener noreferrer\">lazyscripter.com<\/a><\/p>\n<p>Alright, here\u2019s a post for the advanced Linux users that doesn\u2019t have time to mess around. Have you ever wanted to track what accesses a file on your server? Using the auditd daemon, you can do just that.<\/p>\n<p><strong>Is auditctl installed?<\/strong><br \/>\n<code><br \/>\n[root@eclipse ] ~ # which auditctl<br \/>\n\/sbin\/auditctl<br \/>\n<\/code><\/p>\n<p><strong>How to install auditctl<\/strong><br \/>\nIf your output is blank, or shows an error message, you may need to install the audit package.<br \/>\n<code><br \/>\n[root@eclipse ] ~ # yum -y install audit<br \/>\nRunning auditd on boot<br \/>\n[root@eclipse ] ~ # chkconfig auditd on<br \/>\n[root@eclipse ] ~ # ntsysv<br \/>\n<\/code><br \/>\nYou\u2019ll see a screen like this:<\/p>\n<p style=\"text-align: center;\">ntsysv<\/p>\n<p style=\"text-align: left;\">\nJust make sure auditd has a star, then hit  once to go to the \u201cOk\u201d button, and hit Enter to save.<\/p>\n<p>After you save, be sure to start the auditd daemon by executing:<br \/>\n<code><br \/>\n[root@eclipse] ~ # \/etc\/init.d\/auditd start<br \/>\nStarting auditd:                                           [  OK  ]<br \/>\n<\/code><\/p>\n<p><strong>Setting up a file watch<\/strong><br \/>\nTo setup a file watch, you\u2019ll need 3 things:<\/p>\n<ul>\n<li>The filename to watch<\/li>\n<li>A shadow file to record the changes<\/li>\n<li>A permission filter with at least one of these flags: a -&gt; append, r -&gt; read, w -&gt; write, x -&gt; execute<\/li>\n<\/ul>\n<p>Once you have all of that, then go ahead and create your audit rule using the  auditctl command like so:<br \/>\n<code>[root@eclipse] ~ # auditctl -w \/path\/to\/my\/file -k \/path\/to\/my\/shadow-file -p rwxa<\/code><\/p>\n<p>For example i\u2019m going to use a file called \/root\/notouchie:<br \/>\n<code><br \/>\n[root@eclipse] ~ # auditctl -w \/root\/notouchie -k \/root\/notouchie-shadow -p rwxa<\/code><\/p>\n<p>You should then list your auditctl rules to verify that rule is in place.<br \/>\n<code><br \/>\n[root@eclipse] ~ # auditctl -l<br \/>\nLIST_RULES: exit,always watch=\/root\/notouchie perm=rwxa key=\/root\/notouchie-shadow<\/code><\/p>\n<p>Then, against better judgement, we\u2019re going to touch \/root\/notouchie like so:<br \/>\n<code><br \/>\n[root@eclipse] ~ # touch \/root\/notouchie<\/code><\/p>\n<p>This should set off auditd, so now we search our audit database with ausearch and give it a few arguments.<br \/>\n<code><br \/>\n[root@eclipse] ~ # ausearch -i -f \/root\/notouchie<br \/>\n----<br \/>\ntype=PATH msg=audit(07\/14\/2010 00:53:12.844:94) :<br \/>\nitem=0 name=\/root\/notouchie inode=131757 dev=08:02 mode=file,644 ouid=root ogid=root rdev=00:00<br \/>\ntype=CWD msg=audit(07\/14\/2010 00:53:12.844:94) :<br \/>\ncwd=\/root<br \/>\ntype=SYSCALL msg=audit(07\/14\/2010 00:53:12.844:94) :<br \/>\narch=x86_64 syscall=open success=yes exit=0 a0=7fffcec7fa71 a1=941 a2=1b6 a3=0 items=1 ppid=27044 pid=18781 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=pts0 ses=4294967295 comm=touch exe=\/bin\/touch key=\/root\/notouchie-shadow<\/code><\/p>\n<p>Now we see that uid=root executed \/bin\/touch and modified the file.<\/p>\n<p>This is just the beginning of the possibilities of auditd, check out more options at the manpage:<\/p>\n<p><a href=\"http:\/\/linux.die.net\/man\/8\/aureport\" target=\"_blank\" rel=\"noopener noreferrer\">aureport(8)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>From lazyscripter.com Alright, here\u2019s a post for the advanced Linux users that doesn\u2019t have time to mess around. Have you ever wanted to track what accesses a file on your server? Using the auditd daemon, you can do just that. Is auditctl installed? [root@eclipse ] ~ # which auditctl \/sbin\/auditctl How to install auditctl If&#8230; <\/p>\n<div class=\"read-more navbutton\"><a href=\"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/\">Read More<i class=\"fa fa-angle-double-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-3374","post","type-post","status-publish","format-standard","hentry","category-info"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use auditd to track file changes - Linux Shtuff<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use auditd to track file changes - Linux Shtuff\" \/>\n<meta property=\"og:description\" content=\"From lazyscripter.com Alright, here\u2019s a post for the advanced Linux users that doesn\u2019t have time to mess around. Have you ever wanted to track what accesses a file on your server? Using the auditd daemon, you can do just that. Is auditctl installed? [root@eclipse ] ~ # which auditctl \/sbin\/auditctl How to install auditctl If... Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/\" \/>\n<meta property=\"og:site_name\" content=\"Linux Shtuff\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:author\" content=\"https:\/\/fb.me\/g33kinf0\" \/>\n<meta property=\"article:published_time\" content=\"2010-07-16T03:33:59+00:00\" \/>\n<meta name=\"author\" content=\"g33kadmin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/drsinger1111\" \/>\n<meta name=\"twitter:site\" content=\"@drsinger1111\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/\"},\"author\":{\"name\":\"g33kadmin\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"headline\":\"How to use auditd to track file changes\",\"datePublished\":\"2010-07-16T03:33:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/\"},\"wordCount\":278,\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"articleSection\":[\"General Info\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/\",\"name\":\"How to use auditd to track file changes - Linux Shtuff\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\"},\"datePublished\":\"2010-07-16T03:33:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/how-to-use-auditd-to-track-file-changes\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use auditd to track file changes\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#website\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/\",\"name\":\"Linux Shtuff\",\"description\":\"Because I have CRS Syndrome...\",\"publisher\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/#\\\/schema\\\/person\\\/c022e4c40b13ea1b678e6f020756f547\",\"name\":\"g33kadmin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"url\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"contentUrl\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\",\"width\":512,\"height\":512,\"caption\":\"g33kadmin\"},\"logo\":{\"@id\":\"https:\\\/\\\/g33kinfo.com\\\/info\\\/wp-content\\\/uploads\\\/2022\\\/07\\\/minion-researchA.gif\"},\"description\":\"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\\\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....\",\"sameAs\":[\"https:\\\/\\\/thelinuxreport.com\",\"https:\\\/\\\/fb.me\\\/g33kinf0\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/drsinger1111\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use auditd to track file changes - Linux Shtuff","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/","og_locale":"en_US","og_type":"article","og_title":"How to use auditd to track file changes - Linux Shtuff","og_description":"From lazyscripter.com Alright, here\u2019s a post for the advanced Linux users that doesn\u2019t have time to mess around. Have you ever wanted to track what accesses a file on your server? Using the auditd daemon, you can do just that. Is auditctl installed? [root@eclipse ] ~ # which auditctl \/sbin\/auditctl How to install auditctl If... Read More","og_url":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/","og_site_name":"Linux Shtuff","article_publisher":"https:\/\/fb.me\/g33kinf0","article_author":"https:\/\/fb.me\/g33kinf0","article_published_time":"2010-07-16T03:33:59+00:00","author":"g33kadmin","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/drsinger1111","twitter_site":"@drsinger1111","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/#article","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/"},"author":{"name":"g33kadmin","@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"headline":"How to use auditd to track file changes","datePublished":"2010-07-16T03:33:59+00:00","mainEntityOfPage":{"@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/"},"wordCount":278,"publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"articleSection":["General Info"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/","url":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/","name":"How to use auditd to track file changes - Linux Shtuff","isPartOf":{"@id":"https:\/\/g33kinfo.com\/info\/#website"},"datePublished":"2010-07-16T03:33:59+00:00","breadcrumb":{"@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/g33kinfo.com\/info\/how-to-use-auditd-to-track-file-changes\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/g33kinfo.com\/info\/"},{"@type":"ListItem","position":2,"name":"How to use auditd to track file changes"}]},{"@type":"WebSite","@id":"https:\/\/g33kinfo.com\/info\/#website","url":"https:\/\/g33kinfo.com\/info\/","name":"Linux Shtuff","description":"Because I have CRS Syndrome...","publisher":{"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/g33kinfo.com\/info\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/g33kinfo.com\/info\/#\/schema\/person\/c022e4c40b13ea1b678e6f020756f547","name":"g33kadmin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","url":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","contentUrl":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif","width":512,"height":512,"caption":"g33kadmin"},"logo":{"@id":"https:\/\/g33kinfo.com\/info\/wp-content\/uploads\/2022\/07\/minion-researchA.gif"},"description":"I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com\/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....","sameAs":["https:\/\/thelinuxreport.com","https:\/\/fb.me\/g33kinf0","https:\/\/x.com\/https:\/\/twitter.com\/drsinger1111"]}]}},"_links":{"self":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/3374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/comments?post=3374"}],"version-history":[{"count":0,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/posts\/3374\/revisions"}],"wp:attachment":[{"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/media?parent=3374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/categories?post=3374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/g33kinfo.com\/info\/wp-json\/wp\/v2\/tags?post=3374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}