find . -name ‘*.*’ | xargs grep -l ’search term’
UPDATE
The gentlemen who replied below is correct in stating that the command below would be easier.
grep -ril 'search_term' *
find . -name ‘*.*’ | xargs grep -l ’search term’
UPDATE
The gentlemen who replied below is correct in stating that the command below would be easier.
grep -ril 'search_term' *
In debian execute this shell command apt-get install imagemagick
Now to resize images execute convert -size 125×125 /path/to/image.jpg -resize 125×125 /path/to/image.jpg
Ofcourse you can do this in php by executing the shell command using the exec() function.
Well I’ve put enough time and effort into my server configuration, mysql databases, and my web dev files that it was finally time to start backing up. Now I’m not completely crazy, the server does have a 3ware card in it for mirroring, but in the end its still a server in the closet (its not gay) and something bad could happen. So I spent about 2 hours writing a few backup scripts because I’m too poor for rsync and too lazy for amanda.
All you need is a cheap web host like the one I use (about $5 a month) and some time. Here’s what I did:
Well I’ve been running debian sarge with the 2.4 kernel for a long time and things came to ahead when I was unable to install some pecl and pear packages for some neat stuff I’m doing in PHP. I have a tendency to make drastic decisions. In geekdom upgrading your server to not only a new linux version about the kernel as well in one night is considered drastic…I think. I have lots of important stuff on there too, client files, mysql databases, lots of web content in /var/www and not to mention the countless hours, weeks worth of hours I’ve spent fine tuning it.
I’ve known for a while that there is a way to set the default group ownership and rwx permissions of files in a directory, but I’ve been content with changing files permission levels on an as needed basis until today.
To set the default file permissions in a directory:
umask 775 /path/to/dir
To set the default group ownership:
chmod g+s /path/to/dir
Here is a good article on file permissions in linux: http://www.linuxforums.org/security/file_permissions.html
So I needed to setup automated backups poor man style. Since I’m most proficient in PHP I created several PHP scripts that tar, gzip, and ftp my important files to a remote server. I then automated this by adding each script as a cron job to be run every sunday early in the morning. Here’s the crontab syntax:
* * * * * command to be executed - - - - - | | | | | | | | | ----- Day of week (0 - 7) (Sunday=0 or 7) | | | ------- Month (1 - 12) | | --------- Day of month (1 - 31) | ----------- Hour (0 - 23) ------------- Minute (0 - 59)
To edit your cronjobs type crontab -e
Here is a mock example:
15 3 * * 7 /home/root/backupmymusic.php 15 4 * * 7 /home/root/backupmyimages.php
I needed to setup SSL to increase login security for various web apps I’m running on my server. Luckily I found a good tutorial here. Here’s the process in a nutshell:
Log rotate recently rotated my logs a little to early so now webalizer is only displaying statistics for the last two days. After changing logrotat to run once a month instead of weekly I wanted to “repair” my apache log files. I always forget how to use the cat command so it became the perfect candidate for a quick article.
file1 – beginning text.
file2 – end text.
cat file1 file2 > newfile
You don’t have to create a new file. You can just append file1 to file2, but I chose this method just incase I messed something up. Here’s exactly what I did: cat access.log.1 access.log > test and once I verified the test file looked good I did a mv test access.log so now I have one giant log file. I then forced webalizer to run and everything looks good now. Since I’m on it, I actually had to copy access.log to access.log.1 to finally get webalizer to see everything I wanted. I forced webalizer to run by executing the /usr/bin/webalizer command on my debian system.
It’s been a while since I added anything so here I go. If you have access to execute shell commands and curl is installed on your linux box then this is by far the easiest way to perform an HTTP POST. Here is the simple code:
exec("curl -d \"poststring=true&easy=yes\" http://www.somedomain.com");
Of course you can jazz this up by turning the post string into a variable a long with the url you are posting to. If you add a second parameter to the exec function such as $result then you can easily get a response from the host you are posting too. I came up with this simple method while working on a project at work. I was having problems getting PHPs built-in curl functionality to work, so this was the next best thing or better.
I often forget how to get the OS type and service type’s of remote servers. Here are a few commands that are quick, easy, and effective.
If curl is installed you can execute curl –head http://www.example.com to return web server and OS information. Note there are two dashes in front of head.
If nmap is installed nmap -p 80 -sV http://www.example.com will return the same information as above. The added benefit of using nmap is that you can change the port number parameter in front of -p to anything (25 for smtp, 21 for ftp, etc).