Archive for May, 2008

World Without Engineers

May 28, 2008


Backup(dump) and Restoring a mysql DB

May 21, 2008
  • Dumping all databases of a hosts
    $ mysqldump -u root -psecret --all-databases > DATABASE.sql

other options can be used with this

    --skip-opt --force --no-data --no-create-info (see man page of mysqldump for detail)
  • Dumping a particular database
    $ mysqldump -u root --databases design > design.sql
  • Restoring backup of all databases
    $ mysql -u root -psecret < DATABASE.sql
  • Restoring backup of a particular database
    $ mysql -u root -psecret -D design < design.sql

Simple backup scripts

  • mysqldump -A –password=xxxxxx | gzip >/mysql_backup/`date +%m%d%y_%T`.sql.gz

Magic command of tar

May 21, 2008

If we want to send a large file to a remote host, we first compress (using tar cvzf’) the file then send (using scp) that file to the remote host and then uncompress (using tar xzvf) the file to view. so this is lengthy and time consuming.

If we use the following single line command it will reduce time to a significant amount ( take only 1/3 time of the above procedure).

  tar czvf - <File-U-Want-to-tar> | ssh tarique@  "cat | tar xvzf -"


  tar czvf - <file-u-want-to-tar> | (ssh tarique@ tar xvzf -)

Efficient use of scp command

May 21, 2008

Sometimes you need to copy a file from a remote hosts.In this case we can use the scp command in a different fashion,not only different but a efficient way to copy the file from the remote hosts not logging into that remote host.

The syntax is as follows-

  $ scp  <remote-host-name/IP>:<remote-host-file-name-with-location>  <path-you-want-to-keep-file>

Assigning a user to a group

May 21, 2008

Sometimes a user need to be assign to a existing group or to a new group.If the group is exists then just follow the command and if the group is a new one then first create the group using groupadd command and then follow the command.

usermod -a -G <group-name-2b-add> <user>

g – primary group
G – upplementary group
a – option will add the user to a group without removing him/her from other groups.