Linux 4 - Permissions



4
26669

Suggest new or help me make more videos here: http://patreon.com/opencanvas Lesson 4 delves into file and directory permissions and the 9 RWX bits associated with each. So here’s a scenario; your root admin has created you as a new user on the system at a company you work for. You have created some important files related to your business on the system, and it’s paramount that these files aren’t tampered with. But someone from another department needs to read the files for verification. Ideally we want them to read the file, but not modify anything. Or how about you’re a web developer, and you have a directory of file scripts you want to share with your team, but no-one else. By setting file or directory permissions, we can determine what user’s can read, write or even execute. With linux, we can set permissions to do just that. The nine bits assigned to each file or directory define the access that you and the others have. The first 3 bits apply to the owner’s permission. The next three apply to the group assigned and the last 3 apply to all others. The R stands for read, with a file this means you can view the contents of the file and with a directory, you can see what files and subdirectories it contains. The W stands for write, meaning a file’s contents can be changed, the file can be renamed or even deleted. If it’s a directory, it means you can add, change or delete files or subdirectories in that directory. The X stands for Execute. With a file it will be treated as a program and run. With a directory, you can change to it, search or execute a program from that directory. If a dash appears instead of the letter, it means the permission is turned off for that associated read, write, or execute bit. At any time you can identify the permissions for any file or directories in your present working directory by typing: LS -LD We can see the 9 bit permissions associated with each. In most cases, unless you are the root admin, your ability to alter permissions will be limited. If you own a file, you can use the CHMOD command to alter the permissions as you wish. The CHMOD command can change permissions with either numbers or letters. In our example we will be using numbers. With numbers, each permission is assigned a number, and you use each set’s total number to establish the permission. For example, you have written a bash script, and you only want you and your team to be able to execute it. You could apply permissions to it by typing: CHMOD 750 (followed by the filename). This gives you; the owner, full permissions and your group the ability to read and execute, but not write. All others are entirely prohibited. Permissions can also be applied to a directory recursively, meaning that it will apply the permission to all files and subdirectories contained in that directory. Thank you for watching and don’t forget to subscribe to the SMKS Channel. In the next lesson we will look into Ownership. References: Linux Bible 8th Bible

Published by: OpenCanvas Published at: 9 years ago Category: علمی و تکنولوژی