linux history command with timestamps

Config output format in HISTTIMEFORMAT with below command:

echo ‘export HISTTIMEFORMAT=”%d-%m-%y  %T” ‘  >> ~/.bash_profile; bash

then history to see the different

To make the changes permanent follow the below steps,

you need to add the below line to .bashrc file and then save it,

run the below command to source .bashrc file,

 

Reference:

http://askubuntu.com/questions/391082/how-to-see-time-stamps-in-bash-history

 

Nginx resolve 403 forbidden error

When configuration virtual host in nginx with below configuration file.

virtual host configuration for php.sandbox
virtual host configuration for php.sandbox

Might be, you will have trouble with 403 forbidden error:

nginx virtual host 403
nginx virtual host 403

it could be caused by selinux, just check selinux audit logs with the command:

sudo ausearch -m avc –start recent | grep httpd or sudo ausearch -m avc –start recent | grep httpd or
sudo ausearch -m avc –start recent | grep nginx
sudo ausearch -m avc –start recent | grep nginx

selinux audit for nginx user
selinux audit for nginx user

The solution is that let selinux allow httpd user to read user content by the command

setsebool -P httpd_read_user_content 1
also remember chmod 755 for virtual host directory
#eg chmod 755 /home/longnguyen/php-workspace/

Good luck 😉

Finding all files containing a text string on linux

I faced with the issue that how to find all files containing a text string on linux

Just t do the following steps (I copy and paste from stackoverflow.com)

-r is recursive, -n is line number and -w stands match the whole word. Along with these, –exclude or –include parameter could be used for efficient searching. Something like below:

This will only search through the files which have .c or .h extensions. Similarly a sample use of –exclude:

Above will exclude searching all the files ending with .o extension. Just like exclude file it’s possible to exclude/include directories through –exclude-dir and –include-dir parameter, the following shows how to integrate –exclude-dir:

This works well for me.

References:
http://stackoverflow.com/questions/16956810/finding-all-files-containing-a-text-string-on-linux http://www-users.york.ac.uk/~mijp1/teaching/2nd_year_Comp_Lab/guides/grep_awk_sed.pdf ( useful tutorial about grep awk and sed command line)

PPTP Setup on Fedora 21 (kernel 3.19.3-200.fc21.x86_64)

I have just updated my laptop to fedora 21 OS.
And had faced with the problem when trying to connect my office VPN (via point to point tunneling protocol – PPTP) with this error message “connection process ends with timeout”.
If you have the same issue, type command below :

if you want to load nf_conntrack_pptp module automatically when your lap start up, type these commands:

You should change nf_conntrack_pptp.conf permisson to 771 if you have file permission error with the second command.

Reference link:
https://support.hidemyass.com/hc/en-us/articles/202721566-PPTP-Setup-on-Fedora
https://bugzilla.redhat.com/show_bug.cgi?id=1187328