create directory and set owner/group/mode in one shot

install -o user -g group -m 0700 -d /path/to/newdir

6
2009-07-26 10:37:10

These Might Interest You

  • Copy both perms and owner group from one file to another.


    2
    for i in chmod chown; do sudo "$i" --reference=/home/user/copyfromfile /tmp/targetfile; done
    zlemini · 2014-08-28 15:08:32 0
  • This is useful when you want to copy a file and also force a user, a group and a mode for that file. Note: if you want to move that file instead of copying it, you can use install -o user -g group -m 755 /path/to/file /path/to/dir/ && rm -f /path/to/file which will remove the file only if the install command went fine.


    1
    install -o user -g group -m 755 /path/to/file /path/to/dir/
    raphink · 2009-02-18 10:46:19 0
  • A web server using $HOME/public_html as user directory is required, $HOME/public_html/shots must exist and have appropriate access rights and $HOSTNAME must be known to and accessible from the outside world. The command uses scrot to create a screen shot, moves it to the screen shot directory, uses xsel to copy the URL to the paste buffer (so that you can paste it with a middle click) and finally uses feh to display a preview of the screen shot. Assign this command to a key combination or an icon in whatever panel you use.


    0
    scrot -e 'mv $f \$HOME/public_html/shots/; echo "http://\$HOSTNAME/~\$USER/shots/$f" | xsel -i; feh `xsel -o`'
    penpen · 2009-03-26 11:32:09 1
  • Meaning of switches (see man page too): v verbose p ignore mode (permissions) o ignore owner, group t ignore time of modification Disadvantage: If you modify any linked file, this will propagate to all other files which occupy the same space. Show Sample Output


    1
    hardlink -vpot .
    knoppix5 · 2012-04-09 12:40:38 0

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

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.

Share Your Commands



Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: