How to migrate a MySQL database from one Linux server to another using the command the line

How to move/migrate a MySQL database from one Linux server to another via the command line using “mysqldump” to export the database , “scp” (secure copy) to transfer it, and “mysql” to import it.

In this example, we’ll migrate/move a theoretical SQL database named twatdb from it’s current location on example.com over to the twat.ca server.

1. Export the database from the old server using “mysqldump”

For our example, let’s say our database is named “junglist”. Before transferring the database file to the new VPS, we first need to create a database dump on the original server using mysqldump:

mysqldump -u root -p –opt [database name] > [database file].sql

2. Transfer the .sql database file to the new server

While there’s many different ways we could move our .sql file over to the new server (SFTP, rsync, etc.) we’re going to use “scp” (secure copy) in this example.

Syntax: scp [database name].sql [username]@[servername]:path/to/database/

Using scp, we’ll put the file in our home folder on the new server:

3. Import the database on the new server

Log in to your new server via SSH and import using mysql:

mysql -u root -p [database name] < [database file].sql

How to check your connection speed with Speedtest.net from Ubuntu/Debian command line

How to check your internet connection speed using the “speedtest-cli” Python application for Ubuntu & Debian and optionally share your results.

1. Install speedtest-cli application

Note: You can optionally skip the “sudo” prefixes on the commands below by switching to root using the sudo su command.

First, make sure your list of repository packages is up to date:

Next, install the Python package manager (pip):

Now install the speed-cli application using Python package manager (pip):

And if you ever want to upgrade the application, you can use:

2. Test your connection speed using speedtest-cli application

To check your internet connection speed, run the speedtest-cli application:

Alternatively, if you want to be able to share your results:

Run the speedtest-cli application using the optional share argument:

Paste the address above into a browser to see the result. Example:

6017542333.png Speedtest.net result

For additional information:

  • Speedtest.net website (the original web-based version)
  • Run speedtest-cli using the optional help argument:

How to check the uptime of a Linux server

See how long your server’s been up without a reboot or crash.

Just type ‘uptime’ and you’re done:

Output:
This shows that it’s currently 2:36am, the server has been up for 28 days, 19 hours and 35 minutes, and there is one user connected.  The load average displays the average CPU load over the past last one, five, and fifteen minutes.

Install LambdaMOO 1.8.1 server with LambdaCore database on Ubuntu 12

MOO = MUD Object-Oriented. This will show you how to download and compile LambdaMOO 1.8.1 server and get it running as a background process using the LambdaCore database.

 

Download the LambdaMOO server into your home folder using ‘wget’:

Output:

Extract the LambdaMOO .tar.gz archive:

Output:

Change directory & run the configure script:

Output:

You may have to install yacc before the next step:

Output:

Compile the server:

Output:
I’m not sure what the errors are all about but it seems to run fine regardless!

Download the LambdaCore database:

Output:

Extract the LamdaCore database:

That’s it, now you should be able to start up the MOO:

The format is: ./moo <input-db-file> <output-db-file> <port> &
The & is used to run it in the background so you don’t need to keep the window open.

Output:

To test it, just telnet to the port you specified above:

Output:

LINKS:

Download LambdaMOO-latest.tar.gz (server)
Download LambdaCore (database)

And be sure to visit Lisdude’s MOO Resources page:

Lisdude’s MOO Resources

Extract a .tar.gz archive to a specific location in Ubuntu 12.04

How to extract a .tar.gz file to a specific folder and vice versa (create a .tar.gz file from a folder) using the ‘tar’ command from Ubuntu 12.04 command-line terminal.

To extract .tar.gz:

Usage: tar -zxvf <filename>
Usage: tar -zxvf <filename> -C <folder>

  • -z : filter the archive through gzip
  • -x : extract files from an archive
  • -v : verbosely list files processed
  • -f filename : use archive file or device ARCHIVE

Examples:

Or, to do the opposite (create .tar.gz archive from a folder):

  • -z : filter the archive through gzip
  • -c : create a new archive
  • -v : verbosely list files processed
  • -f  filename : use archive file or device ARCHIVE

To exclude specific filetypes from either of the above, you can use –exclude … the following example excludes all .mp3 and .tar.gz files:

Example to create a .tar (non .gz) file  in the current folder named test.tar, archiving the folder /home/jamesc/test

Tar usage (output of “tar –help”)

 

How to switch to another user using sudo in Ubuntu 12.04 shell

How to switch to another user from the Ubuntu 12.04 command-line shell without the password of the target user. Must have sudo permissions.

Usage: sudo -u <username> <shell>

Assuming your account has root/sudo permissions:

You may have to type in your password (not the password of the account you’re switching to.)

Just type “exit” to get back to your original session:

 

How to create symbolic links in Ubuntu 12.04 shell

How to create a symbolic link using the ‘ln’ command from an Ubuntu 12.04 command-line terminal/shell to refer a path to another location on your disk.

Usage: ln -s <target> <link>

target = existing file or folder you wish to create a symbolic link of.
link = the new file/folder link to be created

For example, to create a link to /var/www/html/wordpress in my home folder:

Or:

Output:

 

How to check your hard drive space in Ubuntu 12.04 shell

How to list all storage devices using the ‘dh’ command from a command-line Ubuntu 12.04 shell, including file system type, total size, used space, available space, % used and mountpoint.

Type the following command from your shell prompt:

Output:
The device mounted on / is the root folder of your file system.

If you want to see the file system types as well:

Output:

Using ‘eyeD3’ to show/edit/copy MP3 ID3 tags in Ubuntu 12.04 shell

How to use ‘eyed3’ from an Ubuntu 12 command-line terminal to display ID3 tags, edit ID3 tags, copy ID3v2 to ID3v1, copy ID3v1 to ID3v2 and more.

To install eyeD3:

Note: lowercase ‘d’ unlike the actual command.

To display ID3 info, use “eyeD3 <filename>”, surrounding the filename in quotes if it contains spaces:

Note: uppercase ‘D’ when using the command.

Output:

You can also display the ID3 info for multiple files at once, for example to see the ID3 tags for every file in a directory:

 

There’s lots you can do with eyeD3, including retagging, copying tags, removing tags, converting one tag format to another, etc.. here’s the full “eyeD3 –help” usage output: