- 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 test.txt gedit test.txt
- View file location locally (ls)
ls -al
- Display file contents locally
cat test.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/test.txt input
- View files in hdfs (-ls)
./bin/hdfs dfs -ls
- Display the content of the file in hdfs
./bin/hdfs dfs -cat input/test.txt
- delete the local txt file and view the directory
rm -r ~/hadoop/test.txt
- Download the txt to the original local location from hdfs.
cd /usr/local/hadoop ./sbin/start-dfs.sh ./bin/hdfs dfs -get input/test.txt ~/hadoop
- delete txt from hdfs and view directory
./bin/hdfs dfs -rm -r input/test.txt ./bin/hdfs dfs -ls -R
Shell commands provided by Hadoop accomplish the same task
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=324906525&siteId=291194637
Recommended
Ranking