You are on page 1of 17

Local File System

Commands
(Linux Based Commands)
Commands
1. ~]$pwd- present work directory
2. ls
3. ls –l
 If start with – then it is a file
 If start with d then it is a directory

4. For Hidden Files: ls –a


5. Create directory: mkdir glbajaj
6. How to change directory pwd to other directory: cd glbajaj
7. Progressively create directory:
 [training@localhost glbajaj]$ mkdir -p bigdata/teacher/students
 [training@localhost glbajaj]$ cd bigdata/teacher/students
8. For home directory:
 [training@localhost students]$ cd ~
9. For root directory:
 [training@localhost ~]$ cd /
 [training@localhost /]$ pwd
 /

10. For root to glbajaj directory:


 [training@localhost /]$ cd ~/glbajaj
 [training@localhost glbajaj]$ pwd
 /home/training/glbajaj
 [training@localhost glbajaj]$ cd /
 [training@localhost /]$ pwd
 /
 11) cd – ( use for previous directory)
 [training@localhost /]$ cd ~
 [training@localhost ~]$ cd ..
 [training@localhost home]$ cd ..
 [training@localhost /]$ cd ..
11. File can be created in three ways:
a) Cat command
b) Vi editor
c) Touch comand
Cat commnad[training@localhost /]$ cat>demo.txt
bash: demo.txt: Permission denied
[training@localhost /]$ cd ~
[training@localhost ~]$ cat>demo.txt
Hii how are you
How was your job goining on?
CTRL+C(Existing the file without saving)
CTRL+d (save and exit)
a) Cat can be used in three ways:

CAT comand

Cat>>
Creating a file if
it is not available Cat
Cat> Display content
Creating a file And for
appending text of the file
to the already
existed file
training@localhost ~]$ cat>>demo.txt
Am Back
training@localhost ~]$cat demo.txt
Hii how are you
How was your job goining on?
Am Back
b) Vi editor
Three modes in vi editor:
 Esc mode(esc button)(by default mode)
 Insert mode (press ‘i’ )
 Colon mode (press “shift + ‘;’)

training@localhost ~]$vi file.txt


 Inside insert mode-
-
-
-
-insert-
 Press esc then :wq for save and exit
 Press esc then :q for exit without saving file
vi modes

press Esc shift+;


COLON
INSERT MODE ESC MODE
MODE
Press ‘i’ esc
 C) touch command
 It is just for creating a file not for writing

content inside file


 training@localhost ~]$ touch file2.txt
12. Remove file: rm <filename>
training@localhost ~]$rm file.txt
13. For recursively removing directories: rm
-r<directories>
[training@localhost glbajaj]$ rm -r bigdata/teacher
rm: descend into directory `bigdata/teacher'? y
rm: remove regular file `bigdata/teacher/teachers'? y
rm: remove directory `bigdata/teacher/students'? y
rm: remove directory `bigdata/teacher'? y
[training@localhost glbajaj]$
14. For forcefully removing directory
[training@localhost glbajaj]$ rm -rf
bigdata/teacher
[training@localhost glbajaj]$
Teacher deleted
15. Copy and paste file
[training@localhost glbajaj]$ cp <src> <dest>
 If src is a file then dest may be file or

directory
 But if src is a directory then dest should be

directory
16. Cut and paste
[training@localhost glbajaj]$ mv <src> <dest>
17. Two ways two display content of file:
Absolute path
[training@localhost glbajaj]$ cat
home/training/glbajaj/bigdata/teacher/stude
nt/file.txt
Relative path
[training@localhost glbajaj]$cat
bigdata/teacher/student/file.txt
Command Of Hadoop
 Hadoop fs
 hadoop fs -ls
 hadoop fs -mkdir newdirectory
 hadoop fs -ls
 hadoop fs -put /home/training/file3.txt newdirectory
 hadoop fs -put /home/training/Desktop/hello.txt newdirectory
 hadoop fs -copyFromLocal /home/training/Desktop/tem.txt

/user/training/newdirectory
 hadoop fs -moveFromLocal /home/training/Desktop/tem.txt

/user/training/newdirectory
 hadoop fs -get /user/training/newdirectory/tem.txt /home/training/Desktop

◦ -copyToLocal
 hadoop fs -cat newdirectory/tem.txt
 hadoop fs -rm newdirectory/tem.txt
 hadoop fs –rmr aaa
 hadoop fs -cp /user/training/newdirectory/file3.txt aaa
 hadoop fs -cp /user/training/newdirectory/file3.txt filea.txt
 hadoop fs -mv /user/training/newdirectory/file3.txt /user/training/abbcc/filea3.txt
HDFS - fsck (File System Check)

 HDFS supports the fsck command to check for various


inconsistencies. It it is designed for reporting problems
with various files, for example, missing blocks for a file
or under-replicated blocks. Unlike a traditional fsck
utility for native file systems, this command does not
correct the errors it detects. Normally NameNode
automatically corrects most of the recoverable failures.
By default fsck ignores open files but provides an option
to select all files during reporting. The HDFS fsck
command is not a Hadoop shell command. It can be run
as 'bin/hadoop fsck'. For command usage, see fsck
command. fsck can be run on the whole file system or
on a subset of files.

You might also like