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
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.
ls Command-a — shows hidden files and directories.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With