HDFS is used to store the files
of different size and will be very useful for the data set which are
very big in size.
We will have a look into the
some of the basic commands that can be used in HDFS.
Directory Creation (mkdir):- The directory in HDFS can be created with the help of 'mkdir' command.
Syntax :- hdfs fs -mkdir
dirname
we can also create the directory
by giving the path .
Syntax :- hdfs fs -mkdir
pathname/dirname
Listing directory and files(
ls ) :- The files and directory can be viewed via 'ls' command in
the HDFS.
Syntax :- hdfs fs -ls
We can list the files and
directory by giving the specified path.
Syntax :- hdfs fs -ls
pathname
Displaying
the file (cat ) :- 'cat' command
is used to display the contents of the file.
We
will create a file in our local filesystem.
Syntax
:- cat > file,txt
Now we will display the contents
of the file after sending the file in HDFS using the command cat.
Syntax :- hdfs fs -cat
file.txt
Sending
the file via put command :- We
can send the file from local filesystem to the hdfs via 'put' command.
Note :- put command can be used
to transfer file from one location to another.
Syntax :- hdfs fs -put path1
path2
If we want to send the same
file to the hdfs , we will get an error “File exists” .
To avoid this error , we can
send the file using the option -f .
Syntax :- hdfs fs -put -f
path1 path2
Copying
File in HDFS :- We
can copy the file from one location to another via 'cp' command .
Syntax :- hdfs fs -cp path1
path2
Moving
file in HDFS :- We can
transfer the file from one location to another via 'mv' command .
Syntax
:- hdfs fs -mv path1 path2
No comments:
Post a Comment