shellGPT自动生成Linux命令

shellGPT自动生成Linux命令

一、shellGPT工具介绍

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

二、shellGPT安装

1、安装openssl 1.1.1版本

1.1 安装openssl 1.1.1

bash 复制代码
[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
bash 复制代码
[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
bash 复制代码
[root@localhost ~]# cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/openssl/lib

[root@localhost ~]# ldconfig

1.2 查看openssl版本

bash 复制代码
[root@localhost shell_gpt]# openssl version
OpenSSL 1.1.1t  7 Feb 2023

2、下载安装python3

bash 复制代码
[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
bash 复制代码
[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
bash 复制代码
[root@localhost ~]# vim /etc/profile
export PATH=$PATH:/usr/local/python3/bin:/usr/local/openssl/bin

[root@localhost ~]# source /etc/profile
bash 复制代码
[root@localhost ~]# python3 --version
Python 3.12.8

3、修改pip国内仓库

bash 复制代码
[root@localhost ~]# cat /root/.pip/pip.conf 
[global]
index-url = http://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

4、安装shellGPT

bash 复制代码
[root@localhost ~]# pip3 install shell-gpt

5、修改shellGPT的配置文件

shell-gpt默认调用的是gpt,国内环境受限,修改其调用国内kimi api

在kimi api官方平台创建key, https://platform.moonshot.cn/console/account

bash 复制代码
[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生成执行命令

bash 复制代码
[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
相关推荐
EveryPossible11 小时前
cpu展示示例
服务器
韦东东11 小时前
行业资讯日报自动化:从采集到 LLM 生成的全链路拆解(以政务网站为例)
运维·人工智能·自动化·大模型·llm·政务·行业资讯
tianyuanwo11 小时前
TERM变量迷思:从Jenkins节点连接差异看终端仿真与构建系统的微妙关系
运维·ssh·jenkins·java web·term
一勺菠萝丶11 小时前
Jenkins 打包显示 SUCCESS 但产物不全?日志出现 Killed 的排查与解决(小白版)
运维·jenkins
Java 码农11 小时前
RabbitMQ集群部署方案及配置指南01
linux·服务器·rabbitmq
tyatyatya11 小时前
Ansible自动化配置,从入门到实战
运维·自动化·ansible
郝学胜-神的一滴11 小时前
深入理解Linux中的Try锁机制
linux·服务器·开发语言·c++·程序人生
Anakki11 小时前
企业级 Elastic Stack 集成架构:Spring Boot 3.x 与 Elasticsearch 8.x 深度实践指南
运维·jenkins·springboot·elastic search
Java后端的Ai之路11 小时前
【AutoDL算力平台】-MobaXterm 连接 AutoDL 并上传文件资源(图文 + 实操)
服务器·网络·mobaxterm·autodl算力平台
阿巴~阿巴~11 小时前
NAT技术:互联网连接的隐形桥梁
服务器·网络·网络协议·架构·智能路由器·nat·正反向代理