How to send an email using a single command?
Answer:
# echo World | mail -s Hello [email protected]
If you would like to specify the from email address, you can use
# echo World | mail -aFrom:[email protected] -s Hello [email protected]
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to send an email using a single command?
Answer:
# echo World | mail -s Hello [email protected]
If you would like to specify the from email address, you can use
# echo World | mail -aFrom:[email protected] -s Hello [email protected]
How to create a dummy file with a given size in Linux?
Answer:
Use the dd command
Example:
dd if=/dev/zero of=test.txt bs=1 count=1MB
The above command will create a 1MB dummy file and stored as test.txt
How to avoid SQL injection in PHP?
Answer:
The easiest method is to use the mysql_real_escape_string function
Example:
$query = sprintf("SELECT * FROM users WHERE user='%s' AND password='%s'",
mysql_real_escape_string($user),
mysql_real_escape_string($password));
Reference: http://php.net/manual/en/function.mysql-real-escape-string.php
How to disable a service from startup in Ubuntu?
Answer:
For example, to turn off apache2 from startup, use
sudo update-rc.d -f apache2 remove
When the system restart, apache2 will not be running anymore.
But, if you want to add them back later, you can use
sudo update-rc.d -f apache2 defaults
How to hide images request in my Apache's log?
Answer:
Open the Apache config, e.g. vi httpd.conf
Add the following lines around the log configurations, e.g.
...
SetEnvIfNoCase Request_URI "\.gif$|\.png$|\.jpg$" DONT_LOG
CustomLog access.log common env=!DONT_LOG
...