Imported Upstream version 2.4.3
[platform/upstream/audit.git] / docs / ausearch.8
1 .TH AUSEARCH: "8" "Sept 2009" "Red Hat" "System Administration Utilities"
2 .SH NAME
3 ausearch \- a tool to query audit daemon logs
4 .SH SYNOPSIS
5 .B ausearch
6 .RI [ options ]
7 .SH DESCRIPTION
8 \fBausearch\fP is a tool that can query the audit daemon logs based for events based on different search criteria. The ausearch utility can also take input from stdin as long as the input is the raw log data. Each commandline option given forms an "and" statement. For example, searching with \fB\-m\fP and \fB\-ui\fP means return events that have both the requested type and match the user id given. An exception is the \fB\-n\fP option; multiple nodes are allowed in a search which will return any matching node.
9
10 It should also be noted that each syscall excursion from user space into the kernel and back into user space has one event ID that is unique. Any auditable event that is triggered during this trip share this ID so that they may be correlated.
11
12 Different parts of the kernel may add supplemental records. For example, an audit event on the syscall "open" will also cause the kernel to emit a PATH record with the file name. The ausearch utility will present all records that make up one event together. This could mean that even though you search for a specific kind of record, the resulting events may contain SYSCALL records.
13
14 Also be aware that not all record types have the requested information. For example, a PATH record does not have a hostname or a loginuid.
15
16 .SH OPTIONS
17 .TP
18 .BR \-a ,\  \-\-event \ \fIaudit-event-id\fP
19 Search for an event based on the given \fIevent ID\fP. Messages always start with something like msg=audit(1116360555.329:2401771). The event ID is the number after the ':'. All audit events that are recorded from one application's syscall have the same audit event ID. A second syscall made by the same application will have a different event ID. This way they are unique.
20 .TP
21 .BR \-\-arch \ \fICPU\fP
22 Search for events based on a specific CPU architecture.  If you do not know the arch of your machine but you want to use the 32 bit syscall table and your machine supports 32 bits, you can also use
23 .B b32
24 for the arch. The same applies to the 64 bit syscall table, you can use
25 .B b64.
26 The arch of your machine can be found by doing 'uname -m'.
27 .TP
28 .BR \-c ,\  \-\-comm \ \fIcomm-name\fP
29 Search for an event based on the given \fIcomm name\fP. The comm name is the executable's name from the task structure.
30 .TP
31 .BR \-\-debug
32 Write malformed events that are skipped to stderr.
33 .TP
34 .BR \-\-checkpoint \ \fIcheckpoint-file\fP
35 Checkpoint the output between successive invocations of ausearch such that only events not
36 previously output will print in subsequent invocations.
37
38 An auditd event is made up of one or more records. When processing events, ausearch defines
39 events as either complete or in-complete.  A complete event is either a single record event or
40 one whose event time occurred 2 seconds in the past compared to the event being currently
41 processed.
42
43 A checkpoint is achieved by recording the last completed event output along with the device
44 number and inode of the file the last completed event appeared in \fIcheckpoint-file\fP. On a subsequent invocation,
45 ausearch will load this checkpoint data and as it processes the log files, it will discard all
46 complete events until it matches the checkpointed one. At this point, it will start
47 outputting complete events.
48
49 Should the file or the last checkpointed event not be found, one of a number of errors will result and ausearch will terminate. See \fBEXIT STATUS\fP for detail.
50
51 .TP
52 .BR \-e,\  \-\-exit \ \fIexit-code-or-errno\fP
53 Search for an event based on the given syscall \fIexit code or errno\fP.
54 .TP
55 .BR \-f ,\  \-\-file \ \fIfile-name\fP
56 Search for an event based on the given \fIfilename\fP.
57 .TP
58 .BR \-ga ,\  \-\-gid\-all \ \fIall-group-id\fP
59 Search for an event with either effective group ID or group ID matching the given \fIgroup ID\fP.
60 .TP
61 .BR \-ge ,\  \-\-gid\-effective \ \fIeffective-group-id\fP
62 Search for an event with the given \fIeffective group ID\fP or group name.
63 .TP
64 .BR \-gi ,\  \-\-gid \ \fIgroup-id\fP
65 Search for an event with the given \fIgroup ID\fP or group name.
66 .TP
67 .BR \-h ,\  \-\-help
68 Help
69 .TP
70 .BR \-hn ,\  \-\-host \ \fIhost-name\fP
71 Search for an event with the given \fIhost name\fP. The hostname can be either a hostname, fully qualified domain name, or numeric network address. No attempt is made to resolve numeric addresses to domain names or aliases.
72 .TP
73 .BR \-i ,\  \-\-interpret
74 Interpret numeric entities into text. For example, uid is converted to account name. The conversion is done using the current resources of the machine where the search is being run. If you have renamed the accounts, or don't have the same accounts on your machine, you could get misleading results.
75 .TP
76 .BR \-if ,\  \-\-input \ \fIfile-name\fP\ |\ \fIdirectory\fP
77 Use the given \fIfile\fP or \fIdirectory\fP instead of the logs. This is to aid analysis where the logs have been moved to another machine or only part of a log was saved.
78 .TP
79 .BR \-\-input\-logs
80 Use the log file location from auditd.conf as input for searching. This is needed if you are using ausearch from a cron job.
81 .TP
82 .BR \-\-just\-one
83 Stop after emitting the first event that matches the search criteria.
84 .TP
85 .BR \-k ,\  \-\-key \ \fIkey-string\fP
86 Search for an event based on the given \fIkey string\fP.
87 .TP
88 .BR \-l ,\  \-\-line\-buffered
89 Flush output on every line. Most useful when stdout is connected to a pipe and the default block buffering strategy is undesirable. May impose a performance penalty.
90 .TP
91 .BR \-m ,\  \-\-message \ \fImessage-type\fP\ |\ \fIcomma-sep-message-type-list\fP
92 Search for an event matching the given \fImessage type\fP. You may also enter a \fIcomma separated list of message types\fP. There is an \fBALL\fP message type that doesn't exist in the actual logs. It allows you to get all messages in the system. The list of valid messages types is long. The program will display the list whenever no message type is passed with this parameter. The message type can be either text or numeric. If you enter a list, there can be only commas and no spaces separating the list.
93 .TP
94 .BR \-n ,\  \-\-node \ \fInode-name\fP
95 Search for events originating from \fInode name\fP string. Multiple nodes are allowed, and if any nodes match, the event is matched.
96 .TP
97 .BR \-o ,\  \-\-object \ \fISE-Linux-context-string\fP
98 Search for event with \fItcontext\fP (object) matching the string.
99 .TP
100 .BR \-p ,\  \-\-pid \ \fIprocess-id\fP
101 Search for an event matching the given \fIprocess ID\fP.
102 .TP
103 .BR \-pp ,\  \-\-ppid \ \fIparent-process-id\fP
104 Search for an event matching the given \fIparent process ID\fP.
105 .TP
106 .BR \-r ,\  \-\-raw
107 Output is completely unformatted. This is useful for extracting records that can still be interpreted by audit tools.
108 .TP
109 .BR \-sc ,\  \-\-syscall \ \fIsyscall-name-or-value\fP
110 Search for an event matching the given \fIsyscall\fP. You may either give the numeric syscall value or the syscall name. If you give the syscall name, it will use the syscall table for the machine that you are using. 
111 .TP
112 .BR \-se ,\  \-\-context \ \fISE-Linux-context-string\fP
113 Search for event with either \fIscontext\fP/subject or \fItcontext\fP/object matching the string.
114 .TP
115 .BR \-\-session \ \fILogin-Session-ID\fP
116 Search for events matching the given Login Session ID. This process attribute is set when a user logs in and can tie any process to a particular user login.
117 .TP
118 .BR \-su ,\  \-\-subject \ \fISE-Linux-context-string\fP
119 Search for event with \fIscontext\fP (subject) matching the string.
120 .TP
121 .BR \-sv ,\  \-\-success \ \fIsuccess-value\fP
122 Search for an event matching the given \fIsuccess value\fP. Legal values are 
123 .B yes
124 and
125 .BR no .
126 .TP
127 .BR \-te ,\  \-\-end \ [\fIend-date\fP]\ [\fIend-time\fP]
128 Search for events with time stamps equal to or before the given end time. The format of end time depends on your locale. If the date is omitted,
129 .B today
130 is assumed. If the time is omitted, 
131 .B now
132 is assumed. Use 24 hour clock time rather than AM or PM to specify time. An example date using the en_US.utf8 locale is 09/03/2009. An example of time is 18:00:00. The date format accepted is influenced by the LC_TIME environmental variable.
133
134 You may also use the word: \fBnow\fP, \fBrecent\fP, \fBtoday\fP, \fByesterday\fP, \fBthis\-week\fP, \fBweek\-ago\fP, \fBthis\-month\fP, or \fBthis\-year\fP. \fBToday\fP means starting now. \fBRecent\fP is 10 minutes ago. \fBYesterday\fP is 1 second after midnight the previous day. \fBThis\-week\fP means starting 1 second after midnight on day 0 of the week determined by your locale (see \fBlocaltime\fP). \fBWeek\-ago\fP means 1 second after midnight exactly 7 days ago. \fBThis\-month\fP means 1 second after midnight on day 1 of the month. \fBThis\-year\fP means the 1 second after midnight on the first day of the first month.
135 .TP
136 .BR \-ts ,\  \-\-start \ [\fIstart-date\fP]\ [\fIstart-time\fP]
137 Search for events with time stamps equal to or after the given start time. The format of start time depends on your locale. If the date is omitted, 
138 .B today
139 is assumed. If the time is omitted, 
140 .B midnight
141 is assumed. Use 24 hour clock time rather than AM or PM to specify time. An example date using the en_US.utf8 locale is 09/03/2009. An example of time is 18:00:00. The date format accepted is influenced by the LC_TIME environmental variable.
142
143 You may also use the word: \fBnow\fP, \fBrecent\fP, \fBtoday\fP, \fByesterday\fP, \fBthis\-week\fP, \fBweek\-ago\fP, \fBthis\-month\fP, \fBthis\-year\fP, or \fBcheckpoint\fP. \fBToday\fP means starting at 1 second after midnight. \fBRecent\fP is 10 minutes ago. \fBYesterday\fP is 1 second after midnight the previous day. \fBThis\-week\fP means starting 1 second after midnight on day 0 of the week determined by your locale (see \fBlocaltime\fP). \fBWeek\-ago\fP means starting 1 second after midnight exactly 7 days ago. \fBThis\-month\fP means 1 second after midnight on day 1 of the month. \fBThis\-year\fP means the 1 second after midnight on the first day of the first month.
144 .sp
145 \fBcheckpoint\fP means \fIausearch\fP will use the timestamp found within a valid checkpoint file ignoring the recorded inode, device, serial, node and event type also found within a checkpoint file. Essentially, this is the recovery action should an invocation of \fIausearch\fP with a checkpoint option fail with an exit status of 10, 11 or 12. It could be used in a shell script something like:
146 .sp
147 .in +5
148 .nf
149 .na
150 ausearch --checkpoint /etc/audit/auditd_checkpoint.txt -i
151 _au_status=$?
152 if test ${_au_status} eq 10 -o ${_au_status} eq 11 -o ${_au_status} eq 12
153 then
154   ausearch --checkpoint /etc/audit/auditd_checkpoint.txt --start checkpoint -i
155 fi
156 .ad
157 .fi
158 .in -5
159 .TP
160 .BR \-tm ,\  \-\-terminal \ \fIterminal\fP
161 Search for an event matching the given \fIterminal\fP value. Some daemons such as cron and atd use the daemon name for the terminal.
162 .TP
163 .BR \-ua ,\  \-\-uid\-all \ \fIall-user-id\fP
164 Search for an event with either user ID, effective user ID, or login user ID (auid) matching the given \fIuser ID\fP.
165 .TP
166 .BR \-ue ,\  \-\-uid\-effective \ \fIeffective-user-id\fP
167 Search for an event with the given \fIeffective user ID\fP.
168 .TP
169 .BR \-ui ,\  \-\-uid \ \fIuser-id\fP
170 Search for an event with the given \fIuser ID\fP.
171 .TP
172 .BR \-ul ,\  \-\-loginuid \ \fIlogin-id\fP
173 Search for an event with the given \fIlogin user ID\fP. All entry point programs that are pamified need to be configured with pam_loginuid required for the session for searching on loginuid (auid) to be accurate.
174 .TP
175 .BR \-uu ,\  \-\-uuid \ \fIguest-uuid\fP
176 Search for an event with the given \fIguest UUID\fP.
177 .TP
178 .BR \-v ,\  \-\-version
179 Print the version and exit
180 .TP
181 .BR \-vm ,\  \-\-vm-name \ \fIguest-name\fP
182 Search for an event with the given \fIguest name\fP.
183 .TP
184 .BR \-w ,\  \-\-word
185 String based matches must match the whole word. This category of matches include: filename, hostname, terminal, and SE Linux context.
186 .TP
187 .BR \-x ,\  \-\-executable \ \fIexecutable\fP
188 Search for an event matching the given \fIexecutable\fP name.
189
190 .SH "EXIT STATUS"
191 .TP 5
192 0
193 if OK,
194 .TP
195 1
196 if nothing found, or argument errors or minor file acces/read errors,
197 .TP
198 10
199 invalid checkpoint data found in checkpoint file,
200 .TP
201 11
202 checkpoint processing error
203 .TP
204 12
205 checkpoint event not found in matching log file
206 .SH "SEE ALSO"
207 .BR auditd (8),
208 .BR pam_loginuid (8).