Search code examples
sshgoogle-compute-enginels

ls doesn't show any output in ssh connected to an Debian 9 VM instance in Google Cloud Platform


this might be a dumb question, but I checked everywhere and there's no direct answer to it.

I set up both SSH keys successfully and I can connect to my instance via terminal, but when I do "ls", it doesn't show me any output. I am using iTerm2 with zsh on my Mac but I don't think this is an issue.

Can anybody give me a hint? Thanks!


Solution

  • When you access a VM through SSH, your working directory is the home directory of the user specified with the SSH command, i.e. /home/username. In case you access as root, the working directory will be /root. You can check it through the command pwd

    If it is a brand new machine, it is normal that the output of 'ls' is empty since in your home directory no file matches the filters of 'ls' with no parameters. The reason is that 'ls' doesn't show filenames starting with a dot ('.') because in the Linux convention they are hidden unless you run ls -al.

    You can try again with $ ls -al and you will be able to see hidden files and directories as well.

    On the other hand you can create as well first an empty file and then running again 'ls':

    $ touch file
    $ ls