CLI

 


Hadoop File System Interface

Command Line Interface is the primary tool used to interact directly with HDFS from a terminal. It provides a file system shell that allows you to perform basic operations like creating directories, moving files, viewing file contents, and altering permissions.

The Command Line Interface (CLI) in Hadoop is a text-based interface used to interact with the Hadoop system by typing commands in a terminal or command prompt.

It allows users to manage files in HDFS (Hadoop Distributed File System), run Hadoop applications, and monitor Hadoop operations.


Advantages of Hadoop CLI

Easy to execute Hadoop commands.

Supports file management in HDFS.

Helps upload and download large datasets.

Allows users to run Hadoop jobs and administer the cluster.

Useful for automation through shell scripts.

Hadoop CLI is a command-based interface that helps users interact with Hadoop and perform HDFS file operations, run jobs, and manage the cluster.

 

HDFS Commands

 1.                      You have to start first Hadoop

2.                      Give following commands

Start-all.cmd

3.                      Then Give command(check all are running properly)

Jps

4.                      Run the derby server-Use command

StartNetworkServer -h        0.0.0.0



                 ls: This command is used to list all the files. Use lsr for recursive approach. It is useful when we want a hierarchy of a folder.

Syntax:

hdfs  dfs -ls  <path>

Example:

hdfs  dfs -ls  /

It will print all the directories present in HDFS.

            mkdir: To create a directory. In Hadoop dfs there is no home directory by default. So let's first create it.

Syntax:

hdfs dfs -mkdir <folder name>

Example:

  hdfs dfs -mkdir  /states  =>  '/' means absolute path

                      put — this command is used to copy the data from the local file system to HDFS.

 hdfs dfs -put <Local File Path> <HDFS file path>

                 get — this command is used to copy the data from HDFS to the local file system. This command is the reverse of the ‘put’ command.

 hdfs dfs -get  <HDFS file path>  <Local File Path>

 

1.      CopyFromLocal -same as put command

Ex: hdfs dfs   -copyFromLocalsourcepath    destinationpath


1.      copyToLocal- same as get command

Ex: hdfs dfs  -copyToLocalsourcepath     destinationpath

 

            Cat- to view contents of a file

Ex: hdfs dfs  -cat  /Shree/sample.txt

   cp- to copy files from one location to another

Ex: hdfs dfs -cp sourcepath destinationpath



           df- displays disk free space and all other 

    Ex:hdfs dfs -df /user

                                   mv-moving files within hdfs

     Ex: hdfs dfs -mv sourcepath destinationpath


     rm - to remove files from hdfs

     Ex:hdfs  dfs  -rm /subhash/sample.txt




SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

Hadoop_EcoSystem

  Unit-4 Hadoop Ecosystem   Hadoop ecosystem architecture  HDFS (Hadoop Distributed File System). Serves as the primary storage foundati...