- Basic Linux tutorials for beginner
- Linux basic concepts, installation and troubleshooting
- Linux administration
- Linux commands
- Linux network tutorials
- Linux security tutorials
- Linux software configuration
- Linux desktop tutorials for beginner
- Collection of Linux tips
- Windows basic tutorials
- Introduction to windows
- Windows pre-installation
- Windows Installation
- Windows xp desktop
- Log on for the first time
- Windows XP control panel
- Managing Folders in Windows XP
- Outlook Express Setup
- How to import address book in Outlook Express
- Import Ms Exchange inbox file(.pst) into Ms Outlook 2003
- Import Outlook Express email messages into Ms Outlook 2003
- How to mount and unmount usb drive (thumb drive) in Windows
- House keeping - Keep your Windows clean and tidy
- Windows basic tutorials
Linux administration - File and directory ownership
Submitted by jinlusuh on Tue, 01/29/2008 - 08:06
Linux file and directory ownerships guide
Managing file and directory ownerships are important administration task in Linux. Setting up ownership means give security to a file or directory.
Linux has a very special ownership and permission system. Each files or directories has 2 ownership which is user and group. That means, a certain file or a directory has its owner and group responsible for it. Let's see more about these in details with examples. We will create a new directory named 'owner' in /home/bill directory. We will use mkdir command to create a new directory or folder (as you called it in Windows). Type as follows:
Now create a new file named ownership.txt. The command to create a new file (simple file) is touch <filename>.
The first column (-rw-r--r--) is a permission of the subject.
The second column (1) is the number of link to the subject.
The third column (bill) is the owner of the subject.
The fourth column (users) is the group owner of the subject.
The column (0) is the size of the subject.
The next column (2006-01-16 13:02) is the date and time when the subject is last updated.
Finally, the last column (ownership.txt) is the subject.
The size of the subject ownership.txt is 0. We can edit the file with vim text editor to add some text to it. Try vim ownership.txt now. Press i to go to insert mode. Type something:
Now press Esc to go back to the vi command mode. Save what we did by entering ':w and :q to exit vim editor. Don't worry to much about vim editor now. You can learn more in Linux vi editor tutorial later if you want.
Linux chown command
Ok now, the command to change the owner of the subject is chown. Oh you can view the format and info about chown with man chown. Let's try it if you are ready.
You can't change the owner of 'ownership.txt' file to root because you don't have the power. Who's the most powerful user in Linux operating system? Well, switch to root now. The command is su, means switch user or super user. Type su - to switch to root environment. Enter the root password and you are root now.
Now issue the following command:
Now the owner of the subject is root.
The command chgrp is used to change the group owner. The example is as follows:
We have changed the owner and group of the subject. Now press Ctrl + D or type exit to exit from root.
View the content again with 'vi ownership.txt'. Press'i' and insert some text. After you finished, try force save and exit with ':wq!'
You can't overwrite the file this time. Why? That's ownership ;-)
To exit from vim press ':q!'. This option is to force quit vi.