Synchronizing your Linux Laptop and Desktop
Transferring Single Objects
If your laptop computer is a complement to your desktop machine, you're probably well aware of the need to synchronize data between the two. When you're in the middle of a big project and know you're going to be spending the afternoon in a doctor's waiting room or on an airplane, it's nice to be able to quickly transfer your project files--and maybe your email and contacts--to the laptop, then vice-versa when you return to your desk. This article will show you two ways to accomplish this on GNU/Linux-based machines.
If you only have a handful of individual files or directories to transfer, it's probably easiest to send them one at a time via secure shell (OpenSSH). Every GNU/Linux distribution includes OpenSSH, but not all of them run the SSH daemon (which allows you to connect to the computer via SSH) by default. Starting the daemon is as simple as typing
sshd in a root terminal. You can also configure your distribution to start OpenSSH at boot time; each distro handles startup scripts differently, so you'll have to consult your distro's documentation to learn how to do that.
Once the secure shell daemon is started, other computers can connect to your machine from a terminal window by using the
ssh command, or you can copy files over a secure connection by using
scp. The latter works just like the regular
cp command does, except you have to give it an address for at least one of the files:
scp picture.jpg 192.168.1.101:/home/user/pictures/
In the above example, a file called picture.jpg is transferred to the network machine with the address 192.168.1.101 in the /home/user/pictures/ directory. By default,
scp copies the target file or directory to the home directory of whatever user you're logged in as; you can specify a different location by adding the path after the colon following the address.
By using your /etc/hosts file, you can create a nickname for the remote machine you're copying files to. Just start a new line in the file, type in the IP address of the machine you want to nickname, then press the tab key once and type in the name you'd like to call it:
In the next example, we'll use the laptop nickname instead of the address, specify a different user than the one currently logged into the terminal we're copying from, and copy an entire directory instead of just one file:
scp -r /home/user/pictures/ user2@laptop:/home/user2/
The -r switch means recursive, which tells
scp to copy the directory and everything in it. The above command will create a pictures directory to the /home/user/ directory on the laptop computer, and copy all of the contents of the local machine's /home/user/pictures/ directory to it. So what do you do if the remote machine already has a /home/user/pictures/ directory, but you still want to copy everything in the local machine's pictures directory? You use a wildcard:
scp /home/user/pictures/* laptop:/home/user/pictures/
Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.
- 1Linux Top 3: Alienware, KDE and Ubuntu 13.04
- 2Linux Top 3: Linux Mint Olivia, Fedora 19's Cat and Ubuntu's Mission Accomplished Moment
- 3GNOME 3.8 Debuts New Open Source Linux Desktop
- 4Linux Top 3: Linux 3.10 Goes Long, Linux 3.11 Advances as LXDE Merges
- 5Linux Top 3: Ubuntu Kaylin, Debian Wheezy and Linux Mint