Remove Apache Headers
For me it's really wrong to show everyone which version of apache you have installed and other informations, many crackers can use this info to make attacks to your web server, so it's will not be bad to hide them, this is really easy all you must to do is open httpd.conf file with vi command "vi httpd.conf" and find "ServerSignature On" replace On with OFF at next line add "ServerTokens Prod", thats all restart apache server and enjoy your server version will not be available not in headers nor in error pages.
How to Emulate a Remote Linux Desktop From Windows
It's really easy to control linux OS from windows by using remote desktop. all what you need is several free software and done. first of all you must download SSH client I recommend Putty its free and really nice soft you can download it from here "http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html" second step is to login with SSH as root and install VNC server with cent os you can do this with this command "yum install vnc-server" also you must recheck that you have installed Gnome Desktop this is important if you don't have you must install it too " yum groupinstall "GNOME Desktop Environment" " you also can use KDE&XFCE, now edit xstartup file "vi ~/.vnc/xstartup" it must be like this one and plus -Find the section where it says twm & and replace it with your choice. I know there are more, but these seem to be the most popular ones. Don't include what I have in the parenthesis
-startkde & (used for the KDE window manager)
-exec gnome-session & (used for the Gnome window manager)
-startxfce4 & (used for the XFCE4 window manager, my favorite choice)
Batch Image Resize on Linux
You can easily resize any images in your directory or entry server with help of ImageMagick Libraries if you don't have it you can easily install it by this commands
Ubuntu - sudo apt-get install imagemagick
CentOs - yum install ImageMagick
ok if you installed it, you can use "mogrify" command to resize your images for example if you want to resize all images with jpg extension in directory use this command
mogrify -resize 800×600! *.jpg
this means that all images with extension .jpg will be resized at 800x600, you can change jpg to any image extension you want to resize such as png, gif.......
How do I Compress a Whole Linux or UNIX Directory?
Q. How can I compress a whole directory under Linux / UNIX using a shell prompt?
A. It is very easy to compress a Whole Linux/UNIX directory. It is useful to backup files, email all files, or even to send software you have created to friends. Technically, it is called as a compressed archive. GNU tar command is best for this work. It can be use on remote Linux or UNIX server. It does two things for you:
=> Create the archive
=> Compress the archive
You need to use tar command as follows (syntax of tar command):
tar -zcvf archive-name.tar.gz directory-name
Where,
- -z: Compress archive using gzip program
- -c: Create archive
- -v: Verbose i.e display progress while creating archive
- -f: Archive File name
For example, you have directory called /home/jerry/prog and you would like to compress this directory then you can type tar command as follows:
$ tar -zcvf prog-1-jan-2005.tar.gz /home/jerry/prog
Above command will create an archive file called prog-1-jan-2005.tar.gz in current directory. If you wish to restore your archive then you need to use following command (it will extract all files in current directory):
$ tar -zxvf prog-1-jan-2005.tar.gz
Where,
- -x: Extract files
If you wish to extract files in particular directory, for example in /tmp then you need to use following command:
$ tar -zxvf prog-1-jan-2005.tar.gz -C /tmp
$ cd /tmp
$ ls -
MySQL Tutorial – Import or Export A Database
This tutorial section deals with mysqldump which is a tool to import and export MySQL databases.
It can be used to back up a database or to move database information from one server to another.
1. Export A MySQL Database
This example shows you how to export a database. It is a good idea to export your data often as a backup.
|
Replace username, password and database_name with your MySQL username, password and database name.
File FILE.sql now holds a backup of your database, download it to your computer.
2. Import A MySQL Database
Here, we import a database. Use this to restore data from a backup or to import from another MySQL server.
Start by uploading the FILE.sql file to the server where you will be running this command.
|
Replace the parts in red with your own information.
This powerful, easy to use command has many uses. Let's say you wanted to switch web hosting providers.
Simply export your data on the old provider's server and import it on your account with the new host.
How To Copy Files In Linux
To copy files, you use the cp command. The following will copy file to file2. Note that if file2 doesn't exist, it'll be created, but if it exists, it'll be overwritten:
$ cp file file2
There aren't any undo commands in the Linux CLI, so accidentally overwriting an important file would probably make you pull your head off. The risk of doing so is smaller if you use the -i option ("interactive") with cp. The following does the same as the above, but if file2 exists, you'll be prompted before overwriting:
$ cp -i file file2
cp: overwrite `file2'? n
$
So it's a good idea to use the -i option whenever you're dealing with important files you don't want to lose!
If you want to copy file into directory dir1:
$ cp file dir1
The following would do the same as the above, copy file into dir1, but under a different name:
$ cp file dir1/file2
You can also copy multiple files into one directory with a single command:
$ cp file1 file2 file3 dir1
If you want to copy all files to dir2 you can use this command:
$ cp *.* dir2
This command will copy only .txt files to dir2:
$ cp *.txt dir2
Note that if the last argument isn't a directory name, you'll get an error message complaining about it.
Upgrade To PHP 5.2.x on CentOS/RHEL/Fedora
If you want to upgrade php automatically on your dedicated server or VPS, you can easily do this with this method, first of all write this command
wget -q -O - http://www.atomicorp.com/installers/atomic.sh | sh
then
yum update
if you are updating from php 4 type this to replace the PHP 4 php.ini with PHP 5.2.x's
mv /etc/php.ini.rpmnew /etc/php.ini
now type this to replace the php.conf with the PHP 5.2.x php.conf
mv /etc/httpd/conf.d/php.conf.rpmnew /etc/httpd/conf.d/php.conf
now restart your webserver
service httpd restart
(or)
/etc/init.d/httpd restart
Open Alternative SMTP Port with Postfix
Many ISP(Internet Service Provider) are blocking 25 port which is used to send emails from email clients like The Bat, Outlook, Thunderbird .etc, so what you must do if you want to use some email client, this is very simple, login as root, go to your postfix directory by default this is " etc/postfix " you must edit " master.cf " you can use this command " vi master.cf ", click " i " and add this
2525 inet n - n - - smtpd
which will open 2525 port, save changes and exit " :wq ", now you can use 2525 port to send emails.
Edit php.ini from ssh
First of all you must login as root, Then go to your php.ini category for example in etc category. type " ls " this will show that you are in right place, now type "vi php.ini " and by clicking " i " start editing what you want but be careful, then press " Esc " type ":" and " wq " to save file and exit. Restart your httpd and your done.
