Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ls ~/.ssh work but not cd ~/.ssh? [closed]

Tags:

bash

cmd

ls

cd

If the ls command lists the contents of a directory, then some output to ls <directory would seem to indicate that a directory exists.

For example, this is what I get:

> ls ~/.ssh
id_rsa  id_rsa.pub  known_hosts

But why then, when I type cd ~/.ssh do I get

> cd ~/.ssh
The system cannot find the path specified.

?

Why can I list the contents of this directory but not navigate to it?

I am using Windows 8

like image 574
CodyBugstein Avatar asked Jun 03 '16 17:06

CodyBugstein


People also ask

How do I change directory in SSH?

Change the working directory Navigate your server's filesystem using the cd command. cd /path/to/your/directory – change the current working directory to the nominated path. Note that the first / indicates the path is relative to the root directory.

How do I view directory in SSH?

ls Command-a — shows hidden files and directories.

Can you SSH to a specific directory?

Meaning - we can automatically change to a particular directory when log in to a remote system via SSH. Not just SSH into a specific directory, it is even possible run any command immediately right after connecting to the remote server over SSH.

What is cd in terminal?

cd or change directory The cd command allows you to move between directories. The cd command takes an argument, usually the name of the folder you want to move to, so the full command is cd your-directory . In the terminal, type: $ ls.


1 Answers

This answer is under the assumption that you are using the command prompt to execute these commands.

The reason that you can ls the directory but not cd to it, is because the ls command comes from a library that you downloaded that makes ls work on windows.

In contrast, your cd command is being executed from Windows, not from the library you downloaded.

In short, ls knows how to parse the tilde (~) as home, but windows doesn't know how to parse ~. try it: cd ~. it won't work.

like image 163
ddavison Avatar answered Sep 24 '22 16:09

ddavison