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
umask(1)						      General Commands Manual							  umask(1)

NAME
umask - Displays or sets the file mode creation mask SYNOPSIS
umask [-S] [mask] Note The C shell has a built-in version of the umask command. If you are using the C shell, and want to guarantee that you are using the com- mand described here, you must specify the full path /usr/bin/umask. See the csh(1) reference page for a description of the built-in com- mand. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: umask: XCU5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. OPTIONS
Produce symbolic output. Output is produced in a format that is recognized on a subsequent invocation of umask as a mask operand to restore the previous file mode creation mask. If the -S option is not used, output is displayed as an octal integer, but is still usable as input on a subsequent invocation of the umask command. OPERANDS
A string specifying the new file mode creation mask. This string may may be an octal value or a symbolic_mode value. For a symbolic_mode value, the new value of the file mode creation mask is the logical complement of the file permission bits por- tion of the file mode specified by the symbolic_mode string. In a symbolic_mode value, the characters + and - are interpreted relative to the current file mode creation mask; + causes the bits for the indicated permissions to be cleared in the mask; - causes the bits for the indicated permissions to be set in the mask. The file mode creation mask is set to the resulting numeric value. In the obsolescent octal integer form of mode, the specified bits are set in the file mode creation mask. DESCRIPTION
The umask command sets the file mode creation mask of the current shell execution environment to the value specified by the mask oper- and. This mask affects the initial value of the file permission bits of subsequently created files. If the mask operand is not specified, the umask command writes the value of the invoking process's file mode creation mask to standard out- put. If the -S option is specified, the output is in the following format: "u=%s,g=%s,o=%s ", <owner permissions>, <group permissions>, <other permissions>" The three values are combinations of letters from the set {r, w, x}; the presence of a letter indicates that the corresponding bit is clear in the file mode creation mask. NOTES
Any mask operand such as -r, -w, -x, or anything beginning with a hyphen, must be preceded by -- to keep it from being interpreted as a option. Since umask affects the current shell execution environment, it is provided as a shell regular built-in. In contrast to the nega- tive permission logic provided by the file mode creation mask and the octal number form of the mask argument, the symbolic form of the mask operand specifies those permissions that are left alone. Although the references to octal modes are obsolescent in the ISO/IEC 9945-2:1993 standard, they are maintained for portable applications until further notice. RESTRICTIONS
If umask is called in a subshell or separate utility execution environment, it does not affect the file mode creation mask of the caller's environment. A separate execution environment could be one of the following: (umask 002) nohup umask ... find . -exec umask ... ; EXIT STATUS
The following exit values are returned: The file mode creation mask was successfully changed, or no mask operand was supplied. An error occurred. EXAMPLES
To set the file mode creation mask so that subsequently created files have their write by all others bit cleared, enter either of the fol- lowing commands: umask a=rx,ug+w umask 002 If the file mode creation mask was set with either of the above commands, the umask command can be used to write out the current value of the mask. To write the value in octal format, enter: umask This provides the output: 0002 To write the value in symbolic format, enter: umask -S This provides the output: u=rwx,g=rwx,o=rx The following sequence of commands is an example of how to save the current file mode creation mask and later restore the value using the umask command and octal integer formats. Examine the current value of the mask: umask The current mask is reported as: 022 Save the current value, and verify the saved value: SAVEMASK =`umask` echo $SAVEMASK The saved value is reported as: 022 Change the current mask: umask 444 Verify the change: umask The new mask is reported: 0444 Restore the previous mask: umask $SAVEMASK Verify the restored value: umask The value is now restored: 022 The following sequence of commands is an example of how to save the current file mode creation mask and later restore the value using the umask command and symbolic_mode formats. Examine the current value of the mask: umask -S The current mask is reported as: u=rwx,g=rx,o=rx Save the current value, and verify the saved value: SAVEMASK=`umask -S` echo $SAVE- MASK The saved value is reported as: u=rwx,g=rx,o=rx Change the current mask: umask a= Verify the change: umask -S The new mask is reported: u=,g=,o= Restore the previous mask: umask $SAVEMASK Verify the restored value: umask -S The value is now restored: u=rwx,g=rx,o=rx To set the file mode creation mask so that subsequently created files have all their write bits cleared, enter: umask -- -w ENVIRONMENT VARIABLES
The following environment variables affect the execution of umask: Provides a default value for the internationalization variables that are unset or null. If LANG is unset or null, the corresponding value from the default locale is used. If any of the internationalization vari- ables contain an invalid setting, the utility behaves as if none of the variables had been defined. If set to a non-empty string value, overrides the values of all the other internationalization variables. Determines the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multibyte characters in arguments). Determines the locale for the for- mat and contents of diagnostic messages written to standard error. Determines the location of message catalogues for the processing of LC_MESSAGES. SEE ALSO
Commands: chmod(1) Functions: chmod(2), umask(2) Standards: standards(5) umask(1)
All times are GMT -4. The time now is 05:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy