Linux for Beginners: How to Transfer Files Between Linux Machines
Transferring files between Linux machines can seem daunting for beginners, but it's actually a simple process. In this post, we'll go over some easy ways to transfer files between Linux machines.
Method 1: SCP
SCP, or Secure Copy, is a command-line tool that allows you to securely transfer files between Linux machines. To transfer a file from one machine to another using SCP, simply run the following command:
scp /path/to/local/file username@remotehost:/path/to/remote/directory
Replace /path/to/local/file
with the local file you want to transfer, username
with your remote machine's username, remotehost
with your remote machine's IP address or hostname, and /path/to/remote/directory
with the remote directory you want to transfer the file to.
For example, to transfer a file named example.txt
from your local machine to a remote machine with IP address 192.168.1.100
and username user
, run the following command:
scp /path/to/example.txt user@192.168.1.100:/home/user/
Method 2: FTP
FTP, or File Transfer Protocol, is another way to transfer files between Linux machines. To transfer files using FTP, you'll need to set up an FTP server on the remote machine and an FTP client on the local machine.
One popular FTP server for Linux is vsftpd. To install vsftpd on Ubuntu, run the following command:
sudo apt-get install vsftpd
Once vsftpd is installed, you can use an FTP client like FileZilla to connect to the remote machine and transfer files.
Download and install FileZilla on your local machine.
Open FileZilla and click on the "File" menu at the top left of the window.
Click on "Site Manager" in the menu that appears.
Click on the "New Site" button in the Site Manager window.
In the "Host" field, enter the IP address or hostname of the remote machine.
In the "Port" field, enter the port number for the FTP server on the remote machine. The default port for FTP is 21.
In the "Protocol" field, select "FTP - File Transfer Protocol."
In the "Encryption" field, select "Use plain FTP."
In the "Logon Type" field, select "Normal."
In the "User" and "Password" fields, enter the username and password for the remote machine.
Click on "Connect" to connect to the remote machine.
Once connected, you'll see the remote machine's file system on the right-hand side of the FileZilla window. Use the left-hand side of the window to navigate to the local file you want to transfer.
Drag and drop the file from the local file system to the remote file system to transfer the file.
That's it! You've now successfully transferred a file from your local machine to a remote machine using FileZilla.
Method 3: Samba
Samba is a software suite that allows you to share files and printers between Linux and Windows machines. To transfer files between Linux machines using Samba, you'll need to set up a Samba server on the remote machine and a Samba client on the local machine.
To install Samba on Ubuntu, run the following command:
sudo apt-get install samba
Once Samba is installed, you can create a shared folder on the remote machine and then access it from the local machine using the Samba client.
To create a shared folder on the remote machine, you'll need to edit the Samba configuration file. Open the file /etc/samba/smb.conf using a text editor and add the following lines at the end of the file:
luaCopy code[shared_folder]
path = /path/to/folder
read only = no
Replace "shared_folder" with a name for your shared folder, "/path/to/folder" with the path to the folder you want to share, and "read only = no" with "read only = yes" if you want to make the folder read-only.
Save the changes to the file and then restart the Samba service by running the following command:
Copy codesudo systemctl restart smbd
On the local machine, you can access the shared folder using the Samba client. Open the file manager and select "Connect to Server" from the menu. In the "Server Address" field, enter the IP address of the remote machine followed by the name of the shared folder, like this:
arduinoCopy codesmb://192.168.1.100/shared_folder
Replace "192.168.1.100" with the IP address of the remote machine and "shared_folder" with the name of the shared folder you created. Click "Connect" and then enter the username and password for the remote machine when prompted. You should now be able to access the shared folder and transfer files to and from it.
Transferring files between Linux machines doesn't have to be complicated. By using tools like SCP, FTP, and Samba, you can easily transfer files between machines. Experiment with these methods and see which one works best for your needs. Good luck and happy transferring!
Subscribe to my newsletter
Read articles from Matthew Hard directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Matthew Hard
Matthew Hard
I'm Matthew, a cybersecurity enthusiast, programmer, and networking specialist. With a lifelong passion for technology, I have dedicated my career to the world of cybersecurity, constantly expanding my knowledge and honing my skills. From a young age, I found myself captivated by the intricate workings of computers and networks. This fascination led me to pursue in-depth studies in the fields of networking and cybersecurity, where I delved deep into the fundamental principles and best practices. Join me on this exciting journey as we explore the multifaceted world of technology together. Whether you're a beginner or a seasoned professional, I am here to share my knowledge, discuss the latest trends, and engage in insightful discussions. Together, let's embrace the ever-changing world of tech and navigate the complexities of cybersecurity with confidence and expertise.