为何执行cd ~/test1时提示‘no such file or directory’错误?
问题原因与解决办法
你犯了一个路径基础错误:~/是用户主目录的快捷路径,你执行cd ~/test1时,系统会去你的主目录(比如/home/yourname/)里找test1文件夹,但你创建的test1明明在当前的examples目录下,这俩根本不是同一个位置,当然会提示找不到。
解决方法很简单,二选一就行:
- 用相对路径直接进入:
cd test1(因为你现在就在examples目录下,test1是它的子目录) - 用绝对路径进入:先执行
pwd获取当前examples目录的绝对路径(比如输出是/home/yourusername/examples),然后执行cd /home/yourusername/examples/test1
记住:以后不要随便加~/前缀,除非你明确要访问主目录下的文件或文件夹。
内容的提问来源于stack exchange,提问作者newbie_program
相关产品推荐
相关产品推荐

