欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 教育 > 培训 > shellGPT自动生成Linux命令

shellGPT自动生成Linux命令

2025/5/11 10:03:27 来源:https://blog.csdn.net/u010198709/article/details/145844515  浏览:    关键词:shellGPT自动生成Linux命令

shellGPT自动生成Linux命令

  • 一、shellGPT工具介绍
  • 二、shellGPT安装
    • 1、安装openssl 1.1.1版本
      • 1.1 安装openssl 1.1.1
      • 1.2 查看openssl版本
    • 2、下载安装python3
    • 3、修改pip国内仓库
    • 4、安装shellGPT
    • 5、修改shellGPT的配置文件
    • 6、使用sgpt生成执行命令

一、shellGPT工具介绍

ShellGPT‌是一个由AI大型语言模型(LLM)驱动的命令行生产力工具,它允许用户通过终端与AI进行交互,执行各种任务和命令。

二、shellGPT安装

1、安装openssl 1.1.1版本

1.1 安装openssl 1.1.1

[root@localhost ~]# yum -y groupinstall "Development Tools"
[root@localhost ~]# yum -y install wget zlib-devel perl-core[root@localhost ~]# wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz
[root@localhost ~]# tar xf openssl-1.1.1t.tar.gz 
[root@localhost ~]# cd openssl-1.1.1t/
[root@localhost ~]# ./configure --prefix=/usr/local/openssl --openssldir=/usr/local/openssl 
[root@localhost ~]# make -j $(nproc)
[root@localhost ~]# make install
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin:/usr/local/openssl/bin
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH[root@localhost ~]# source /etc/profile
[root@localhost ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/openssl/lib[root@localhost ~]# ldconfig

1.2 查看openssl版本

[root@localhost shell_gpt]# openssl version
OpenSSL 1.1.1t  7 Feb 2023

2、下载安装python3

[root@localhost shell_gpt]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
[root@localhost shell_gpt]#  tar xf Python-3.12.8.tar.xz 
[root@localhost shell_gpt]#  cd Python-3.12.8/
[root@localhost shell_gpt]#  ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
[root@localhost shell_gpt]#  make 
[root@localhost shell_gpt]#  make install
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin:/usr/local/openssl/bin[root@localhost ~]# source /etc/profile
[root@localhost ~]# python3 --version
Python 3.12.8

3、修改pip国内仓库

[root@localhost ~]# cat /root/.pip/pip.conf 
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/[install]
trusted-host=mirrors.aliyun.com

4、安装shellGPT

[root@localhost ~]# pip3 install shell-gpt

5、修改shellGPT的配置文件

shell-gpt默认调用的是gpt,国内环境受限,修改其调用国内kimi api
在kimi api官方平台创建key, https://platform.moonshot.cn/console/account

[root@localhost shell_gpt]# pwd
/root/.config/shell_gpt[root@localhost shell_gpt]# vim .sgptrc 
DEFAULT_MODEL=moonshot-v1-8k
OPENAI_API_KEY=sk-9uZmRscj56VyR5TTeOwofkU24iE3NjhUreC65OidQiCiUPM8
API_BASE_URL=https://api.moonshot.cn/v1

6、使用sgpt生成执行命令

[root@localhost shell_gpt]# sgpt -s "查看网卡ens33的mac地址"
ip link show ens33 | grep ether | awk '{print $2}'
[E]xecute, [D]escribe, [A]bort: e
00:0c:29:cc:6b:2f

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词