Tips, Tricks, Guides

How to display the history of commands executed by the user?

Linux: History command

Each bash sessions stores the history of commands executed in .bash_history file which in turn in stored under each user’s home directory

usr100@dev01:/tmp/user$ ls
07-14.txt a.txt b.txt d.txt

usr100@dev01:/tmp/user$ cat ~/.bash_history
su root
rm -i d.txt
ls -ltr
touch c.txt


Nagios: Temporary failure in name resolution

Troubleshooting the above warning message in Nagios:

i) If you can specify the IP address of the host with its port number try specifying it that way instead of the host name

ii) Check the the time that is set for the http check parameter and based on it try setting the -w (warning message) parameter (sample setting: command_line /usr/lib/nagios/plugins/check_http -H -t 60 -w 55)


How to restrict folder, file permission settings for each user?

Sticky bit

There may be situation where you wanted all users to store files in a certain folder but might want to restrict users from deleting other users file. For this scenario, you can set the sticky bit of the folder which will serve our purpose.

For example we have created a folder inside /tmp directory called “user”

root@dev:/tmp# ls -l | tail -1
drwxr-xrwx 2 root root 4096 2009-07-13 11:39 user
root@dev:/tmp# cd user

Now create a file called a.txt (you are currently with root privileges)
root@dev:/tmp/user# touch a.txt

Now change to the user with normal privileges (i have created a user called ‘usr100’ for this purpose)
usr100@dev:/tmp/user$ su usr100
usr100@dev:/tmp/user$ whoami
Continue Reading…


How to find the environment settings in Linux?

The following command will give you the environment settings in Linux

$ env

This is equivalent of PATH in windows.


PHP Image Upload and Security

List of steps to take care when using PHP to upload images or documents

i) use is_uploaded() function to check if the file is uploaded before moving the file from temporary location

ii) sanitize the name of the file before moving the file from the temporary location by executing the ‘mv’ system command (use escapeshellargs, escapeshellcmd as needed)

iii) chmod the file setting to 644 if needed

iv) the directory from where the file will be moved and the destination directory should be initialized beforehand in order to prevent users from altering the path where the files could be stored


Linux: Umask file, directory permission settings

What is umask?
The command umask is used to set the file, directory permissions.

In linux, you can set the file or directory permission for all users by editing /etc/profile (or in /etc/bashrc) file or for specific users by editing their respective ~/.bashrc file.

For files, the default permission settings are 0666 (execute permission is disabled) and for directories it is 0777

To produce symbolic output, you can use umask with -s option
$ umask -s

Continue Reading…


JQuery: Showing a progress image while processing background task

I thought to write a simple example to show a progress bar or a gif image showing a that a task is happening at the background using a jquery function.

i) Include jquery script file in the header section and the following code in the head

<script language="javascript">
    $("#main a.bgdiv").click(function(){
        return false;

Continue Reading…


Strange character sequence when parsing XML

When XML files are read from RSS feeds or from other sources, it is necessary that they both use the same standard encoding. When there is a conflict, strange characters like ‘, ’ gets shown on the browsers.

In RSS feeds, UTF-8 is the standard encoding scheme that is used and if a browser using ISO-8859-1 tries to read and display the data from the feed then these characters get passed on to the display.

To avoid having this strange characters displyed on screen (where ISO-8859-1 encoding is used), PHP’s iconv function comes in handy and you can use it like

echo iconv(“UTF-8″,”ISO-8859-1//TRANSLIT”, $temp_item[‘encoded’]);

and this will remove those characters and replace it with the nearest possible character during its tranliteration.


Transfer larger files in email – zip, split, unzip

How to transfer mysql backup files across network or emails?

Say for example, you generate a mysql dump called “mysql.dump” from your database the size of which is beyond the file transferable limit of your email account. The following steps will help you in making the file transfer possible Continue Reading…


YUI Compressor to compress css javascript

Download the YUI (Yahoo User Interface) Compressor which compresses javascript and css files hence making the file size smaller and execution speed faster.

Download location:

It is very simple to use this application to compress the files. All you need to have is a java installation in your machine. Continue Reading…

Kurinchi Calendar
September 2018
« Oct