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
07-14.txt a.txt b.txt d.txt
usr100@dev01:/tmp/user$ cat ~/.bash_history
rm -i d.txt
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 mywebsite.com -t 60 -w 55)
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
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
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
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.
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…
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…