Bash Commands - chmod # Invoking script

1. Invoke

Having written the script, you can invoke it by bash scriptname

Much more convenient is to make the script itself directly executable with a chmod.

Either:

$ chmod 555 scriptname            (gives everyone read/execute permission)  or

$ chmod +rx scriptname             (gives everyone read/execute permission)


$ chmod u+rx scriptname            (gives only the script owner read/execute permission)

2. Test

Having made the script executable, you may now test it by

./scriptname


For example:

$ cat >test_chmod << "EOF"                # Create a (script) file named test_chmod.

> #!/bin/bash                                              # the "sha-bang" line. Indicate calling command interpreter.

> echo "Hello,bash world!"                    # Write a script command.

> EOF                                                           # End the file.

$ chmod 555 test_chmod                      # Invoke the script file, gives everyone read/execute permission.

$ ./test_chmod                                          # test it!

Hello,bash world!                                      # The script file was run.

3. "sha-bang" line

#!/bin/sh
#!/bin/bash
#!/usr/bin/perl
#!/usr/bin/tcl
#!/bin/sed -f
#!/bin/awk -f

Each of the above script header lines calls a different command interpreter, be it /bin/sh, the default shell
(bash in a Linux system) or otherwise.

Note: $chmod 4755 filename                   # Give filename root permission.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值