这一切都是在ubuntu中使用终端实现的。
在第一次创建文件之后采购文件时,您首先需要read权限吗?
然后,您需要executable权限才能执行,以便在使用ls -l filename时显示x
我不确定的是,当你源码的时候,哪个进程会执行这些内容?会是current shell吗?
那么,当您执行调用文件名的脚本时,您将使用new shell进程吗?
开始学习Linux,所以试图理解脚本的权限和进程。
发布于 2019-09-27 02:14:35
做一个小实验;
$ echo $$ # print PID of current shell
1234
$ echo 'echo $$' > test.sh # make a little shell script that just prints its PID
$ ls -l test.sh
-rw-rw-r-- 1 hlub hlub 10 Sep 26 20:01 test.sh
# no x'es: not executable
$ source test.sh # source it....
1234
# OK, that worked, even without execute permission,
# .... and we get the same PID:
# .... apparently "source" runs commands in the current shell
$ ./test.sh
zsh: permission denied: ./test.sh
# Oops! need execute permission
$ chmod a+x test.sh # make the script executable
$ ls -l test.sh
-rwxrwxr-x 1 hlub hlub 10 Sep 26 20:02 test.sh
# x'es, just as I expected!
$ ./test.sh
5678
# OK, so now the script executes in a new process!https://stackoverflow.com/questions/58121899
复制相似问题