- Create a TXT file in the "/home/hadoop/" directory of your local Linux file system, where you can enter some words.
mkdir hadoopcd Hadooptouch Test.txtgedit test.txt
- To view the file location locally (LS)
Ls-al
- Displaying the contents of a file locally
Cat Test.txt
- Use the command to upload "TXT" from 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
- Displays the contents 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
- From HDFs, download the txt locally to the original location.
Cd/usr/local/hadoop./sbin/start-dfs.sh./bin/hdfs Dfs-get input/test.txt ~/hadoop
- Remove TXT from HDFs and view the directory
./bin/hdfs Dfs-rm-r Input/test.txt./bin/hdfs Dfs-ls-r
The shell command provided by Hadoop accomplishes the same task