I’ve just started my Linux journey earlier this year. As a goal to learn how to self-host applications and services that will allow me to take back some control of my data. Immich instead of Google Photos, for example.

I have a local server running Unraid and 22 docker containers now. And then a VPS (Ubuntu 20.04 LTS) running two apps. I’ve learned a ton but one thing I can’t seem to wrap my brain around is navigation through the file structure using only terminal. My crutch has been to open a SFTP session in Cyberduck to the same device I’m SSH’d to and try to figure things out that way. I know enough to change directories, make directories, using Tree to show the file structure at different levels of depth. But I feel like I’m missing some efficient way to find my way to files and folders I need to get to. Or are y’all just memorizing it and know where everything is by now?

I come from a Windows background and even then I sometimes catch myself checking via explorer where a directory is instead of using CMD or PowerShell to find it.

I’d love to hear any tips or tricks!

EDIT: I’ve been using Termius because they have a great Android client, but I wasn’t about to pay $5/mo for sync. Especially to sync to someone else’s cloud. Which led me to Tabby, which I understand has quite a large footprint resource-wise. But I guess I either don’t know enough yet to be mad about it or it hasn’t impacted any of my systems negatively yet. No Android client though, but you can bring your own sync solution and it has a handy little shortcut to SFTP to the current directory you’re in. Between that and stuff like ranger, it’s made it so much easier to learn my way around!

  • tvcvt@lemmy.ml
    link
    fedilink
    arrow-up
    34
    ·
    1 year ago

    I think it’s just a matter of getting used to it. I had the same issue at first and the more I used the command line, the more I started to prefer it to GUI apps for certain tasks.

    A couple things that I use all the time:

    • tab completion is incredible
    • cd - goes back to the last directory you were in (useful for bouncing back and forth between locations)
    • !$ means the last argument. So if you ls ~/Downloads and then decide you want to go there, you can cd !$.
    • :h removes the last piece of a path. So I can do vim /etc/network/interfaces and then cd !$:h will take me to /etc/network.
  • inspxtr@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    1 year ago

    Others have mentioned using interactive tools like zoxide to easily get to frequently visited directories.

    In addition, I also use nnn (https://github.com/jarun/nnn), which is a terminal file manager that you can navigate through. You can create shortcuts, snippets and bookmarks with this. I use this and zoxide + fzf regularly on CLI to navigate.

    Some here also mention ranger, which is another terminal file manager. In my limited experience with ranger, I feel like the start up time is much slower than nnn; but I haven’t tried much. Tho with ranger + graphic-accelerated terminals like kitty, I believe you can preview images and files, which seems to be a great feature. So it depends on your need.

    • SnachBarr@lemm.ee
      link
      fedilink
      arrow-up
      4
      ·
      1 year ago

      Why use a separate command when “cd -“ works just fine to take you to the previous directory

      • kool_newt@lemm.ee
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 year ago

        Right, but what if the dir you want to return to was not the last one?

        For example, you are working in two dirs and go into your home dir for something, now you can pop yourself back into your long ass hard to type working path.

  • ErnieBernie10@lemmy.world
    link
    fedilink
    arrow-up
    7
    ·
    1 year ago

    Useful one I find is the z program you can install it with package manager and it’s also included with zsh shell. It’s basically like a smart cd command. Instead of having to type the entire path for cd, when using z you can just type the destination folder and if it’s in your history it will resolve the path by itself.

  • Presi300@lemmy.world
    link
    fedilink
    English
    arrow-up
    5
    ·
    1 year ago

    Use the fish shell… No, seriously it’s autocomplete and tab functionality makes browsing directories through the terminal so much easier

  • cizra@lemm.ee
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    In Linux, the locate command is crazy fast. I am amazed at how slow search is in Windows, compared to this.

  • jernej@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    I use ls and ranger, to find files i use find -name and remember that * is used as a wildcard so you can use it when searching for stuff with in incomplete filename or when copying or moving files/directories. You could also use colorls to add some flare to your ls, and oh-my-zsh for syntax highlighting and tab autocomplete

  • slembcke@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    edit-2
    1 year ago

    There are a few directory structures I have memorized, like my programming projects for instance. For everything else, I use the GUI. That’s what it’s there for. Mixing and match to get the best of both worlds. Some handy tips:

    • xdg-open will act like clicking on a file in the GUI, and is an easy way to open folders from the terminal when you want to browse them.
    • Use sshfs or even just whatever is built into your desktop environment to connect to remote servers and browse them
    • Most terminals let you drag files or folders into them to paste their paths
  • 257m@lemmy.ml
    link
    fedilink
    arrow-up
    5
    ·
    1 year ago

    For navigating files quickly fzf is pretty much crucial to my workflow. Being able to get my home directory to the directory of the project I want to work on in two seconds flat is such a nice feeling after manually typing the path in for months. https://github.com/junegunn/fzf

  • Magister@lemmy.world
    link
    fedilink
    arrow-up
    4
    ·
    1 year ago

    Just using “cd -” to go back where you were is useful.

    history command and ! and the number in history, like

    !123

    For instance, it’s useful

    • Father_Redbeard@lemmy.mlOP
      link
      fedilink
      arrow-up
      3
      ·
      1 year ago

      Yeah I’ve been messing with that. I like that you can limit how deep you want to go, like if you just want to see folders but not the files within, for example.