<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Linux Admin Zone &#187; root history</title>
	<atom:link href="http://linuxadminzone.com/tag/root-history/feed/" rel="self" type="application/rss+xml" />
	<link>http://linuxadminzone.com</link>
	<description>Adding more reasons to celebrate Open Source.</description>
	<lastBuildDate>Wed, 09 May 2012 10:17:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Save root or user history to check later</title>
		<link>http://linuxadminzone.com/save-root-or-user-history-to-check-later/</link>
		<comments>http://linuxadminzone.com/save-root-or-user-history-to-check-later/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 08:18:09 +0000</pubDate>
		<dc:creator>jagbir</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[root history]]></category>
		<category><![CDATA[user history]]></category>

		<guid isPermaLink="false">http://linuxadminzone.com/?p=6</guid>
		<description><![CDATA[Some times we need a way to automatically save any user&#8217;s or root&#8217;s activity so that we can check later. In environment, where root account is accessible by multiple people, its very helpful to exactly know who did what and when? In my case, I have found that some files are changed mysteriously but I [...]]]></description>
			<content:encoded><![CDATA[<p>Some times we need a way to automatically save any user&#8217;s or root&#8217;s activity so that we can check later. In environment, where root account is accessible by multiple people, its very helpful to exactly know who did what and when? In my case, I have found that some files are changed mysteriously but I was clueless as there are more than one users with root access.</p>
<p>To save the activity/history of any user (including root), you need to open the user&#8217;s .bash_profile from his home directory.</p>
<p>Here, for instance, I would like to record all commands in a file when a user login as root or su to root. History will be stored in a file with name as DateTimeIPAddress from where user came.</p>
<p>Step 1. Go to root&#8217;s home:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~</pre></div></div>

<p>Step 2. You can make a hidden directory so that all history files will be stored there:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> .rhistdata</pre></div></div>

<p>Step 3. Open .bash_profile and write down following commands:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">vi</span> .bash_profile
<span style="color: #666666; font-style: italic;"># save root history</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTSIZE</span>=<span style="color: #000000;">3000</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTFILESIZE</span>=<span style="color: #000000;">5000</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">HISTFILE</span>=<span style="color: #000000; font-weight: bold;">/</span>root<span style="color: #000000; font-weight: bold;">/</span>.rhistdata<span style="color: #000000; font-weight: bold;">/</span>.bash_hist-$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">who</span> am i <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $3.$4.$5.$6}'</span>;<span style="color: #7a0874; font-weight: bold;">exit</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Save and close the file.</p>
<p>It&#8217;s simple. You can try to login again as root, do something and logout. Login again and check that there&#8217;s file having all commands you performed.</p>
<p>* <a href="http://linuxadminzone.com/5-steps-to-secure-your-linux-server/"> 5 steps to secure your Linux Server </a><br />
* <a href="http://linuxadminzone.com/ensuring-secure-access-to-production-linux-servers/"> Ensuring secure access to production Linux Servers </a><br />
* <a href="http://linuxadminzone.com/bash-script-to-backup-essential-log-files-of-linux-server/"> Bash script to backup essential log files in Linux </a><br />
* <a href="http://linuxadminzone.com/quickly-change-your-ssh-port-from-default-22-to-something-higher/"> Quickly change your ssh port from defualt 22 to something higher </a><br />
* <a href="http://linuxadminzone.com/ssh-port-forwarding-from-remote-to-local-machine/"> SSH port forwarding from remote to local machine </a><br />
* <a href="http://linuxadminzone.com/install-and-configure-denyhost/"> Install and configure denyhost to prevent brute force attacks </a></p>
]]></content:encoded>
			<wfw:commentRss>http://linuxadminzone.com/save-root-or-user-history-to-check-later/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

