How to Upload Local File to Server Through Linux Terminal

AuthorSumit Dey Sarkar

Pubish Date27 May 2023

categoryServer

In this tutorial, we will learn how to upload a local file to a server using linux terminal.

How to Upload Local File to Server Through Linux Terminal

Uploading files to the server through the terminal

To upload a local file to a server using the Linux terminal, you can use the scp command (secure copy)
 uses SSH (Secure Shell) for secure file transfer.

Here's the general syntax to upload a file using scp:

scp /path/to/local/file username@server_ip:/path/on/server

Let's see the above command in details:

  • /path/to/local/file is indicate the path to the file on your local machine that you want to upload.
  • username is the login name which required when you want to connect to the server.
  • server_ip is the IP address or hostname of the server.
  • /path/on/server is the destination path on the server where you want to upload the file.

Example:

scp /path/to/local/file.txt username@server_ip:/home/username/destination_folder/

With this command, the server's /home/username/destination_folder/ directory will get the file.txt from your local computer.

When you execute the programme, you will be required for your server password. The file will be sent to the server once you enter the right password.

Ensure that you have all the necessary (important) permissions to write files to the server and alse make sure that the destination directory already exists.

Comments 0

Leave a comment