如何在linux中创建自动运行文件并执行shell文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3802752/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:17:54  来源:igfitidea点击:

How to create a autorun file in linux and execute a shell file?

linuxunixubunturedhatautorun

提问by Big Bang Theory

How to create a autorun file in linux which is similar to autorun.inf in Windows in order to execute a shell file ie Following are the requirment

如何在Linux中创建一个类似于Windows中的autorun.inf的自动运行文件以执行shell文件,即以下是要求

1.Autorun the installer file ./example.sh

1.自动运行安装文件./example.sh

When CD is mounted onto the system .

当 CD 安装到系统上时。

回答by h_b

this is not possible. would be too much of a risk. You can of course do this for your own system in various variants. for example cronjobs. but i suppose you want it to run on any other system...

这不可能。风险太大。您当然可以在各种变体中为您自己的系统执行此操作。例如 cronjobs。但我想你希望它在任何其他系统上运行......

回答by Aboelnour

Rule #1 in Linux's Security: Any new Executable file come to system haven't the due to execute himself without permission from his user/owner :) you can make an autorun for your system but for other systems nop I guess

Linux 安全性中的规则 #1:任何新的可执行文件进入系统都不会在未经用户/所有者许可的情况下自行执行 :) 您可以为您的系统自动运行,但我猜对于其他系统没有

回答by Barun Parichha

we might use our udev rules :

我们可能会使用我们的 udev 规则:

mount /mnt/flash && sh /mnt/flash/autorun.sh

with proper device signature (product id, device id).

具有正确的设备签名(产品 ID、设备 ID)。

or

或者

use "autorun" command, which currently works with cdrom.

使用“autorun”命令,该命令目前适用于 cdrom。