linux poison RSS
linux poison Email
0

Recover MySQL database root password

You can recover MySQL database server password with following five easy steps.

Step # 1: Stop the MySQL server process.

Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password

Step # 3: Connect to mysql server as the root user

Step # 4: Setup new root password

Step # 5: Exit and restart MySQL server

Here are commands you need to type for each step (login as the root user):

Step # 1 : Stop mysql service

# /etc/init.d/mysql stop

Stopping MySQL database server: mysqld.

Step # 2: Start to MySQL server w/o password

# mysqld_safe –skip-grant-tables &

[1] 5988

Starting mysqld daemon with databases from /var/lib/mysql

mysqld_safe[6025]: started

Step # 3: Connect to mysql server using mysql client

# mysql -u root

Output:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-logType ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql>

Step # 4: Setup new MySQL root user password

mysql> use mysql;

mysql> update user set password=PASSWORD(”NEW-ROOT-PASSWORD“) where User=’root’;

mysql> flush privileges;

mysql> quit

Step # 5: Stop MySQL Server:

# /etc/init.d/mysql stop

Stopping MySQL database server: mysqld STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
.
[1]+ Done mysqld_safe –skip-grant-tables

Step # 6: Start MySQL server and test it

# /etc/init.d/mysql start

# mysql -u root -p
Read more
0

BackUp and Restore MBR after Windows messes it up

Just another note about restoring the boot loader for dual boot systems, after Windows messes it up. In Linux, the “dd” command can read and write to/from raw disks and files. If you have a floppy drive, creating a boot disk is as simple as putting a floppy in the drive and typing this:

[You need to use "root" account to do following]

# dd if=/dev/hda of=/dev/fd0 bs=512 count=1

This makes an exact copy of the MBR of the first hard drive (hda - you need to replace this), copying it to a floppy disk. You can boot directly from this floppy, and see your old boot menu. You can restore it by switching the “if=” and “of=” (input file, output file) parameters.

If you don’t have a floppy drive, you can back it up to a file with this:

# dd if=/dev/hda of=/home/nik/boot.mbr bs=512 count=1

Then you can boot into a CD-ROM distribution such as Knoppix, or often use your Linux distribution’s installation CD to boot into rescue mode and restore it with:

# dd if=/mnt/hda5/nik/boot.mbr of=/dev/hda bs=512 count=1

(you’ll need to find and mount the partition containing the directory where you backed up the MBR).
Read more
0

How to use rsysnc to keep files in Sync Between Servers

Suppose remote computer is “192.168.1.171″ and has the account “don”. You want
to “keep in sync” the files under “/home/Logs” on the remote computer with files on “/home/nikesh/Server” on the local computer.

$ rsync -Lae ssh don@192.168.1.171:/home/Logs /home/nikesh/Server

“rsync” is a convient command for keeping files in sync, and as shown above, it will work
through ssh. The -L option tells rsync to treat symbolic links like ordinary files.

Also see [http://www.rsnapshot.org/]
Read more
0

Sync Samba and Unix password

The pam_smbpass PAM module can be used to sync users’ Samba passwords with their system passwords. If a user invokes the passwd command, the password he uses to log in to the system as well as the password he must provide to connect to a Samba share are changed.

To enable this feature, add the following line to /etc/pam.d/system-auth below the pam_cracklib.so invocation:

password required /lib/security/pam_smbpass.so nullok use_authtok try_first_pass

Read more
0

Quick Apache configuration tips

Enable Directory Browsing
Options +Indexes

## block a few types of files from showing
IndexIgnore *.wmv *.mp4 *.avi

Disable Directory Browsing
Options All -Indexes

Customize Error Messages
ErrorDocument 403 /forbidden.html
ErrorDocument 404 /notfound.html
ErrorDocument 500 /servererror.html

Get SSI working with HTML/SHTML
AddType text/html .html
AddType text/html .shtml
AddHandler server-parsed .html
AddHandler server-parsed .shtml
# AddHandler server-parsed .htm

Change Default Page (order is followed!)
DirectoryIndex myhome.htm index.htm index.php

Block Users from accessing the site
order deny,allow
deny from 202.54.122.33
deny from 8.70.44.53
deny from .spammers.com
allow from all

Allow only LAN users
order deny,allow
deny from all
allow from 192.168.0.0/24

Redirect Visitors to New Page/Directory
Redirect oldpage.html http://www.domainname.com/newpage.html
Redirect /olddir http://www.domainname.com/newdir/

Block site from specific referrers
RewriteEngine on
RewriteCond %{HTTP_REFERER} site-to-block\.com [NC]
RewriteCond %{HTTP_REFERER} site-to-block-2\.com [NC]
RewriteRule .* - [F]

Block Hot Linking/Bandwidth hogging
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$RewriteCond %{HTTP_REFERER} !^http://(www\.)?mydomain.com/.*$ [NC]
RewriteRule \.(gif|jpg)$ - [F]

Want to show a “Stealing is Bad” message too?
Add this below the Hot Link Blocking code:
RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]

Stop .htaccess (or any other file) from being viewed
order allow,deny
deny from all

Avoid the 500 Error
# Avoid 500 error by passing charset
AddDefaultCharset utf-8

Grant CGI Access in a directory
Options +ExecCGI
AddHandler cgi-script cgi pl# To enable all scripts in a directory use the following#
SetHandler cgi-script

Change Script Extensions
AddType application/x-httpd-php .gne
gne will now be treated as PHP files! Similarly, x-httpd-cgi for CGI files, etc.

Use MD5 Digests
Performance may take a hit but if thats not a problem, this is a nice option to turn on.
ContentDigest On

Save Bandwidth
# Only if you use PHP
php_value zlib.output_compression 16386

Turn off magic_quotes_gpc
# Only if you use PHP
php_flag magic_quotes_gpc off


Read more
Related Posts with Thumbnails