Recent Changes - Search:

Basics

Languages

Tools

OS

Resources

PmWiki

pmwiki.org

edit SideBar

Chmod

File permissions is an important part of many usability. You might want your coworkers to be able to read files but not edit them. Maybe they could also run executables which you provide to them? And navigate your directories to make copies, but, again, not directly edit your files. You can set all that using chmod

The first thing to do is to check the current permissions, usually with ls?, like this:

 ls -l *
dr-xr-x--- 1 user group      0 Month  Day 13:25 Folder1
-r--r--r-- 1 user group   4231 Month  Day 13:25 File1
-rwxr-xr-x 1 user group   4231 Month  Day 13:25 File2
-rwxrwx--- 1 user group   4231 Month  Day 13:25 File3
-rwx------ 1 user group   4231 Month  Day 13:25 File4
-rwxr----- 1 user group   4231 Month  Day 13:25 File5

The above files show:

Folder1
A folder, which can be accessed (executed) only by the user and their group
File1
A file which everybody can read but do nothing else with
File2
A file which can be read, edited and ran by the user, but only read and ran by everyone else
File3
A file which can be read, edited and ran by the user and their group, but nobody else
File4
A file which can be read, edited and ran only by the user
File5
A file which can be read, edited and ran only by the user and also read by their group

In order to change the permission, chmod can be used. The easiest way to do so is to first define who you want to change permissions for, then if you want to add (+) or remove (-) a permission, then which permission. This looks like:

[@ chmod u-x g+r@ FirstTargetFile SecondTargetFile]

where the first series of tokens identify whose permission to change (u: users, g: group, o: others, a: all), how (+ or -), and which specifically (r: read, w: write, x: execute). The second series of tokens identify which files this will be applied to and can use wildcards as usual.

Edit - History - Print - Recent Changes - Search
Page last modified on October 02, 2019, at 02:26 PM