Sponsored Content
Full Discussion: find -perm query
Top Forums UNIX for Dummies Questions & Answers find -perm query Post 302097784 by Perderabo on Tuesday 28th of November 2006 01:28:36 PM
Old 11-28-2006
You have to know octal - binary conversion. 020 in octal is 000010000 in binary. And looking at the permission bits:
rwx rwx rwx
000 010 000

So we start with all zeros and replace the zero with a one if we are interested in that bit. Then we convert to octal. See my article on file permissions in our tips and tutorials section for more info.
 

10 More Discussions You Might Find Interesting

1. Programming

change semaphore perm

Hi, I've a problem with this simple code about of semaphore: #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<semaphore.h> #include<sys/types.h> #include<sys/mman.h> #include<sys/fcntl.h> #define SemName "/SEM_1" int main (int argc, char **argv) { char name;... (5 Replies)
Discussion started by: FastMagister
5 Replies

2. Shell Programming and Scripting

perm bits

hi, in other previous post, someone suggested to set the " perm bits " to lock the file such that preventing others write to that same file, could someone please explain exactly what is perm bits and how can I achieve the desired result? Thanks! (1 Reply)
Discussion started by: mpang_
1 Replies

3. Shell Programming and Scripting

Wild card in find perm

Hi, Is there a way to use find command to list the directories for certain permissions. I know we can use find . -type d -perm nnn, where nnn is the permission number . However I wold like to know if I wanna search for wild card permissions i.e 75* / 7* / 55* , as i do not know the actual... (1 Reply)
Discussion started by: braindrain
1 Replies

4. UNIX for Dummies Questions & Answers

find -mtime query

Hello everyone, I have got two queries: 1) I want to do some work on files that were last modified yesterday. Will find ... -mtime -2 be correct or -mtime-1? 2)What about finding files that were modified today? Will it be -mtime -0 or -mtime -1? Thanks. (1 Reply)
Discussion started by: Rajat
1 Replies

5. UNIX for Dummies Questions & Answers

File Perm settings

we have a file particular group(say abc) and we have a user(say def) in that group.I created file ram.txt it looked like this.. -rwxr--r-- 1 def abc 10 Oct 16 03:54 ram.txt I changed the owner and group of the file as below -rwxr--r-- 1 kriz test 10 Oct 16 03:58 ram.txt when I log in as... (3 Replies)
Discussion started by: ramkriz
3 Replies

6. Shell Programming and Scripting

find and replace query

Hello ppl, I am writing a script which finds multiple words match and replace it with new words. I have server.conf file which looks like ### Welcome to server ### ### Server address and port ### Server=127.0.0.1 ### Replace Server=0.0.0.0 ### ServerPort=0 ### Replace... (11 Replies)
Discussion started by: lightdensity
11 Replies

7. Shell Programming and Scripting

Help with find -perm option

How to find all files for instance that match the permission rwxr*x--- where * is a wildcard which can be optionally asserted but all the others must match? Thanks in advance (7 Replies)
Discussion started by: stevensw
7 Replies

8. Red Hat

Sudo perm to troubleshooting

I am building an access template of what types of commands I will need sudo, to support an installed application and view log files in general what commands are recommended is there a general of what would be useful on Red Hat? (1 Reply)
Discussion started by: NelsonC
1 Replies

9. Shell Programming and Scripting

Find query

when i search for a file using find i want to be able to cd to the directory of the file simple find i'm using is find . -name <filename> the output is the full path to the file, i want to use the output to cd into the directory... I need to add this into a script Any ideas pls (2 Replies)
Discussion started by: duckeggs01
2 Replies

10. UNIX for Dummies Questions & Answers

How to find directory listing from root to all files in tree format with details of perm/own/grp?

Hi, My apologies if my query is already available on this forum but I am new and could not find. I need a script to list all directories/sub directories and files with permissions/groups/owners. The script would run from home directory and should capture every directory. How do I do this? ... (4 Replies)
Discussion started by: 8709711
4 Replies
CHMOD(1)						    BSD General Commands Manual 						  CHMOD(1)

NAME
chmod -- change file modes SYNOPSIS
chmod [-fhv] [-R [-H | -L | -P]] mode file ... DESCRIPTION
The chmod utility modifies the file mode bits of the listed files as specified by the mode operand. The options are as follows: -H If the -R option is specified, symbolic links on the command line are followed. (Symbolic links encountered in the tree traversal are not followed by default.) -L If the -R option is specified, all symbolic links are followed. -P If the -R option is specified, no symbolic links are followed. This is the default. -R Change the modes of the file hierarchies rooted in the files instead of just the files themselves. -f Do not display a diagnostic message if chmod could not modify the mode for file. -h If the file is a symbolic link, change the mode of the link itself rather than the file that the link points to. -v Cause chmod to be verbose, showing filenames as the mode is modified. If the -v flag is specified more than once, the old and new modes of the file will also be printed, in both octal and symbolic notation. The -H, -L and -P options are ignored unless the -R option is specified. In addition, these options override each other and the command's actions are determined by the last one specified. Only the owner of a file or the super-user is permitted to change the mode of a file. DIAGNOSTICS
The chmod utility exits 0 on success, and >0 if an error occurs. MODES
Modes may be absolute or symbolic. An absolute mode is an octal number constructed from the sum of one or more of the following values: 4000 (the set-user-ID-on-execution bit) Executable files with this bit set will run with effective uid set to the uid of the file owner. Directories with the set-user-id bit set will force all files and sub-directories created in them to be owned by the directory owner and not by the uid of the creating process, if the underlying file system supports this feature: see chmod(2) and the suiddir option to mount(8). 2000 (the set-group-ID-on-execution bit) Executable files with this bit set will run with effective gid set to the gid of the file owner. 1000 (the sticky bit) See chmod(2) and sticky(8). 0400 Allow read by owner. 0200 Allow write by owner. 0100 For files, allow execution by owner. For directories, allow the owner to search in the directory. 0040 Allow read by group members. 0020 Allow write by group members. 0010 For files, allow execution by group members. For directories, allow group members to search in the directory. 0004 Allow read by others. 0002 Allow write by others. 0001 For files, allow execution by others. For directories allow others to search in the directory. For example, the absolute mode that permits read, write and execute by the owner, read and execute by group members, read and execute by oth- ers, and no set-uid or set-gid behaviour is 755 (400+200+100+040+010+004+001). The symbolic mode is described by the following grammar: mode ::= clause [, clause ...] clause ::= [who ...] [action ...] action action ::= op [perm ...] who ::= a | u | g | o op ::= + | - | = perm ::= r | s | t | w | x | X | u | g | o The who symbols ``u'', ``g'', and ``o'' specify the user, group, and other parts of the mode bits, respectively. The who symbol ``a'' is equivalent to ``ugo''. The perm symbols represent the portions of the mode bits as follows: r The read bits. s The set-user-ID-on-execution and set-group-ID-on-execution bits. t The sticky bit. w The write bits. x The execute/search bits. X The execute/search bits if the file is a directory or any of the execute/search bits are set in the original (unmodified) mode. Operations with the perm symbol ``X'' are only meaningful in conjunction with the op symbol ``+'', and are ignored in all other cases. u The user permission bits in the original mode of the file. g The group permission bits in the original mode of the file. o The other permission bits in the original mode of the file. The op symbols represent the operation performed, as follows: + If no value is supplied for perm, the ``+'' operation has no effect. If no value is supplied for who, each permission bit specified in perm, for which the corresponding bit in the file mode creation mask is clear, is set. Otherwise, the mode bits represented by the specified who and perm values are set. - If no value is supplied for perm, the ``-'' operation has no effect. If no value is supplied for who, each permission bit specified in perm, for which the corresponding bit in the file mode creation mask is clear, is cleared. Otherwise, the mode bits represented by the specified who and perm values are cleared. = The mode bits specified by the who value are cleared, or, if no who value is specified, the owner, group and other mode bits are cleared. Then, if no value is supplied for who, each permission bit specified in perm, for which the corresponding bit in the file mode creation mask is clear, is set. Otherwise, the mode bits represented by the specified who and perm values are set. Each clause specifies one or more operations to be performed on the mode bits, and each operation is applied to the mode bits in the order specified. Operations upon the other permissions only (specified by the symbol ``o'' by itself), in combination with the perm symbols ``s'' or ``t'', are ignored. EXAMPLES
644 make a file readable by anyone and writable by the owner only. go-w deny write permission to group and others. =rw,+X set the read and write permissions to the usual defaults, but retain any execute permissions that are currently set. +X make a directory or file searchable/executable by everyone if it is already searchable/executable by anyone. 755 u=rwx,go=rx u=rwx,go=u-w make a file readable/executable by everyone and writable by the owner only. go= clear all mode bits for group and others. g=u-w set the group bits equal to the user bits, but clear the group write bit. BUGS
There's no perm option for the naughty bits. COMPATIBILITY
The -v option is non-standard and its use in scripts is not recommended. SEE ALSO
chflags(1), install(1), chmod(2), stat(2), umask(2), fts(3), setmode(3), symlink(7), chown(8), mount(8), sticky(8) STANDARDS
The chmod utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compatible with the exception of the perm symbol ``t'' which is not included in that standard. HISTORY
A chmod command appeared in Version 1 AT&T UNIX. BSD
March 31, 1994 BSD
All times are GMT -4. The time now is 05:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy