How to transfer a local file to HDFS in Hadoop?
To upload a local file to HDFS, you can use the following command:
hadoop fs -put /本地路径/文件名 HDFS路径/文件名
Local path/filename refers to the path and filename of the local file to be uploaded, while HDFS path/filename refers to the path and filename in HDFS where the file will be uploaded.
For example, to upload the local file /home/user/test.txt to the directory /user/hadoop in HDFS, you can use the following command:
hadoop fs -put /home/user/test.txt /user/hadoop/test.txt
In this way, the test.txt file will be uploaded to the /user/hadoop directory in HDFS.