Linux netstat Command : Linux Networking
Linux du Command Example | Linux show disk usage
Linux Create Users : How To Create Users In Linux
Syntax Error In JavaScript In Hindi | JS SyntaxError
What is NIC In Hindi ? Network Interface Card Kya hai ?
JavaScript "new Function" Syntax : JS "new Function" Syntax
JavaScript eval() Function In Hindi | JS eval() Function
Selection Sort in PHP With Example | How does selection sort work in PHP ?
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.
तो जैसा कि आपको पता है 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 में normally 3 types के users होते हैं जिनके लिए हम ownership set करते हैं। और वो हैं -
Owner
Group
World / Other
और जब भी हम किसी file / directory की ownership set करते हैं तो इन तीनो तरह के users के लिए करते हैं।
Files / directories की security के लिए Linux में Ownership और Permission maintain करने के लिए chmod और chown
command का use किया जाता है।
Linux में chown Command का use किसी File / directorie की ownership change करने के लिए किया जाता है। chown
Command आपको वो सभी options provide करती है जिनकी help से आप ownership को maintain कर सकते हैं।
chown Command के सभी options को देखने के लिए chown --help
command run कर सकते हैं।
$ chown --help
Option | Description |
-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 को अच्छे से समझने के लिए हम current directory में mkdir और touch Command की help से एक test
directory और एक test.txt
file बना लेते हैं।
touch test.txt
mkdir test
किसी 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" में है।
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 हो गया है।
इसी तरह 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
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
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 कर सकते हैं।
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