Monday, December 20, 2010
Where should find the trash files in ubuntu
Thursday, September 9, 2010
Set ubuntu screen resolution
Wednesday, August 11, 2010
Cron job commands to run shell script, ruby script and php script
Syntax:
Time to run - Command
[ Minute - Hour - Day - Month - Weekday ] - Command
Times pattern
* * * * * => Execute every minute
0 * * * * => Execute every Hour
0 0 * * * => Execute every mid-night
0 0 0 * * => Execute every Month
0 0 0 0 * => Execute every Weekday
*/5 * * * * => Execute every 2 minutes
0 */2 * * * => Execute two Hours
Commands can be broken down as
[PATH OF PHP] [ARGUMENTS] [PATH OF PHP SCRIPT]
######Run PHP Script#########
/usr/local/bin/php -q /home/tom/public_html/cron/maintenance.php
######Run Ruby Script#########
#Ruby cron job setting. Ruby will run cron jobs through script runner.
/usr/local/bin/ruby /home/inkkdds1/inkakinada/script/runner /home/inkkdds1/inkakinada/app/cron_job_database.rb
#ruby-path script-runner-path ruby-file-path
######Run Shell Script#########
cd /home/devinka/public_html/spocosy/ && sh cron.xmlParse.sh
#cd to application-path && sh shell-script-path
Linux Shell Scripting Secrets
Thursday, April 29, 2010
Linux SSH Error - Remote host identification changed
when I try to connect to my remote host through ssh, it throws an error called Remote host identification is changed, below is the process for how can we get rid of this message.
The possible reasons for getting this error are:
If os and openssh in your system is reinstalled, or os or openssh is reinstalled in remote system.
You have assigned the IP address of one system to another system and trying to ssh.
You system is dual boot with different ssh keys in both flavors of linux.
You are using an IP for load balancing and trying to ssh to the same IP.
You generated new ssh keys for your system.
When you tries to login to a remote system through ssh, then the destination hosts provides it’s keys and asked whether these keys are trusted and then those keys are added to your trusted database(known_hosts file). Whenever you tries to login again to the same system, the received keys are checked against the keys available in your file and if both matches then the next step occurs, which is authentication. But if due to any of the above given reason, the keys doesn’t match, then you will get this error and won’t be able to login.
The solution for this problem is
Just remove the old key for remote host from your system's known_hosts file, So when you try to connect through ssh it will again ask you to store the key in the known_hosts file.
OR
Completely Remove keys from known_hosts file
To remove the old keys from the known_hosts file, we can use -R option. This option will remove all the obsolete/old keys from your file. This can be used like this:
# ssh-keygen -R
# ssh-keygen -R
The path for known_hosts file is
In linux
home/venkat(username)/.ssh folder
In windows
c:/documentes and settings/venkat
Tuesday, April 27, 2010
Install and Remove RPM packages in linux
# rpm -ivh foo-2.0-4.i386.rpm
Install from remote host
# rpm -i ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm
# rpm -i http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
Remove package
# rpm -e foo
To uninstall a RPM package. Note that we used the package name foo, not the name of the original package file foo-2.0-4.i386.rpm above
To upgrade
# rpm -Uvh foo-1.0-2.i386.rpm
# rpm -Uvh ftp://ftp.redhat.com/pub/redhat/RPMS/foo-1.0-1.i386.rpm
# rpm -Uvh http://oss.oracle.com/projects/firewire/dist/files/kernel-2.4.20-18.10.1.i686.rpm
Friday, April 23, 2010
Clear history in linux
When you connect to remote host using shell, then make sure to clear the history before you logout.
#command to clear the history is
history -c && rm -f ~/.bash_history
#Shell commands ref:
http://www.blogger.com/publish-confirmation.g?blogID=6810438578552048741&postID=843161968983163768×tamp=1272031182981&javascriptEnabled=true
Thursday, April 15, 2010
Secure files transfer through SSH
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/ed0d3f0199e49f57ca25734000023a77?OpenDocument
Some times you need to login two hosts.
First login:
ssh pete2@stickerguy.net
password:
su
root password:
Next server
ssh stickerguy@web2.greatbasin.net -p 2222
password:
Now you connected two hosting servers and you are in second server. To come out of second server press exit.
The below command will copy the first server files to second server.
scp -r pete2@stickerguy.net:/usr/local/lib/php/Services/ ./Services/
Saturday, April 3, 2010
Linux ssh Tips
You can connect to ssh using root@hostname.com If you have root access
If you dont have root access then do as below
1. First login ssh user@host1.com
2. su
3. Password: root password
After you login to host1's root.
then ssh user@host2.com -p 2222
host2password :
Now you logged into host2 from host1's root.
To come out to host1. use exit.
stickerguy@web2.greatbasin.net
locate is the command to search any folder or files.
Copying files from one host to another with scp command
http://www.lesbell.com.au/Home.nsf/b8ec57204f60dfcb4a2568c60014ed0f/04eaff076bce249dca256fb6007f53e5?OpenDocument
Copy entire folder with all files and subfolders
user@user:~$ scp -r /var/www/localdir/ user@192.168.10.150:/var/www/
In windows
Putty and pscp are excellent tools for ssh and scp operations in windows os.
Download putty and pscp softwares from http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
They are self executable files so no need to install those just place in some folder ex: c:\programfiles\putty folder and set the path in command prompt.
open command prompt (DOS Prompt)from start -> run -> cmd
set PATH=C:\path\to\putty\directory;%PATH%
So to copy the file /etc/hosts from the server example.com as user fred to the file c:\temp\example-hosts.txt, you would type:
pscp fred@example.com:/etc/hosts c:\temp\example-hosts.txt
To send (a) file(s) to a remote server:
pscp [options] source [source...] [user@]host:target
So to copy the local file c:\documents\foo.txt to the server example.com as user fred to the file /tmp/foo you would type:
pscp c:\documents\foo.txt fred@example.com:/tmp/foo
You can use wildcards to transfer multiple files in either direction, like this:
pscp c:\documents\*.doc fred@example.com:docfiles
pscp fred@example.com:source/*.c c:\source
Copy entire folder from remote server to local computer along with files and subfolders
pscp -r user@example.com:source/* c:\source
Ref : http://www.jfitz.com/tips/ssh_for_windows.html
Tuesday, March 30, 2010
Export and import database to and from remote servers through telnet
Import command at terminal or dos
mysql -u user_login -p database_name < /path_to_the_file/my_backup.sql
Export command at terminal or dos
mysqldump -u user_login -p database_name > /path_to_the_file/my_backup.sql
Database Backup
connect to remote host with SSH from termail using below command
#ssh user@host.com
password:
After login, crate one folder to store the backup file and make it writeble, then run the beloc ommand to take backup for the whole database
#mysqldump -u dbusername -p dbname > dbbackup.sql
It will ask you the dbpassword
After download ddbackup.sql and transfer to new host where you have to set up the database..
connect to remote host with SSH
#mysql -u dbusername -p dbname -e 'source dbbackup.sql'
It wil ask you the dbpassword.
The other way, which is even cooler, and more secure, assuming you have ssh access on both machines (this, again, is a direct dump-to-import):
mysqldump -ux -px database | ssh me@newhost "mysql -ux -px database"
This will dump the data to stdout, pipe it to ssh @ the newhost, and into mysql. Of course, replace all x's with username's and password.
If you want to keep two databases equal, you can use rsync (if your system supports it) to do it by creating a simple script:
rsync you@yourserver::share/path/to/mysql/data/* /path/on/the/other/server/
that you call with a cron job every 10 minutes/1 hour/1day/...
This way, whenever your database change, rsync will find the difference and would transfer ONLY the bytes that have changed.
Ref: http://www.webhostingtalk.com/archive/index.php/t-226992.html
Tuesday, March 23, 2010
Commands to start apache server and mysql server in linux
#service httpd start
the above command will start both apache and mysql servers.
To start Mysql server in linux (LAMP)
#service mysqld start
Friday, February 19, 2010
Cron job settings in server
For php:
Login to hosting server and goto the cron job settings page and select the time interval you want to run the script then give the command to run the php file as below
php /path-to-your-phpfile.php
(OR)
/usr/local/bin/php /path-to-your-phpfile.php
For Ruby:
/usr/local/bin/ruby /home/user/domainname/script/runner /home/user/domainname/app/cron_job.rb
Wednesday, January 20, 2010
Linux chage folder permision to a group
Hi, In linux root have the full permission over entire os and other users will have some previliages only. So when you loggin to the system and want to have write permission to one folder all you have to do, first see the permission of that folder, it contains three blocks,
OWNER - root
GROUP - root
OTHERS --
Here this means all all writes are permitted to root only. If you want to have write permission to this folder, First change the group permission to your group, then provide the write permission to the group. For this follow the below commands
First login as superuser that i.e root for this run command 'su' in the terminal
sudo su
enter root password:
chgrp -R venkat /var/www
#the above command will change the group
chmod -R g+w /var/www
#the above command will provide the write permission to the group
Now the user who logged in as venkat can have the read write permission to the folder var/www
r = read permission
w = write permission
x = execute permission
- = no permission
Ref: http://www.tuxfiles.org/linuxhelp/filepermissions.html
http://www.comptechdoc.org/os/linux/usersguide/linux_ugfilesp.html
Thursday, November 26, 2009
Preventing open a new window for each folder in linux
2. Go to the "Edit" menu and choose "Preferences."
3. Click on the "Behavior" tab.
4. Put a check in the box marked "Always open in browser windows
Tuesday, November 24, 2009
File permissions in Linux
By using chown command through terminal you can give file permissions to the users in linux operating systems without login as root. By default you are not able to access some folders in the linux os due to the security reasons. But sometimes you need to access some folders. Ex: If you want to run php files you need to place the files in the folder called /var/www/html but other than root account no one have write permission to this folder.
So if you want to enable write permissions to that folder for your account simply
open the terminal as
# applications > system tools > Terminal
enter su in the terminal to login as root
#su
it will ask you the root password, give the root password
then run the below command
#chown username /var/www/html/
Now you have the write permissions to that folder.
Flash Plugin for Firefox in Fedora11 OS
http://labs.adobe.com/downloads/flashplayer10.html
and download the linux version tar file uncompress the tar file and Copy the file libflashplayer.so in to the folder /usr/lib/mozilla/plugins.
That's it you just need to restart the firefox by File -> Exit and see your firefox is now enabled with flash support.