Pages

Wednesday, 11 July 2012

Start Mysql Without Password

Stop Mysql.
 
Start Mysql with below command 
 
mysqld_safe --skip-grant-tables &
 
Loggin into mysql terminal

mysql --user=root mysql
 
Press enter if asked for password
 
Update the password
 
update user set Password=PASSWORD('new_Password') WHERE User='root';
 
Exit from mysql terminal 
 
Kill the process started by you
 
Start mysql through init script and login through your new password.
 
/etc/init.d/mysql start
 
 
mysql --user=root mysql -p
 
 

Thursday, 1 March 2012

Find and execute a command on the files found

find -mtime +365 -exec mv '{}' /path/to/copy/files/ \;


Find files whose modified time 365*24 hours and "+" would give me files 365 days ago.
"-exec" will help me execute a query, where "{}" is all the files or parameters given by find command. The "{}" are quoted in single quote '.
";" sign simplifies end of command.

SMTP authentication through telnet

[paresh@pareshlinux ~]$ perl -MMIME::Base64 -e 'print encode_base64("Username")'
cWxjX3NhbWVlcg==
[paresh@pareshlinux ~]$ perl -MMIME::Base64 -e 'print encode_base64("Password")'
c2FtZWVy
[paresh@pareshlinux ~]$ telnet 10.10.10.13 25
Trying 121.241.242.215...
Connected to mail1.mailserve.net (10.10.10.13).
Escape character is '^]'.
220 host.mailserve.com ESMTP Postfix
ehlo 121.241.242.215
250-host.mailserve.com
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-AUTH LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
AUTH LOGIN
334 VXNlcm5hbWU6
cWxjX3NhbWVlcg==
334 UGFzc3dvcmQ6
c2FtZWVy
235 2.7.0 Authentication successful

How to view files modified yesterday

find /path/to/directory/ -daystart -ctime 1

The find command helps you to find files that were changed or modified yesterday

-daystart :- will tell to begin the search from yesterday 00:00 and not - 24:-00 hours. If u don't mention it, this will show you files updated 24 hours ago from the current time.

-ctime :- will tell to look for files modified 1 day ago, to check for files n days ago specify -ctime "n", where n is the no. of day

How to use EOF

EOF works some what like this:
Command << EOF
Execute line1
Execute line2
.
.
.
Execute line"n"
EOF

Description: So the above command is executed and after that all the line below it are executed unless EOF is found which means End Of File

example:

#useradd user1
#passwd user1 << EOF
new-password
new-password
EOF