Linux-command not found问题

一、telnet命令

1.检查telnet是否有安装

#有输出说明已安装,如果没有输出则没有安装

rpm -qa telnet

#安装telnet

yum install -y telnet

#执行检查命令
[root@localhost ~]# rpm -qa telnet
[root@localhost ~]# 

#安装telnet
[root@localhost ~]# yum install -y telnet
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package telnet.x86_64 1:0.17-66.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                         Arch                                            Version                                                  Repository                                        Size
=================================================================================================================================================================================================================
Installing:
 telnet                                          x86_64                                          1:0.17-66.el7                                            updates                                           64 k

Transaction Summary
=================================================================================================================================================================================================================
Install  1 Package

Total download size: 64 k
Installed size: 113 k
Downloading packages:
warning: /var/cache/yum/x86_64/7/updates/packages/telnet-0.17-66.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY                                        ]  0.0 B/s |    0 B  --:--:-- ETA 
Public key for telnet-0.17-66.el7.x86_64.rpm is not installed
telnet-0.17-66.el7.x86_64.rpm                                                                                                                                                             |  64 kB  00:00:00     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
 Userid     : "CentOS-7 Key (CentOS 7 Official Signing Key) <security@centos.org>"
 Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
 Package    : centos-release-7-6.1810.2.el7.centos.x86_64 (@anaconda)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:telnet-0.17-66.el7.x86_64                                                                                                                                                                   1/1 
  Verifying  : 1:telnet-0.17-66.el7.x86_64                                                                                                                                                                   1/1 

Installed:
  telnet.x86_64 1:0.17-66.el7                                                                                                                                                                                    

Complete!
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 


#检查是否安装成功
[root@localhost ~]# rpm -qa telnet
telnet-0.17-66.el7.x86_64
[root@localhost ~]# 

2.检查telnet-server服务是否安装

#有输出说明已安装,如果没有输出则没有安装

rpm -qa telnet-server

#安装telnet

yum install -y telnet-server

#检查telcet-server是否安装

[root@localhost ~]# rpm -qa telnet-server
[root@localhost ~]# 
[root@localhost ~]# 

#安装telnet-server
[root@localhost ~]# yum install -y telnet-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.163.com
 * extras: mirrors.huaweicloud.com
 * updates: mirrors.huaweicloud.com
Resolving Dependencies
--> Running transaction check
---> Package telnet-server.x86_64 1:0.17-66.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================================================
 Package                                              Arch                                          Version                                                 Repository                                      Size
=================================================================================================================================================================================================================
Installing:
 telnet-server                                        x86_64                                        1:0.17-66.el7                                           updates                                         41 k

Transaction Summary
=================================================================================================================================================================================================================
Install  1 Package

Total download size: 41 k
Installed size: 55 k
Downloading packages:
telnet-server-0.17-66.el7.x86_64.rpm                                                                                                                                                      |  41 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : 1:telnet-server-0.17-66.el7.x86_64                                                                                                                                                            1/1 
  Verifying  : 1:telnet-server-0.17-66.el7.x86_64                                                                                                                                                            1/1 

Installed:
  telnet-server.x86_64 1:0.17-66.el7                                                                                                                                                                             

Complete!
[root@localhost ~]# 
[root@localhost ~]# 


#检查telnet是否安装
[root@localhost ~]# rpm -qa telnet-server
telnet-server-0.17-66.el7.x86_64
[root@localhost ~]# 

3.如果进行了telnet-server安装操作,且已成功安装,则由于telnet服务是由xinetd守护的,所以我们需要重新启动xinetd

service xinetd restart

[test@localhost ~]$ service xinetd restart
Redirecting to /bin/systemctl restart xinetd.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to manage system services or units.
Authenticating as: root
Password: 



polkit-agent-helper-1: pam_authenticate failed: Authentication failure
==== AUTHENTICATION FAILED ===
Failed to restart xinetd.service: Access denied
See system logs and 'systemctl status xinetd.service' for details.
[test@localhost ~]$ 
[test@localhost ~]$ 
[test@localhost ~]$ 
[test@localhost ~]$

#如果执行报以上错误,则检查是否没有安装xinetd

rmp -qa xinetd

#安装xinetd

yum install -y xinetd

[root@localhost /]# rpm -qa xinetd
xinetd-2.3.15-14.el7.x86_64
[root@localhost /]# 

#重启xinetd
/bin/systemctl restart xinetd.service

[root@localhost /]# /bin/systemctl restart xinetd.service
[root@localhost /]# 

#xinetd启动成功,可以查看xinetd的运行情况
netstat -tnlp

4.可以ping通,但是telnet命令连接失败

[root@localhost ~]# ping 192.168.1.147
PING 192.168.1.147 (192.168.1.147) 56(84) bytes of data.
64 bytes from 192.168.1.147: icmp_seq=1 ttl=128 time=0.702 ms
64 bytes from 192.168.1.147: icmp_seq=2 ttl=128 time=1.50 ms
64 bytes from 192.168.1.147: icmp_seq=3 ttl=128 time=1.76 ms
^X64 bytes from 192.168.1.147: icmp_seq=4 ttl=128 time=1.80 ms
^C
--- 192.168.1.147 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3034ms
rtt min/avg/max/mdev = 0.702/1.442/1.804/0.443 ms
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# telnet 192.168.1.147 6379
Trying 192.168.1.147...
telnet: connect to address 192.168.1.147: Connection refused

可能存在情况:

1)物理网络链路不通:从A地点到B地点没有路可以走

2)防火墙没有开通相关网络:从A地点到B地点由路,但是有路障

3)目标主机没有启动:就没有B地点

我需要连接的是win系统的服务,

可以ping通,说明应该是防火墙有拦截

为指定端口设置规则:

打开win系统的防火墙设置

选择高级选项

选择入站规则,选中新建规则

选择端口、选择特定本地端口、输入端口号、选择允许连接、下一步保存

放开防火墙后,发现还是连接不上

通过查询资料发现,原来redis是开启了受保护模式

将redis.conf中的protected-mode设置为yes(保护模式),外网按理说无法访问
但是protected-mode它启用的条件有两个,第一是没有使用bind,第二是没有设置访问密码(默认没有密码),因此我们注释bind外面就访问不到了,
所以我们使用密码或者设置bind都会让保护模式失效,这样外网就能访问到。

127.0.0.1:6379>
127.0.0.1:6379>
127.0.0.1:6379> config get "protected-mode"
1) "protected-mode"
2) "yes"
127.0.0.1:6379> config set "protected-mode" no
OK
127.0.0.1:6379> config get "protected-mode"
1) "protected-mode"
2) "no"
127.0.0.1:6379>

5.切换用户

#当安装某些工具时,没有权限,需要切换用户

You need to be root to perform this command.

#需要root超级管理员权限才能执行特定命令,执行以下命令切换用户

su

此时需要输入密码

You need to be root to perform this command.
[test@localhost /]$ su
Password: 
[root@localhost /]#

二、Shell

1.在编写shell脚本时,为变量赋值,出现line 3: name: command not found

#注释
name = "test"
echo $name
unset name
echo $name

 解决:为变量赋值时,= 前后不能有空格

<think>嗯,用户遇到了“debootstrap command not found”的问题,我需要帮他们解决。首先,debootstrap是什么?它是一个用来安装基本Debian/Ubuntu系统的工具,通常在容器或chroot环境中使用。如果命令找不到,那通常是因为没有安装这个软件包。 用户可能是在Linux系统上尝试使用debootstrap,比如Ubuntu或CentOS。不同的发行版安装方法可能不同。首先应该检查是否安装了debootstrap。在基于Debian/Ubuntu的系统上,可以用apt来安装。但用户提到参考引用中有提到Ubuntu子系统没有安装apt,这可能是因为他们使用的base镜像太精简了,需要先安装apt。不过正常情况下,apt应该是存在的。可能需要先更新软件源,再安装debootstrap。 对于CentOS或RHEL系统,debootstrap可能不在默认仓库中,需要启用EPEL仓库,然后用yum或dnf安装。用户提供的引用中有提到关闭SELinux的情况,比如引用3中的解决方案,所以如果安装后还有问题,可能需要检查SELinux是否开启,尝试暂时关闭它看看是否有帮助。 另外,用户可能是在Docker环境中操作,引用4提到Docker是容器引擎,所以如果是在Dockerfile里使用,需要确保安装debootstrap的步骤被正确写入,或者在基础镜像中预先安装。如果用户是在LXC容器里,如引用3中的情况,可能需要确保容器配置正确,网络可用,能够下载软件包。 步骤应该是:1. 根据系统类型安装debootstrap;2. 处理可能的依赖问题;3. 检查网络连接;4. 如果权限或安全策略导致问题,调整SELinux或AppArmor设置;5. 测试安装后的命令是否可用。 另外,用户提到的引用2中关于添加Docker仓库的错误,可能和系统版本或仓库配置有关,但当前问题主要是debootstrap未找到,所以重点放在安装该工具上。需要提醒用户根据他们的具体系统选择合适的安装方法,并注意可能的依赖和配置问题。</think>### 解决`debootstrap command not found`的步骤 #### 1. 确认系统环境 首先需要明确当前操作系统的发行版类型: - **Debian/Ubuntu**:默认支持`debootstrap`,但可能需要手动安装。 - **CentOS/RHEL**:需通过第三方仓库(如EPEL)安装。 - **容器或子系统环境**(如LXC、Docker或WSL):需确保基础镜像包含必要组件[^4]。 #### 2. 安装debootstrap 根据系统类型选择安装方式: **Debian/Ubuntu**: ```bash sudo apt update && sudo apt install debootstrap ``` 若提示`apt not found`(如某些精简版子系统[^1]),需先修复基础环境: ```bash # 尝试安装apt sudo apt-get install --reinstall apt ``` **CentOS/RHEL**: ```bash # 启用EPEL仓库 sudo yum install epel-release sudo yum install debootstrap # 或使用dnf(新版本) sudo dnf install debootstrap ``` #### 3. 验证安装 ```bash which debootstrap # 应返回路径如/usr/sbin/debootstrap ``` #### 4. 常见问题处理 - **依赖缺失**:安装时若报错依赖问题,尝试补充安装: ```bash sudo apt install wget gnupg # Debian/Ubuntu sudo yum install wget # CentOS/RHEL ``` - **网络问题**:确保可访问软件仓库(如检查`/etc/apt/sources.list`配置[^2])。 - **SELinux限制**:若权限异常(如引用[3]的场景),临时关闭SELinux: ```bash sudo setenforce 0 # 临时生效 ``` #### 5. 特殊场景:容器环境 在Docker或LXC中操作时: ```dockerfile # Dockerfile示例(Ubuntu) FROM ubuntu:20.04 RUN apt update && apt install -y debootstrap ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值