Here's a quick reference of the most frequently used (and useful) HDFS (Hadoop Distributed File System) commands to manage files.
$HADOOP_HOME/bin/hadoop fs -ls /
Lists all of the files in the root HDFS directory.
$HADOOP_HOME/bin/hadoop fs -ls /rawdata/server01
Lists all of the files in the HDSF directory at the given path.
$HADOOP_HOME/bin/hadoop fs -mkdir /rawdata/
Creates a new directory in HDFS.
$HADOOP_HOME/bin/hadoop fs -put /home/user/importdir/*.txt /rawdata/
Copies files from a local directory to HDFS at the specified path. The destination directory should have been created preliminarily.
$HADOOP_HOME/bin/hadoop fs -get /rawdata/test01.txt
/home/user/importdir/
Copies files from HDFS back to the local filesystem.
$HADOOP_HOME/bin/hadoop fs -cp /rawdata/test01.txt /rawdatabackup/test01.txt
Copies files within HDFS.
$HADOOP_HOME/bin/hadoop fs -rm /rawdata/*.txt
Deletes files from a HDFS directory.
$HADOOP_HOME/bin/hadoop fs -rm -r /rawdata
Deletes a HDFS directory and all of its content.
$HADOOP_HOME/bin/hadoop fs -tail /rawdata/test01.txt
Prints the last kilobyte of a file to the standard output.
$HADOOP_HOME/bin/hadoop fs -df
Displays the free HDFS space.
$HADOOP_HOME/bin/hadoop fs -df -h
Displays the free HDFS space in human readable format.
$HADOOP_HOME/bin/hadoop fs -ls /
Lists all of the files in the root HDFS directory.
$HADOOP_HOME/bin/hadoop fs -ls /rawdata/server01
Lists all of the files in the HDSF directory at the given path.
$HADOOP_HOME/bin/hadoop fs -mkdir /rawdata/
Creates a new directory in HDFS.
$HADOOP_HOME/bin/hadoop fs -put /home/user/importdir/*.txt /rawdata/
Copies files from a local directory to HDFS at the specified path. The destination directory should have been created preliminarily.
$HADOOP_HOME/bin/hadoop fs -get /rawdata/test01.txt
/home/user/importdir/
Copies files from HDFS back to the local filesystem.
$HADOOP_HOME/bin/hadoop fs -cp /rawdata/test01.txt /rawdatabackup/test01.txt
Copies files within HDFS.
$HADOOP_HOME/bin/hadoop fs -rm /rawdata/*.txt
Deletes files from a HDFS directory.
$HADOOP_HOME/bin/hadoop fs -rm -r /rawdata
Deletes a HDFS directory and all of its content.
$HADOOP_HOME/bin/hadoop fs -tail /rawdata/test01.txt
Prints the last kilobyte of a file to the standard output.
$HADOOP_HOME/bin/hadoop fs -df
Displays the free HDFS space.
$HADOOP_HOME/bin/hadoop fs -df -h
Displays the free HDFS space in human readable format.
Comments
Post a Comment