【问题标题】:How to Create Custom Command in Linux? [closed]如何在 Linux 中创建自定义命令? [关闭]
【发布时间】:2021-04-17 16:26:18
【问题描述】:

我是 Linux 新手,我想知道是否可以创建自定义 Linux 命令: 例如

LearningPhase1 cpu getinfo 

显示与 lscpu 命令相似的输出

LearningPhase1 memory getinfo

获取我电脑的内存信息

另外,我想知道我是否可以使用我自己的自定义命令创建新用户

LearningPhase1 user create <username>

创建新用户

LearningPhase1 user list

获取我电脑的所有用户

LearningPhase1 user list --sudo-only

获取具有 sudo 权限的用户

这是我关于 stackoverflow 的问题。 任何与此相关的链接、材料或帮助将不胜感激。 请帮助我了解有关这些内容的更多信息。

【问题讨论】:

    标签: linux shell ubuntu terminal command


    【解决方案1】:

    Linux shell 查找存储在 特定位置 中的程序,如果存在名为 LearningPhase1 的程序,它们会将其作为命令执行。

    您必须编写程序并将其二进制文件或其代码(如果已解释)放在这些特定位置。

    您可以通过以下方式查看这些特定位置:

    echo $PATH
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-02-24
      • 2011-10-19
      • 1970-01-01
      • 2020-07-23
      • 1970-01-01
      • 2018-03-26
      • 2016-06-23
      相关资源
      最近更新 更多