Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, June 12, 2018

Find and delete files recursively in unix

recursively list files by extension
find ./ -type f | awk -F . '{print $NF}' | sort --unique
recursively list files by specific extension
find . -type f -iname "*.css" 

recursively delete them
find . -name "*.html" -type f -delete

Monday, March 12, 2012

Clock settings in gnome like windows


To see all the options: man date | less +/"FORMAT controls"

mine are like windows 7: %H:%M%n%d/%m/%Y

Sunday, March 04, 2012

Using PHP5-FPM With Apache2 On Ubuntu 11.10

http://www.howtoforge.com/using-php5-fpm-with-apache2-on-ubuntu-11.10



Could not reliably determine the server’s fully qualified domain name

sudo gedit /etc/apache2/httpd.conf

ServerName localhost
sudo /etc/init.d/apache2 restart

Thursday, March 01, 2012

Apache

How to redirect your website base on country ip request, Apache, geoip, rewrite

Install the mod-geoip

sudo apt-get install libapache2-mod-geoip

Enable the mods:

sudo a2enmod rewrite
sudo a2enmod geoip

In your file ".htaccess" add these lines:

# if country is PT
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^PT$
RewriteRule ^(.*)$ http://www.site.pt

# else
RewriteEngine on
RewriteRule ^(.*)$ http://www.site/en/

You have to configure the virtual host to read the .htaccess file.
<directory /var/www/site/>
 Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
</directory>


In your file "httpd.conf" add these lines:


GeoIPEnable On
GeoIPDBFile /usr/local/share/geoip/geoip.dat



Download the file from http://www.maxmind.com/app/geolitecountry and put it in /usr/local/share/geoip/geoip.dat

There are a lot of versions. This one is free for countries :)




Using mod_spdy With Apache2 On Ubuntu 12.04
from: http://www.howtoforge.com/using-mod_spdy-with-apache2-on-ubuntu-12.04

SPDY runs over HTTPS, so we need an HTTPS-enabled web site to test SPDY. Please note that SPDY will fall back to HTTPS if the user's browser does not support SPDY or if things go wrong, so installing mod_spdy doesn't hurt your existing setup.

a2enmod ssl
a2ensite default-ssl
/etc/init.d/apache2 restart

cd /tmp
wget https://dl-ssl.google.com/dl/linux/direct/mod-spdy-beta_current_amd64.deb
dpkg -i mod-spdy-*.deb
apt-get -f install
/etc/init.d/apache2 restart
chrome://net-internals/#spdy

Friday, January 27, 2012

Hide PHP on Apache and Apache itself

Hide PHP on Apache and Apache itself:

In httpd.conf
-------------
ServerName localhost
# ...
# Minimize 'Server' header information
ServerTokens Prod
# Disable server signature on server generated pages
ServerSignature Off
# ...
# Set default file type to PHP
DefaultType application/x-httpd-php
# ...

php.ini
------------
; ...
expose_php = Off
; ...

Sunday, January 22, 2012

How to install Eclipse 3.7 on Ubuntu 11.04


The Eclipse packages in Ubuntu are are very out of date. The latest version in the Ubuntu repos is 3.5.2 where as the latest version of Eclipse is 3.7. I’m posting this because Ubuntu 11.04 uses the new Unity desktop which uses overlay-scrollbars (scrolls bars that are hidden until you hover over them). For some reason Eclipse 5.3.2 doesn’t like to play nice with the overlay scrollbars, and I’d rather use the newest version anyways. With Eclipse, you can just download the tar.gz file from eclipse.org and run it no problem, but I like set things up in a cleaner fashion, so here’s how I did it.

1) Download Eclipse. I got eclipse-SDK-3.7-linux-gtk-x86_64.tar.gz
2) Extract it
tar zxvf eclipse-SDK-3.7.2-linux-gtk-x86_64.tar.gz
Or just be lazy and Right Click > Extract Here
3) Move to /opt/ folder
sudo mv -f eclipse /opt/
cd /opt/
sudo chown -R root:root eclipse
sudo chmod -R +r eclipse
4) Create an eclipse executable in your path
sudo touch /usr/bin/eclipse
sudo chmod 755 /usr/bin/eclipse
sudo nano /usr/bin/eclipse
copy this into nano
#!/bin/sh
#export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
export ECLIPSE_HOME="/opt/eclipse"

$ECLIPSE_HOME/eclipse $*
save the file (^O = Ctrl+o) and exit nano (^X = Ctrl+x)
5) Create a gnome menu item
sudo nano /usr/share/applications/eclipse.desktop
copy this into nano
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=eclipse
Icon=/opt/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=GNOME;Application;Development;
StartupNotify=true
save and exit nano
6) Launch Eclipse for the first time
/opt/eclipse/eclipse -clean &

7) The update Site
http://download.eclipse.org/releases/indigo/

Saturday, April 30, 2011

pear


if you have the following error:
PHP Fatal error:  Call to undefined method PEAR::raiseErro() in /usr/share/php/PEAR/REST.php on line 165
try this:
mkdir -p /tmp/pear/cache

Wednesday, April 20, 2011

Git from a SVN

git svn clone -rN  --username username svn://some/repo localreponame
Crie seu branch e mude pra ele:

git checkout -b branchname
Não altere o master branch diretamente, ele deve representar a repositório svn, sempre trabalhe nos branches. Você manda seu trabalho pro master apenas na hora de subir as alterações pro svn.

Com as alterações feitas e commitadas no seu branch, volte para o master e faça o merge:

git checkout master
git merge --squash minhas_paradas
Faça o commit pro git:

git commit -a -m "Funcionalidade tal implementada."
E agora pro svn:

git svn dcommit
E é isso. Pra manter o seu master branch atualizado em relação ao repositório svn use o rebase do git-svn:

git checkout master
git svn rebase
update from a svn
git svn fetch

Tuesday, January 25, 2011

Friday, November 05, 2010

Remote MySQL Access

GRANT ALL ON *.* TO root@192.168.1.1   IDENTIFIED BY 'palavra-pass'   WITH GRANT OPTION;
FLUSH PRIVILEGES;
We just have to tell Mysql to allow remote logins.
sudo vi /etc/mysql/my.cnf
Out-of-the-box, MySQL only allows connections from the localhost identified by the IP Address of 127.0.0.1.
We need to remove that restriction, so find the line that says
bind-address = 127.0.0.1


netstat -tupan | grep mysql

Recursively delete .svn directories

$ rm -rf 'find . -type d -name .svn'
or
find . -iname ".svn" -print0 | xargs -0 rm -r

systemd-timesyncd

sudo apt update && sudo apt install systemd-timesyncd && sudo systemctl enable --now systemd-timesyncd