完美解决xshell输入tree命令后显示找不到该命令-bash: tree: command not found

本文详细解释了在Linux环境下,当遇到输入tree命令却提示'command not found'时的解决办法。针对Ubuntu和CentOS系统,分别提供了安装tree命令的方法,并解决了因环境变量配置错误导致的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题描述

xshell输入tree命令后显示找不到该命令-bash: tree: command not found

错误原因

系统中没有安装tree这个东西,需要安装tree后才行

解决办法

  1. 如果你的Linux系统是Ubuntu版的,输入下面命令安装即可
sudo apt-get install tree
  1. 如果你的Linux系统是cent os 版的,输入下面命令安装即可
yum -y install tree

出现如下页面就是安装成功了,此时再执行tree命令即可
在这里插入图片描述

如果你系统中有安装tree 但是还是执行找不到该命令的话,那原因就是:环境变量错误,编辑 /etc/profile文件中出错。导致系统命令无法识别。

解决办法:在命令行下输入以下内容即可:

export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

以上若无法彻底解决问题,请检查 /etc/profile中添加的环境变量命令是否正确,问题一定在这里,无需质疑。
下面是我改了之后的环境变量,供大家参考:

在这里插入图片描述

修改 /etc/profile 文件后,立即使环境变量生效:
在命令下输入:source /etc/profile

本文参考了:
https://blog.youkuaiyun.com/nasohaohao/article/details/100519129
https://blog.youkuaiyun.com/marblue_/article/details/90510948

Xshell 8 (Build 0068) Copyright (c) 2024 NetSarang Computer, Inc. All rights reserved. Type `help' to learn how to use Xshell prompt. [C:\~]$ Connecting to 192.168.3.57:22... Connection established. To escape to local shell, press 'Ctrl+Alt+]'. Welcome to Ubuntu 18.04.5 LTS (GNU/Linux 4.9.140-tegra aarch64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage This system has been minimized by removing packages and content that are not required on a system that users do not log into. To restore this content, you can run the 'unminimize' command. 762 packages can be updated. 440 of these updates are security updates. To see these additional updates run: apt list --upgradable Last login: Wed Mar 26 11:18:21 2025 from 192.168.3.62 bingda@robot:~$ ls /usr/bin | grep nvidia-smi bingda@robot:~$ lsmod | grep nvidia bingda@robot:~$ nvidia-smi -bash: nvidia-smi: command not found bingda@robot:~$ sudo dpkg -i backport-iwlwifi-dkms_9858-0ubuntu3_all.deb [sudo] password for bingda: Selecting previously unselected package backport-iwlwifi-dkms. (Reading database ... 215988 files and directories currently installed.) Preparing to unpack backport-iwlwifi-dkms_9858-0ubuntu3_all.deb ... Unpacking backport-iwlwifi-dkms (9858-0ubuntu3) ... dpkg: dependency problems prevent configuration of backport-iwlwifi-dkms: backport-iwlwifi-dkms depends on dkms (>= 2.1.0.0); however: Package dkms is not installed. dpkg: error processing package backport-iwlwifi-dkms (--install): dependency problems - leaving unconfigured Errors were encountered while processing: backport-iwlwifi-dkms bingda@robot:~$ sudo apt --fix-broken install Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following packages were automatically installed and are no longer required: apt-clone archdetect-deb bogl-bterm busybox-static cryptsetup
03-27
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值