Also works with:
chgrp --reference file1 file2
chown --reference file1 file2
With GNU chmod at least it is that simple.
Example: touch file{1,2,3}; chmod 777 !*
In addition to a swap partition, Linux can also use a swap file. Some programs, like g++, can use huge amounts of virtual memory, requiring the temporary creation of extra space.
Good for fixing web permissions. You might also want to do something like this and skip files or directories that begin with a period:
find public_html/stuff -not -name ".*" \( -type d -exec chmod 755 {} + -o -type f -exec chmod 644 {} + \)
...or include a special case for scripts:
find public_html/stuff -type d -exec chmod 755 {} + -or -type f -name "*.pl" -exec chmod 755 {} + -or -exec chmod 644 {} +
To apply only to dirs:
chmod 755 $(find . -type d)
Use -R parameters for recursive walk.
+ at the end means that many filenames will be passed to every chmod call, thus making it faster. And find own {} makes sure that it will work with spaces and other characters in filenames.
Listens for events in the directory. Each created file is displayed on stdout. Then each fileline is read by the loop and a command is run. This can be used to force permissions in a directory, as an alternative for umask. More details: http://en.positon.org/post/A-solution-to-the-umask-problem%3A-inotify-to-force-permissions
(Please see sample output for usage) Use any script name (the read command gets it) and it will be encrypted with the extension .crypt, i.e.: myscript --> myscript.crypt You can execute myscript.crypt only if you know the password. If you die, your script dies with you. If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string). Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner. Sorry for the chmod on parentheses, I dont like "-" at the end. Thanks flatcap for the subshell abbreviation to /dev/null Show Sample Output
(Please see sample output for usage) script.bash is your script, which will be crypted to script.secure script.bash --> script.secure You can execute script.secure only if you know the password. If you die, your script dies with you. If you modify the startup line, be careful with the offset calculation of the crypted block (the XX string). Not difficult to make script editable (an offset-dd piped to a gpg -d piped to a vim - piped to a gpg -c directed to script.new ), but not enough space to do it on a one liner. Show Sample Output
Using `-exec cmd {} +` causes find to build the command using all matching filenames before execution, rather than once per file.
Makes any files in the current directory (and any sub-directories) group-readable. Using the "! -perm /g=r" limits the number of files to only those that do not already have this property Using "+" on the end of the -exec body tells find to build the entire command by appending all matching files before execution, so invokes chmod once only, not once per file.
I often use it at my work, on an ovh server with root ssh access and often have to change mod after having finished an operation. This command, replace the user, group and mod by the one required by apache to work.
Copy both perms and owner group from one file to another.
"find . -type d -print0 | xargs -0 chmod 755" thanks masterofdisaster
Useful if you have copied files from an OS without a permission structure (for example, DOS) and you need to disable all executable files but want to be able to descend into your directories.
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: