Tuesday, April 26, 2016

Clear or Disable the Windows 7 Explorer Search History


The way you search for files and folder in Windows 7 is different from the way you do it in older versions of Windows like Windows XP where you used the search companion to help you find your files. Many people don't like the new feature and say it doesn't work as good as the older XP style of searching. That is up for debate and up to you to decide once you use the new Windows search method.
With Windows 7 you type your search word(s) in the search box in the upper right hand corner of Windows Explorer. Then you will notice a green status bar going across the top of the window as it searches. Finally your search results will be displayed in the main window along with other information such as the path to the file and so on. One thing you may have noticed that it keeps a history of your past searches and you may not want that search history to be kept. You may or may not want this history to be kept on your computer for whatever reason.
Windows 7 Search
If you want to clear the history of searched for items you will need to edit the registry. Always be careful when editing the registry since any changes are made instantly. It may be a good idea to export your registry first just in case you make a mistake which can be done from the File menu and then clicking on Export. To open the registry editor click on Start and then type in regedit in the search box and press Enter. Then navigate to
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\WordWheelQuery
Right click on WordWheelQuery and choose Delete and then you can close the Registry Editor. Now your search history will be deleted but any new searches will show up in the history again.
Registry Editor

If you want to disable the search history altogether then you can do so by using the Local Group Policy Editor which is used to define user and computer configurations for things such as policies, security options and software options etc. To open the Local Group Policy Editor, Click on Start and then type in gpedit.msc in the search box. Now navigate to
User Configuration\Administrative Templates\Windows Components\Windows Explorer
Then find the entry that says Turn off display of recent search entries in the Windows Explorer search box.
Local Group Policy Editor
Double click the entry and change the setting to Enabled and click OK. Now whenever you do a search in Windows explorer it will not keep your search history.

Wednesday, April 13, 2016

Configure Apache to enable cgi-bin user directories to run cgi, perl and python in UBUNTU

1. First enable cgi module using the below lines.
sudo a2enmod cgi
sudo service apache2 restart
After latest apache with cgi mod enabled. 
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

  Options +ExecCGI
  AddHandler cgi-script .cgi .pl .py
  Options FollowSymLinks
  Require all granted
3. Create CGI script CGI works with multiple languages, but for now we start with bash shell. We will show examples for some other languages later. Here is a simples version of the CGI bash example:
#!/bin/bash
echo "Content-type: text/html"
echo ''
echo 'CGI Bash Example'
Copy the above code and paste it to a new file in /usr/lib/cgi-bin/ called example-bash.sh. Once done make the file executable using thechmod command:
$ sudo chmod 755 /usr/lib/cgi-bin/example-bash.sh
4. View CGI script
All what remains is to navigate with your browser to host-name or IP address of your web server. In our case the URL will be: http://cgi-example.local/cgi-bin/example-bash.sh
CGI bash example
You can edit this example to display a disk usage of server's root partition "/". You are only limited by your imagination:
#!/bin/bash
echo "Content-type: text/html"
echo ''
echo 'CGI Bash example
'
echo `df -h / | grep -v Filesystem`
The above code will check for free disk space for a root partition and produce the following page:
CGI bash example 2

5. More CGI examples

As promised, here are more CGI examples for a few more programming languages to get you started.

5.1. Perl

Create and make executable the following /usr/lib/cgi-bin/example-perl.pl with a content:
#!/usr/bin/perl

print "Content-type: text/html\n\n";
print <

CGI Perl Example

CGI Perl Example

CGI Perl Example htmlcode

5.2. Python

Create and make executable the following /usr/lib/cgi-bin/example-python.py with a content:


CGI Python Example

CGI Python Example

CGI Python Example """

5.3. C

For C and C++ to work we will need to have a compiler installed. First, install compiler with:
$ sudo apt-get install build-essential
Once installed create a file example-c.c with the following code:
#include 
int main(void)
{
printf("Content-Type: text/plain \n\n");
printf("CGI C Example \n");
}
save the content of example-c.c file and compile it with the following command:
$ sudo gcc -o /usr/lib/cgi-bin/example-c example-c.c
now you should be able to access your C compiled CGI script with: http://cgi-example.local/cgi-bin/example-c

5.4. C++

For C and C++ to work we will need to have a compiler installed. First, install compiler with:
$ sudo apt-get install build-essential
Once installed create a file example-cpp.c with a following code:
#include 
using namespace std;

int main()
{
        cout << "content-type: text/html" << endl << endl;
        cout << "

CGI C++ example

" << endl; return 0; }
save the content of example-cpp.c file and compile it with the following command:
$ sudo g++ -o /usr/lib/cgi-bin/example-cpp example-cpp.c
now you should be able to access your C compiled CGI script with: http://cgi-example.local/cgi-bin/example-cpp

6. Conclusion

As mentioned earlier the CGI is quite old and was largely superseded by different programing languages such as PHP, etc. However, as you can see, it is still relatively simple tool to use to automate your Linux administration tasks such as a remote custom monitoring for your Linux servers using a web browser.

https://www.youtube.com/watch?v=ELFdP7eEZ5w