
<?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> &#187; Nikesh Shakya</title>
	<atom:link href="https://www.nikeshshk.com.np/author/nikesh/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.nikeshshk.com.np</link>
	<description></description>
	<lastBuildDate>Tue, 04 Nov 2025 10:25:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.4</generator>
	<item>
		<title>Hardening your Apache and PHP on Ubuntu 9.04 Server</title>
		<link>https://www.nikeshshk.com.np/news/hardening-your-apache-and-php-on-ubuntu-9-04-server/</link>
		<comments>https://www.nikeshshk.com.np/news/hardening-your-apache-and-php-on-ubuntu-9-04-server/#comments</comments>
		<pubDate>Tue, 02 Jun 2015 11:13:02 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=818</guid>
		<description><![CDATA[You have installed LAMP and OpenSSH on your Ubuntu 9.04 Server. The first thing to do is to harden it in order to avoid some kind of attacks. You can do the following steps in front of your Ubuntu 9.04 Server or remote access it via OpenSSH. For OpenSSH, your Ubuntu 9.04 Server is at 192.168.0.10 : ssh 192.168.0.10 -l nikesh Step 1 : The avoid someone to list your files on your Apache directory, you should do the following step. sudo nano /etc/apache2/sites-available/default Add a minus &#8220;-&#8221; in the front of &#8220;Indexes&#8221; and it will looking like this :     Options -Indexes FollowSymLinks MultiViews     AllowOverride None     Order allow,deny     allow from all Step 2 : To enable the rewrite module of Apache. sudo a2enmod rewrite To avoid Cross-Site-Tracing attack. Add the following lines within &#8221; &#8221; :     RewriteEngine On     RewriteCond %{REQUEST_METHOD} ^(TRACE&#124;TRACK)     RewriteRule .* &#8211; [F] Step 3 : To avoid HTTP DoS, DDoS or Brute Force attack, you should install&#160;<a href="https://www.nikeshshk.com.np/news/hardening-your-apache-and-php-on-ubuntu-9-04-server/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>You have installed LAMP and OpenSSH on your Ubuntu 9.04 Server. The first thing to do is to harden it in order to avoid some kind of attacks.</p>
<p>You can do the following steps in front of your Ubuntu 9.04 Server or remote access it via OpenSSH.</p>
<p>For OpenSSH, your Ubuntu 9.04 Server is at 192.168.0.10 :</p>
<p>ssh 192.168.0.10 -l nikesh</p>
<p>Step 1 :</p>
<p>The avoid someone to list your files on your Apache directory, you should do the following step.</p>
<p>sudo nano /etc/apache2/sites-available/default</p>
<p>Add a minus &#8220;-&#8221; in the front of &#8220;Indexes&#8221; and it will looking like this :</p>
<p><Directory /var/www/><br />
    Options -Indexes FollowSymLinks MultiViews<br />
    AllowOverride None<br />
    Order allow,deny<br />
    allow from all<br />
</Directory></p>
<p>Step 2 :</p>
<p>To enable the rewrite module of Apache.</p>
<p>sudo a2enmod rewrite</p>
<p>To avoid Cross-Site-Tracing attack. Add the following lines within &#8221; <VirtualHost *:80>&#8221; :</p>
<p><IfModule mod_rewrite.c><br />
    RewriteEngine On<br />
    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)<br />
    RewriteRule .* &#8211; [F]
</IfModule></p>
<p>Step 3 :</p>
<p>To avoid HTTP DoS, DDoS or Brute Force attack, you should install this module.</p>
<p>sudo apt-get install libapache2-mod-evasive</p>
<p>Step 4 :</p>
<p>To screen out bad URL requests, such as /etc/shadow or MySQL injection and etc. You should install mod_security module. If you installed a amd64 (64-bit) version of Ubuntu Server, please replaced i386 with amd64 for the following commands.</p>
<p>wget http://etc.inittab.org/~agi/debian/libapache-mod-security2/libapache-mod-security_2.5.9-1_i386.deb</p>
<p>wget http://etc.inittab.org/~agi/debian/libapache-mod-security2/mod-security-common_2.5.9-1_all.deb</p>
<p>sudo dpkg -i libapache-mod-security_2.5.9-1_i386.deb mod-security-common_2.5.9-1_all.deb</p>
<p>Step 5 :</p>
<p>Do not allow any Apache and Ubuntu Server information to be print on the error pages.</p>
<p>sudo nano /etc/apache2/conf.d/security</p>
<p>Change the following lines as the following :</p>
<p>ServerToken Prod<br />
ServerSignature Off</p>
<p>Step 6 :</p>
<p>Now, it is time to harden the PHP.</p>
<p>sudo nano /etc/php5/apache2/php.ini</p>
<p>Change the following lines as the following :</p>
<p>display_errors = Off<br />
log_errors = On<br />
allow_url_fopen = Off<br />
safe_mode = On<br />
expose_php = Off<br />
enable_dl = Off<br />
disable_functions = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd</p>
<p>Step 7 :</p>
<p>Final step is to restart Apache server.</p>
<p>sudo /etc/init.d/apache2 restart</p>
<p>Step 8 :</p>
<p>sudo nano /etc/sysctl.conf<br />
Uncomment the following line and make it look like this.</p>
<p>#Enable TCP SYN Cookie Protection<br />
net.ipv4.tcp_syncookies = 1</p>
<p>Make the change active.</p>
<p>sudo /sbin/sysctl -p</p>
<p>That&#8217;s all. See you!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/hardening-your-apache-and-php-on-ubuntu-9-04-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Protect your Server Against the Shellshock Bash Vulnerability</title>
		<link>https://www.nikeshshk.com.np/news/how-to-protect-your-server-against-the-shellshock-bash-vulnerability/</link>
		<comments>https://www.nikeshshk.com.np/news/how-to-protect-your-server-against-the-shellshock-bash-vulnerability/#comments</comments>
		<pubDate>Sat, 27 Sep 2014 15:49:53 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Shellshock Bash Vulnerability]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=783</guid>
		<description><![CDATA[On September 24, 2014, a GNU Bash vulnerability, referred to as Shellshock or the &#8220;Bash Bug&#8221;, was disclosed. In short, the vulnerability allows remote attackers to execute arbitrary code given certain conditions, by passing strings of code following environment variable assignments. Because of Bash&#8217;s ubiquitous status amongst Linux, BSD, and Mac OS X distributions, many computers are vulnerable to Shellshock; all unpatched Bash versions between 1.14 through 4.3 (i.e. all releases until now) are at risk. The Shellshock vulnerability can be exploited on systems that are running Services or applications that allow unauthorized remote users to assign Bash environment variables. Examples of exploitable systems include the following: Apache HTTP Servers that use CGI scripts (via mod_cgi and mod_cgid) that are written in Bash or launch to Bash subshells Certain DHCP clients OpenSSH servers that use the ForceCommand capability Various network-exposed services that use Bash A detailed description of the bug can be found at CVE-2014-6271 and CVE-2014-7169. Because the Shellshock vulnerability is very widespread&#8211;even more so than the&#160;<a href="https://www.nikeshshk.com.np/news/how-to-protect-your-server-against-the-shellshock-bash-vulnerability/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>On September 24, 2014, a GNU Bash vulnerability, referred to as Shellshock or the &#8220;Bash Bug&#8221;, was disclosed. In short, the vulnerability allows remote attackers to execute arbitrary code given certain conditions, by passing strings of code following environment variable assignments. Because of Bash&#8217;s ubiquitous status amongst Linux, BSD, and Mac OS X distributions, many computers are vulnerable to Shellshock; all unpatched Bash versions between 1.14 through 4.3 (i.e. all releases until now) are at risk.</p>
<p>The Shellshock vulnerability can be exploited on systems that are running Services or applications that allow unauthorized remote users to assign Bash environment variables. Examples of exploitable systems include the following:</p>
<ul>
<li>Apache HTTP Servers that use CGI scripts (via <code>mod_cgi</code> and <code>mod_cgid</code>) that are written in Bash or launch to Bash subshells</li>
<li>Certain DHCP clients</li>
<li>OpenSSH servers that use the <code>ForceCommand</code> capability</li>
<li>Various network-exposed services that use Bash</li>
</ul>
<p>A detailed description of the bug can be found at <a href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-6271">CVE-2014-6271</a> and <a href="http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-7169">CVE-2014-7169</a>.</p>
<p>Because the Shellshock vulnerability is very widespread&#8211;even more so than the OpenSSL Heartbleed bug&#8211;and particularly easy to exploit, it is highly recommended that affected systems are properly updated to fix or mitigate the vulnerability as soon as possible. We will show you how to test if your machines are vulnerable and, if they are, how to update Bash to remove the vulnerability.</p>
<p>Note: <em>(Sept. 25, 2014 &#8211; 6:00pm EST)</em> At the time of writing, only an &#8220;incomplete fix&#8221; for the vulnerability has been released. As such, it is recommended to update your machines that run Bash immediately, and check back for updates and a complete fix.</p>
<div data-unique="check-system-vulnerability"></div>
<h2>Check System Vulnerability</h2>
<p>On each of your systems that run Bash, you may check for Shellshock vulnerability by running the following command at the <code>bash</code> prompt:</p>
<pre><code>env VAR='() { :;}; echo Bash is vulnerable!' bash -c "echo Bash Test"
</code></pre>
<p>The highlighted <code>echo Bash is vulnerable!</code> portion of the command represents where a remote attacker could inject malicious code; arbitrary code following a function definition within an environment variable assignment. Therefore, if you see the following output, your version of Bash is vulnerable and should be updated:</p>
<pre><code>Bash is vulnerable!
Bash Test
</code></pre>
<p>Otherwise, if your output does not include the simulated attacker&#8217;s payload, i.e. &#8220;Bash is vulnerable&#8221; is not printed as output, your version of bash is not vulnerable. It may look something like this:</p>
<pre><code>bash: warning: VAR: ignoring function definition attempt
bash: error importing function definition for `VAR'
Bash Test
</code></pre>
<p>If your version of Bash is vulnerable, read on to learn how to update Bash and fix the vulnerability.</p>
<h3>Test Remote Sites</h3>
<p>If you simply want to test if websites or specific CGI scripts are vulnerable, use this link:<a href="http://shellshock.brandonpotter.com/">&#8216;ShellShock&#8217; Bash Vulnerability CVE-2014-6271 Test Tool</a>.</p>
<p>Simply enter the URL of the website or CGI script you want to test in the appropriate form and submit.</p>
<div data-unique="fix-vulnerability-update-bash"></div>
<h2>Fix Vulnerability: Update Bash</h2>
<p>The easiest way to fix the vulnerability is to use your default package manager to update the version of Bash. The following subsections cover updating Bash on various Linux distributions, including Ubuntu, Debian, CentOS, Red Hat, and Fedora.</p>
<p>Note: <em>(Sept. 25, 2014 &#8211; 6:00pm EST)</em> At the time of writing, only an &#8220;incomplete fix&#8221; for the vulnerability has been released. As such, it is recommended to update your machines that run Bash immediately, and check back for updates and a complete fix.</p>
<h3>APT-GET: Ubuntu / Debian</h3>
<p>Update Bash to the latest version available via <code>apt-get</code>:</p>
<pre><code>sudo apt-get update &amp;&amp; sudo apt-get install --only-upgrade bash
</code></pre>
<p>Now check your system vulnerability again by running the command in the previous section (<a href="https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-shellshock-bash-vulnerability#check-system-vulnerability">Check System Vulnerability</a>).</p>
<h3>YUM: CentOS / Red Hat / Fedora</h3>
<p>Update Bash to the latest version available via the <code>yum</code>:</p>
<pre><code>sudo yum update bash
</code></pre>
<p>Now check your system vulnerability again by running the command in the previous section (<a href="https://www.digitalocean.com/community/tutorials/how-to-protect-your-server-against-the-shellshock-bash-vulnerability#check-system-vulnerability">Check System Vulnerability</a>).</p>
<div data-unique="conclusion"></div>
<h2>Conclusion</h2>
<p>Be sure to update all of your affected servers to the latest version of Bash!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/how-to-protect-your-server-against-the-shellshock-bash-vulnerability/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Additional Disk Drives to CentOS 5/6</title>
		<link>https://www.nikeshshk.com.np/news/adding-additional-disk-drives-to-centos-56/</link>
		<comments>https://www.nikeshshk.com.np/news/adding-additional-disk-drives-to-centos-56/#comments</comments>
		<pubDate>Mon, 23 Jun 2014 14:15:16 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[add drive]]></category>
		<category><![CDATA[ext4]]></category>
		<category><![CDATA[fdisk]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=676</guid>
		<description><![CDATA[Making use of a second drive for extra space? Here&#8217;s a quick run-down: 1) Make sure you know which disk is being formatted. First, second, and third drives will be /dev/sda, /dev/sdb, and /dev/sdc respectively. Check this with fdisk -l [03:50:04] [root@virt ~]# fdisk -l Disk /dev/sda: 34.3 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 4177 33447330 8e Linux LVM Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk /dev/sdb doesn't contain a valid partition table 2) You can see that /dev/sdb (our second hard drive) does not have any partitions. We will need to create a partition(s) on the drive and then make a file system on it, then mount it. Let&#8217;s write partitions to the drive&#160;<a href="https://www.nikeshshk.com.np/news/adding-additional-disk-drives-to-centos-56/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<div>
<p>Making use of a second drive for extra space? Here&#8217;s a quick run-down:</p>
<p>1) Make sure you know which disk is being formatted. First, second, and third drives will be /dev/sda, /dev/sdb, and /dev/sdc respectively. Check this with <code>fdisk -l</code></p>
<pre>[03:50:04] [root@virt ~]# fdisk -l

Disk /dev/sda: 34.3 GB, 34359738368 bytes
255 heads, 63 sectors/track, 4177 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        4177    33447330   8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table</pre>
<p>2) You can see that /dev/sdb (our second hard drive) does not have any partitions. We will need to create a partition(s) on the drive and then make a file system on it, then mount it. Let&#8217;s write partitions to the drive using <code>fdisk /dev/sdb</code>:</p>
<pre>[03:53:01] [root@virt ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help):</pre>
<p>3) As you can see from the help menu (by using the command &#8220;m&#8221;) we want to add a new partition. Using the defaults will use the entire disk. After it&#8217;s created, you will want to use the command &#8220;w&#8221; to &#8220;write table to disk and exit&#8221;.</p>
<pre>Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044): 
Using default value 1044

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[03:54:58] [root@virt ~]#</pre>
<p>4) Now you will notice that the output of <code>fdisk -l /dev/sdb</code> shows a partition as /dev/sdb1:</p>
<pre>[03:57:08] [root@virt ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1044     8385898+  83  Linux</pre>
<p>5) Now we need to create a file system on it. I&#8217;ve always used ext3 for general use/purposes. You&#8217;ll want to use the command <code>mkfs -t ext3 /dev/sdb1</code> as shown here:</p>
<pre>[03:58:38] [root@virt ~]# mkfs -t ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1048576 inodes, 2096474 blocks
104823 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2147483648
64 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.</pre>
<p>6) Great, now we have a single partitioned secondary drive using ext3 file system. Now you want to create a directory to mount it in; lets just use &#8220;/drive2&#8243;. You&#8217;ll need to use the command <code>mount -t [filesystem] [source] [mount directory]</code> to mount it.</p>
<pre>[03:59:50] [root@virt ~]# mount -t ext3 /dev/sdb1 /drive2/</pre>
<p>7) Now you&#8217;ll notice, via df, that the drive is mounted:</p>
<pre>[03:59:57] [root@virt ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       28G  1.4G   25G   6% /
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                1014M     0 1014M   0% /dev/shm
/dev/sdb1             7.9G  147M  7.4G   2% /drive2</pre>
<p>8) Last step &#8211; you want to make sure the drive automatically mounts itself when the server boots/reboots. You&#8217;ll need to add the following line to your <code>/etc/fstab</code> file:</p>
<pre>/dev/sdb1  /drive2  ext3  defaults 0 0</pre>
<p>.</p>
<p>All done!</p>
</div>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/adding-additional-disk-drives-to-centos-56/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Linux Server Sends Email Alert on Root Login</title>
		<link>https://www.nikeshshk.com.np/linux/get-linux-server-sends-email-alert-on-root-login/</link>
		<comments>https://www.nikeshshk.com.np/linux/get-linux-server-sends-email-alert-on-root-login/#comments</comments>
		<pubDate>Sat, 07 Jun 2014 05:04:30 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[email notification]]></category>
		<category><![CDATA[linux security]]></category>
		<category><![CDATA[secure server]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=674</guid>
		<description><![CDATA[This guide is to improve the security of the server, which is exposed to the Internet and possible to get hacked worldwide, it’s best to enable server to automatically send a notification email to predefined email address every time someone logs in as root to the host. To configure the automatic email alert notification to a default email address on each incident of root log on on the server, use the following guide. Login to the server via SSH using as root ID. Ensure that you’re at home directory of root. The open up the .bash_profile for editing using vi by typing one of the following commands at command shell line:vi .bash_profile Scroll down to the end of the file and add the following line: echo 'ALERT - Root Shell Access on:' `date` `who` &#124; mail -s "Alert: Root Access from `who &#124; cut -d"(" -f2 &#124; cut -d")" -f1`"user@nikeshshk.com.np Replace user@nikeshshk.com.np with the actual email account address that you want to&#160;<a href="https://www.nikeshshk.com.np/linux/get-linux-server-sends-email-alert-on-root-login/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>This guide is to improve the security of the server, which is exposed to the Internet and possible to get hacked worldwide, it’s best to enable server to automatically send a notification email to predefined email address every time someone logs in as root to the host. To configure the automatic email alert notification to a default email address on each incident of root log on on the server, use the following guide.</p>
<ol>
<li>Login to the server via SSH using as root ID.</li>
<li>Ensure that you’re at home directory of root. The open up the .bash_profile for editing using vi by typing one of the following commands at command shell line:vi .bash_profile</li>
<li>Scroll down to the end of the file and add the following line:
<pre><code>echo 'ALERT - Root Shell Access on:' `date` `who` | mail -s "Alert: Root Access from `who | cut -d"(" -f2 | cut -d")" -f1`"<em>user@nikeshshk.com.np</em>
</code></pre>
<p>Replace <em>user@nikeshshk.com.np</em> with the actual email account address that you want to the root access alert notification been sent to. Note that you can change the text contains in the email alert too. The text starting with first ALERT is written as email body, and you can add in other info such as host name or change the wordings. The second Alert is the email title which you can change to your own too.</li>
</ol>
<p>Now logout and login again as root, you should receive an email alert at your inbox. The security trick should works on most popular flavor of Linux such as RedHat, CentOS, Ubuntu, FreeBSD and etc.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/linux/get-linux-server-sends-email-alert-on-root-login/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Duplicate Rows from a Table in SQL Server</title>
		<link>https://www.nikeshshk.com.np/news/remove-duplicate-rows-from-a-table-in-sql-server/</link>
		<comments>https://www.nikeshshk.com.np/news/remove-duplicate-rows-from-a-table-in-sql-server/#comments</comments>
		<pubDate>Mon, 21 Apr 2014 08:01:54 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Database Administration]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[remove duplicates]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[sqlserver]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=670</guid>
		<description><![CDATA[Firstly, we will create a table, where we will insert some duplicate rows to understand the topic properly. Create a table called ATTENDANCE by using the following code: CREATE TABLE [dbo].[ATTENDANCE]( [EMPLOYEE_ID] [varchar](50) NOT NULL, [ATTENDANCE_DATE] [date] NOT NULL ) ON [PRIMARY] Now insert some data into this table. INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A001',CONVERT(DATETIME,'01-01-11',5)) INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A001',CONVERT(DATETIME,'01-01-11',5)) INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A002',CONVERT(DATETIME,'01-01-11',5)) INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A002',CONVERT(DATETIME,'01-01-11',5)) INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A002',CONVERT(DATETIME,'01-01-11',5)) INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES ('A003',CONVERT(DATETIME,'01-01-11',5)) After inserting the data, check the data of the below table. If we grouped the employee_id and attendance_date, then A001 and A002 become duplicates. EMPLOYEE_ID ATTENDANCE_DATE A001 2011-01-01 A001 2011-01-01 A002 2011-01-01 A002 2011-01-01 A002 2011-01-01 A003 2011-01-01 So how can we delete those duplicate data? Solution First, insert an identity column in that table by using the following code: ALTER TABLE dbo.ATTENDANCE ADD AUTOID INT IDENTITY(1,1) Now the table data will be like the following table: EMPLOYEE_ID ATTENDANCE_DATE AUTOID A001&#160;<a href="https://www.nikeshshk.com.np/news/remove-duplicate-rows-from-a-table-in-sql-server/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>Firstly, we will create a table, where we will insert some duplicate rows to understand the topic properly. Create a table called ATTENDANCE by using the following code:</p>
<p><code>CREATE TABLE [dbo].[ATTENDANCE](<br />
[EMPLOYEE_ID] [varchar](50) NOT NULL,<br />
[ATTENDANCE_DATE] [date] NOT NULL<br />
) ON [PRIMARY] </code></p>
<p>Now insert some data into this table.</p>
<p><code>INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A001',CONVERT(DATETIME,'01-01-11',5))<br />
INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A001',CONVERT(DATETIME,'01-01-11',5))<br />
INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A002',CONVERT(DATETIME,'01-01-11',5))<br />
INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A002',CONVERT(DATETIME,'01-01-11',5))<br />
INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A002',CONVERT(DATETIME,'01-01-11',5))<br />
INSERT INTO dbo.ATTENDANCE (EMPLOYEE_ID,ATTENDANCE_DATE)VALUES<br />
('A003',CONVERT(DATETIME,'01-01-11',5)) </code></p>
<p>After inserting the data, check the data of the below table. If we grouped the employee_id and attendance_date, then A001 and A002 become duplicates.<br />
EMPLOYEE_ID ATTENDANCE_DATE<br />
A001 2011-01-01<br />
A001 2011-01-01<br />
A002 2011-01-01<br />
A002 2011-01-01<br />
A002 2011-01-01<br />
A003 2011-01-01</p>
<p>So how can we delete those duplicate data?<br />
Solution</p>
<p>First, insert an identity column in that table by using the following code:</p>
<p><code>ALTER TABLE dbo.ATTENDANCE ADD AUTOID INT IDENTITY(1,1) </code></p>
<p>Now the table data will be like the following table:<br />
EMPLOYEE_ID ATTENDANCE_DATE AUTOID<br />
A001 2011-01-01 1<br />
A001 2011-01-01 2<br />
A002 2011-01-01 3<br />
A002 2011-01-01 4<br />
A002 2011-01-01 5<br />
A003 2011-01-01 6</p>
<p>Check the AUTOID column. Now we will start playing the game with this column.</p>
<p>Now use the following code to find out the duplicate rows that exist in the table.</p>
<p><code>SELECT * FROM dbo.ATTENDANCE WHERE AUTOID NOT IN (SELECT MIN(AUTOID) FROM dbo.ATTENDANCE GROUP BY EMPLOYEE_ID,ATTENDANCE_DATE)</code></p>
<p>The above code will give us the following result:<br />
EMPLOYEE_ID ATTENDANCE_DATE AUTOID<br />
A001 2011-01-01 2<br />
A002 2011-01-01 4<br />
A002 2011-01-01 5</p>
<p>Ultimately, these are the duplicate rows which we want to delete to resolve the issue. Use the following code to resolve it.</p>
<p><code>DELETE FROM dbo.ATTENDANCE WHERE AUTOID NOT IN (SELECT MIN(AUTOID) FROM dbo.ATTENDANCE GROUP BY EMPLOYEE_ID,ATTENDANCE_DATE) </code></p>
<p>Now check the data. No duplicate rows exist in the table.</p>
<p>Is it too complicated? I dont think so <img src="https://www.nikeshshk.com.np/wp-includes/images/smilies/simple-smile.png" alt=":)" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/remove-duplicate-rows-from-a-table-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ever been Hacked and now you can&#8217;t delete the file&#8230;Operation not permitted</title>
		<link>https://www.nikeshshk.com.np/news/ever-been-hacked-and-now-you-cant-delete-the-file-operation-not-permitted/</link>
		<comments>https://www.nikeshshk.com.np/news/ever-been-hacked-and-now-you-cant-delete-the-file-operation-not-permitted/#comments</comments>
		<pubDate>Wed, 16 Apr 2014 16:40:48 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[hack]]></category>
		<category><![CDATA[lsattr]]></category>
		<category><![CDATA[problem removing files]]></category>
		<category><![CDATA[remove file linux]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=664</guid>
		<description><![CDATA[You can check the file and ownership permissions as well as if the file is set to immutable with these commands in root SSH: ls -lah /home/username/public_html/pathtofile lsattr /home/username/public_html/pathtofile The first command will show the file and ownership permissions. If they are 000 or root:root, the root user should still be able to remove the file regardless with this command: cd /home/username/public_html/pathtofolder rm filename People can really get into trouble by running rm commands without ensuring they are at the correct directory path for the removal. Next, the &#8220;lsattr&#8221; command above, the second one, will show if there are any attributes set on the file. If you see a -i on the lsattr command, then run this command to unset that attribute: chattr -i /home/username/public_html/pathtofile This will remove that immutable file attribute. What immutable does would be preventing changing and removing a file. If the file has that set on it, even the root user cannot remove the file and&#160;<a href="https://www.nikeshshk.com.np/news/ever-been-hacked-and-now-you-cant-delete-the-file-operation-not-permitted/" class="read-more">Continue Reading</a>]]></description>
				<content:encoded><![CDATA[<p>You can check the file and ownership permissions as well as if the file is set to immutable with these commands in root SSH:</p>
<p><code>ls -lah /home/username/public_html/pathtofile<br />
lsattr /home/username/public_html/pathtofile<br />
</code></p>
<p>The first command will show the file and ownership permissions. If they are 000 or root:root, the root user should still be able to remove the file regardless with this command:</p>
<p><code>cd /home/username/public_html/pathtofolder<br />
rm filename</code></p>
<p>People can really get into trouble by running rm commands without ensuring they are at the correct directory path for the removal.</p>
<p>Next, the &#8220;lsattr&#8221; command above, the second one, will show if there are any attributes set on the file. If you see a -i on the lsattr command, then run this command to unset that attribute:</p>
<p><code>chattr -i /home/username/public_html/pathtofile</code></p>
<p>This will remove that immutable file attribute. What immutable does would be preventing changing and removing a file. If the file has that set on it, even the root user cannot remove the file and this is my suspicion on what might be happening if you haven&#8217;t been able to remove it even as the root user in root SSH.</p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/ever-been-hacked-and-now-you-cant-delete-the-file-operation-not-permitted/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Find and Change File Permissions Recursively, Linux / UNIX</title>
		<link>https://www.nikeshshk.com.np/news/find-and-change-file-permissions-recursively-linux-unix/</link>
		<comments>https://www.nikeshshk.com.np/news/find-and-change-file-permissions-recursively-linux-unix/#comments</comments>
		<pubDate>Fri, 10 Jan 2014 06:20:12 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=624</guid>
		<description><![CDATA[To find all files in /home/user/demo directory, enter: $ find /home/user/demo -type f -print To find all files in /home/user/demo directory with permission 777, enter: $ find /home/user/demo -type f -perm 777 -print Finally, apply new permission using the -exec option as follows: $ find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \; To select directories and subdirectories use the following syntax: $ find /home/user/demo -type d -perm 777 -print -exec chmod 755 {} \;]]></description>
				<content:encoded><![CDATA[<p>To find all files in /home/user/demo directory, enter:</p>
<p><code>$ find /home/user/demo -type f -print</code></p>
<p>To find all files in /home/user/demo directory with permission 777, enter:</p>
<p><code>$ find /home/user/demo -type f -perm 777 -print<br />
</code><br />
Finally, apply new permission using the -exec option as follows:</p>
<p><code>$ find /home/user/demo -type f -perm 777 -print -exec chmod 755 {} \;</code></p>
<p>To select directories and subdirectories use the following syntax:</p>
<p><code>$ find /home/user/demo -type d -perm 777 -print -exec chmod 755 {} \;</code></p>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/find-and-change-file-permissions-recursively-linux-unix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>windows script to run after a specific time</title>
		<link>https://www.nikeshshk.com.np/news/windows-script-to-run-after-a-specific-time/</link>
		<comments>https://www.nikeshshk.com.np/news/windows-script-to-run-after-a-specific-time/#comments</comments>
		<pubDate>Mon, 23 Dec 2013 14:37:49 +0000</pubDate>
		<dc:creator><![CDATA[Nikesh Shakya]]></dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.nikeshshk.com.np/?p=612</guid>
		<description><![CDATA[windows script to run after a specific time using timeout @echo off command1 REM wait for 10 seconds before executing command2 timeout /t 10 command2]]></description>
				<content:encoded><![CDATA[<p>windows script to run after a specific time using timeout</p>
<pre><code>@echo off

command1
REM wait for 10 seconds before executing command2
timeout /t 10
command2</code></pre>
]]></content:encoded>
			<wfw:commentRss>https://www.nikeshshk.com.np/news/windows-script-to-run-after-a-specific-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
