Linux chown Command In Hindi : chown Command Examples

Blogs ❯❯ Linux

Image could not load

Image on pixabay

तो जैसा कि आपको पता है Linux multi-user concept पर work करता है , जिसका मतलब है different - different लोग same machine को use कर सकते हैं। या कोई single user , same machine का use करके different - different Jobs कर सकता है। जहाँ पर हमें file permissions की जरूरत पड़ीं।

Files की ownership और permissions का concept Linux ने UNIX और MINUX
से inherit किया है , जो कि इसलिए था क्योंकि Linux को एक तरह से networked system के रूप में convene किया था जहां पर different - different के लोग different - different programs और files use रहे होंगे। और ऐसे में चीजों को organized और secure बनाने की जरूरत थी। क्योंकि कोई भी नहीं चाहता है कि कोई भी normal user किसी program का use करके पूरे system को trash कर दे।

Linux User Types

Linux में normally 3 types के users होते हैं जिनके लिए हम ownership set करते हैं। और वो हैं -

  1. Owner

  2. Group

  3. World / Other

और जब भी हम किसी file / directory की ownership set करते हैं तो इन तीनो तरह के users के लिए करते हैं।

Files / directories की security के लिए Linux में Ownership और Permission maintain करने के लिए chmod और chown command का use किया जाता है।

what is chown Command ?

Linux में chown Command का use किसी File / directorie की ownership change करने के लिए किया जाता है। chown Command आपको वो सभी options provide करती है जिनकी help से आप ownership को maintain कर सकते हैं।

Linux chown COmmand Options

chown Command के सभी options को देखने के लिए chown --help command run कर सकते हैं।

$ chown --help
OptionDescription

-f, --silent, --quiet

इन सभी options का use error messages को hide / suppress करने के लिए किया जा है।

-h

-h option का use करके किसी actual file या directory की ownership को change किये बिना उसकी symbolic link की ownership को change करता है।

-R

-R , means recursively . मतलब किसी directory के अंदर की सभी files / directory की ownership change करता है।

-v, --verbose

इन options का use करके आप हर file / directory के लिए process देख सकते हैं।

chown Command Example

chown Command को अच्छे से समझने के लिए हम current directory में mkdir और touch Command की help से एक test directory और एक test.txt file बना लेते हैं।

touch test.txt

mkdir test

Check file / directory ownership

किसी file / directory ownership check करने के लिए simply आप ls Command की help से listing करके भी देख सकते हैं -

$ ls -l
total 0 
drwxr-xr-x 1 root root 0 Nov  8 03:40 test 
-rw-r--r-- 1 root root 0 Nov  8 03:40 test.txt 

output में आप देख सकते हैं कि दो बार root , root लिखा है जिसमे पहले root का मतलब है इस file को root user own करता है , और दुसरे root का मतलब है कि root user group "root" में है।

Linux change group

group change करने के लिए सबसे पहले हम एक groupadd Command की help से group बना लेते हैं।

$ sudo groupadd mygroup
$ chown :mygroup test
$ ls -l
total 0 
drwxr-xr-x 1 root mygroup 0 Nov  8 04:04 test 
-rw-r--r-- 1 root root    0 Nov  8 04:04 test.txt 

Output में आ देख सकते हैं कि test directory के लिए group root से mygroup हो गया है।

Linux change owner

इसी तरह owner change करने के लिए , सबसे पहले हम adduser Command की help से एक user बना लेते हैं।

$ sudo adduser rahul

ये Command run करने पर आपसे user के बारे में कुछ information (जैसे name , password ) enter करनी पड़गी।

Now change owner

$ sudo chown rahul test.txt
$ ls -l
total 0 
drwxr-xr-x 1 root  mygroup 0 Nov  8 04:04 test 
-rw-r--r-- 1 rahul root    0 Nov  8 04:04 test.txt

Change user and group together

user और group को एक साथ change करने के लिए username:groupname syntax use किया जाता है।

$ sudo chown rahul:mygroup test
$ ls -l
total 0 
drwxr-xr-x 1 rahul mygroup 0 Nov  8 04:04 test 
-rw-r--r-- 1 rahul root    0 Nov  8 04:04 test.txt

Change ownership of multiple files

multiple files / directories की ownership को एक साथ change करने के लिए आप user / group name के बाद multiple files / directories name pass कर सकते हैं।

$ sudo chown username file1 file2 file3

Or

$ sudo chown groupname file1 file2 file3

ठीक इसी तरह से आप बाकी options को apply करके practice कर सकते हैं।

Recent Blogs

Loading ...

Rahul Kumar

Rahul Kumar

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