- 首先启动hadoop
cd /usr/local/hadoop
./sbin/start-dfs.sh
-
在hdfs的“/user/hadoop”目录下创建file1.txt
./bin/hdfs dfs -touchz file1.txt
-
初始化文件,并向文件中写入内容
./bin/hdfs dfs -get /user/hadoop/file1.txt
vi file1.txt
./bin/hdfs dfs -put -f file1.txt /user/hadoop/file1.txt
./bin/hdfs dfs -cat file1.txt
-
在hdfs的“/user/hadoop”目录下创建file2.txt
./bin/hdfs dfs -touchz file2.txt
-
向file2.txt追加内容
echo "<this is file2.txt>" | ./bin/hdfs dfs -appendToFile - file2.txt
-
查看file2.txt内容
./bin/hdfs dfs -cat file2.txt
-
修改file2.txt.的内容
./bin/hdfs dfs -get /user/hadoop/file2.txt
vi file2.txt
./bin/hdfs dfs -put -f file2.txt /user/hadoop/file2.txt
-
查看修改内容
./bin/hdfs dfs -cat file2.txt