Create a file txt in the "/home/hadoop/" directory of the local Linux file system, and enter some words at will.
- mkdir hadoop
- cd hadoop
- touch 123.txt
- gedit 123.txt
View file location locally (ls)
- ls -al
Display file contents locally
- gedit 123.txt
Use the command to upload "txt" in the local file system to the input directory of the current user directory in HDFS.
- cd /usr/local/hadoop
- ./sbin/start-dfs.sh
- ./bin/hdfs dfs -mkdir /input
- ./bin/hdfs dfs -put ~/hadoop/123.txt /input
View files in hdfs (-ls)
- ./bin/hdfs dfs -ls /input
Display the content of the file in hdfs
- ./bin/hdfs dfs -cat /input/123.txt
delete the local txt file and view the directory
- cd hadoop
- rm -r 123.txt
- ls -al
Download the txt to the original local location from hdfs.
- ./bin/hdfs dfs -get /input/123.txt ~/hadoop
delete txt from hdfs and view directory
- ./bin/hdfs dfs -rm -r /input/123.txt
- ./bin/hdfs dfs -ls