English 中文(简体)
如何创建目录和准许单一指挥
原标题:How to create a directory and give permission in single command

• 如何在含水层建立目录和准许单一指挥?

我必须完全允许地制作许多文件夹777

Commands

mkdir path/foldername
chmod 777 path/foldername 

我不想在两个指挥部中制造和准许。 我能否在单一指挥下这样做?

最佳回答

http://linux.die.net/man/1/mkdir”rel=“noreferer” 页: 1

mkdir -m 777 dirname
问题回答

现有名录:

mkdir -m 777 /path/to/your/dir

如果该名录不存在,而且你希望创建母系:

mkdir -m 777 -p /parent/dirs/to/create/your/dir
install -d -m 0777 /your/dir

你们应该给予你们希望的东西。 了解每个用户都有权在该名录中添加和删除档案。

海事组织在这种情况下更好地利用<代码>install。 我正试图使“密码”在座标上连续不断。

install -d  -g systemd-journal -m 2755 -v /var/log/journal

您可以撰写一份简单的剪辑,例如:

#!/bin/bash
mkdir "$1"
chmod 777 "$1"

Once saved, and the executable flag enabled, you could run it instead of mkdir and chmod:

./scriptname path/foldername

然而, s 答案好得多,因为它使一个进程而不是三个进程。 我不知道<代码>-m选项。

you can use following command to create directory and give permissions at the same time

mkdir -m777 path/foldername 

仅扩大和改善上述部分答复:

首先,我检查了8.26德国公民联盟核心功用的 m子——它向我们提供了有关选择——m和-p(也分别作为——mode=MODE和——父母)的信息:

......set[s] 文档模式(如chmod),而不是“rwx-umask

......如果存在的话,根据需要编制父母名录,则无错误

我认为,这些发言含糊不清。 但基本上说,你可以通过“数字表示”的许可来制作该名录,或者你可以“另一种方式”并使用一种/your umask。

Side note: I say "the other way" since the umask value is actually exactly what it sounds like -- a mask, hiding/removing permissions rather than "granting" them as with chmod s numeric octal notation.

You can execute the shell-builtin command umask to see what your 3-digit umask is; for me, it s 022. This means that when I execute mkdir yodirectory in a given folder (say, mahome) and stat it, I ll get some output resembling this:

               755                   richard:richard         /mahome/yodirectory
 #          permissions                 user:group      what I just made (yodirectory),
 # (owner,group,others--in that order)                 where I made it (i.e. in mahome)
 # 

Now, to add just a tiny bit more about those octal permissions. When you make a directory, "your system" take your default directory perms [which applies for new directories (its value should 777)] and slaps on yo(u)mask, effectively hiding some of those perms . My umask is 022--now if we "subtract" 022 from 777 (technically subtracting is an oversimplification and not always correct - we are actually turning off perms or masking them)...we get 755 as stated (or "statted") earlier.

We can omit the 0 in front of the 3-digit octal (so they don t have to be 4 digits) since in our case we didn t want (or rather didn t mention) any sticky bits, setuids or setgids (you might want to look into those, btw, they might be useful since you are going 777). So in other words, 0777 implies (or is equivalent to) 777 (but 777 isn t necessarily equivalent to 0777--since 777 only specifies the permissions, not the setuids, setgids, etc.)

Now, to apply this to your question in a broader sense--you have (already) got a few options. All the answers above work (at least according to my coreutils). But you may (or are pretty likely to) run into problems with the above solutions when you want to create subdirectories (nested directories) with 777 permissions all at once. Specifically, if I do the following in mahome with a umask of 022:

mkdir -m 777 -p yodirectory/yostuff/mastuffinyostuff
# OR (you can swap 777 for 0777 if you so desire, outcome will be the same)
install -d -m 777 -p yodirectory/yostuff/mastuffinyostuff

页: 1 页: 1 因此,<代码>umask似乎是在<代码>yodirectory和yostuff上穿透的。

( umask 000 && mkdir -p yodirectory/yostuff/mastuffinyostuff )

and that s it. 777 perms for yostuff, mastuffinyostuff, and yodirectory.

Don t do: mkdir -m 777 -p a/b/c since that will only set permission 777 on the last directory, c; a and b will be created with the default permission from your umask.

a. 在座标上填满舱位的子座标上设置新的名录:777;

(umask u=rwx,g=rwx,o=rwx && mkdir -p a/b/c)

请注意,如果已经存在任何一种、b和c的许可,则这种得票没有改变。





相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签