Linux du Command Example | Linux show disk usage
Linux Basic Commands With Examples In Hindi - Part 1
Linux netstat Command : Linux Networking
grep Command in Linux : What is grep Command ?
Linux rm Command Example | Remove file / directory In Linux
How to Implement RESTful APIs In NodeJS In Hindi | NodeJS RestFul API Example
JavaScript "new Function" Syntax : JS "new Function" Syntax
What is Gateway in Hindi ? Gateway kya hai ?
PHP var_export() Function In Hindi | var_export() In PHP In Hindi
If tutorials available on this website are helpful for you, please whitelist this website in your ad blocker😭 or Donate to help us ❤️ pay for the web hosting to keep the website running.
Image by pixabay
Linux में tree command , file structure को traverse करके tree like format में files और directories को list करता है। यह काफी useful command है अगर आप quickly किसी directory structures और किसी certain file की location को investigate करना चाहें।
by default , यह package आपके system में installed नहीं होता है , तो tree use करने के लिए आपको इसे install करना पड़ेगा। tree
install करने के लिए नीचे दी गयी command को run करें।
$ sudo apt update $ sudo apt install tree
$ tree [options] dirpath
By default tree command , current working directory की सभी files और directories को list कर देगा।
$ tree . ├── dir_1 ├── dir_2 ├── dir_3 ├── dir_4 ├── file_1.txt ├── file_2.txt ├── file_3.txt └── file_4.txt 4 directories, 4 files
हालाँकि tree Command के कई और भी Options हैं , जिन्हे आप tree --help
command run करके देख सकते हैं।
tree command के साथ -d
option का use तब किया जाता है जब आप सिर्फ directories की listing कराना चाहते हो। जैसे ऊपर दिए गए example के output में आपने देखा है कि अभी files और directories दोनों आ रहे हैं , लेकिन -d
option pass करने पर सिर्फ directories ही list होंगी।
Example -
$ tree -d . ├── dir_1 ├── dir_2 ├── dir_3 └── dir_4 4 directories
tree के साथ -s
option का use files और directories को size (In bytes) के साथ list करने के लिए किया जाता है।
$ tree -s [ 4096] . ├── [ 4096] dir_1 ├── [ 4096] dir_2 ├── [ 0] file_1.txt └── [ 0] file_2.txt 2 directories, 2 files
tree के साथ -h
option का use भी files और directories को size के साथ list करने के लिए किया जाता है। लेकिन -h
से file का size human-readable format में print होता है। यहां [K for kilobytes, M for megabytes, G for gigabytes] है।
Example -
$ tree -h [4.0K] . ├── [4.0K] dir_1 ├── [4.0K] dir_2 ├── [ 0] file_1.txt └── [ 0] file_2.txt 2 directories, 2 files
tree command के साथ -u
option का use files / directories के file owner का username या UID के साथ list करने के लिए किया जाता है।
$ tree -u [ubuntu ] . ├── [ubuntu ] dir_1 ├── [ubuntu ] dir_2 ├── [ubuntu ] file_1.txt └── [ubuntu ] file_2.txt 2 directories, 2 files
tree के साथ -p
option का use files / directories को उनकी permissions के साथ list करने के लिए किया जाता है।
$ tree -p [drwxr-x---] . └── [drwxrwxr-x] learning ├── [drwxrwxr-x] dir_1 ├── [drwxrwxr-x] dir_2 ├── [-rw-rw-r--] file_1.txt └── [-rw-rw-r--] file_2.txt 3 directories, 2 files
tree के साथ -f
option का use files को full path के साथ list करने के लिए किया जाता है।
$ tree -f . └── ./learning ├── ./learning/dir_1 ├── ./learning/dir_2 ├── ./learning/file_1.txt └── ./learning/file_2.txt 3 directories, 2 files
tree के साथ -J
option का use files / directories को JSON format में print करने के लिए किया जाता है।
$ tree -J [ {"type":"directory","name":".","contents":[ {"type":"directory","name":"dir_1"}, {"type":"directory","name":"dir_2"}, {"type":"file","name":"file_1.txt"}, {"type":"file","name":"file_2.txt"} ]} , {"type":"report","directories":2,"files":2} ]
JSON की full form JavaScript Object Notation है , JSON JavaScript Object पर based एक open standard file format है जो , data को key : value
pair में data store करता है।
Loading ...
Hi ! I'm Rahul Kumar Rajput founder of learnhindituts.com. I'm a software developer having more than 4 years of experience. I love to talk about programming as well as writing technical tutorials and blogs that can help to others. I'm here to help you navigate the coding cosmos and turn your ideas into reality, keep coding, keep learning :)
Get connected with me. :) LinkedIn Twitter Instagram Facebook