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!

      • wolfshadowheart
        link
        fedilink
        122 years ago

        But after the 2.5 years it takes to build the Windows index wouldn’t it be the same - just searching through a built index?

        • @[email protected]
          link
          fedilink
          32 years ago

          It’s been a while since I’ve had a Windows machine, but doesn’t Windows index the content of files as well as their names? If so, that would have fairly profound differences from slocate.

        • @[email protected]
          link
          fedilink
          32 years ago

          lol i remember hunting and systematically ripping out the file indexer in like vista? I think? It was terrible lol

          • wolfshadowheart
            link
            fedilink
            52 years ago

            It was honestly hilarious how bad it was and how much it could slow the system down in some situations. I’d be curious to see just how much of it was a byproduct of HDD’s - that is to say, just how slow is it even in solid state drives!

        • @[email protected]
          link
          fedilink
          22 years ago

          Unless you use everything (that’s what the software is called) to search.

          It’s so fast I’m amazed why microsoft can’t have something similar out of the box.

        • m_r_butts
          link
          fedilink
          22 years ago

          I forgot that. I have never used the built-in Windows search. I hated it in XP and would just drop to a command prompt to find shit, then eventually started using Agent Ransack instead.

  • Presi300
    link
    fedilink
    English
    92 years ago

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

  • DrOps
    link
    fedilink
    162 years ago

    I did 4 things, that helped me a lot:

    1. Make aliases for the most visited directories

    alias cem=’cd /home/drops/.config/emacs’

    1. Make aliases for moving up the tree tree:

    alias. .=’cd. . && ls’

    Three points for two levels up, etc…

    1. Name all directories lowercase, 3-5 letters long, and try to avoid directories with the same starting letter as siblings That way you can use tab completion with just a single letter

    2. Use the option to jump to subdirectories of /home/user from everywhere.

    • Dandroid
      link
      fedilink
      4
      edit-2
      2 years ago

      Instead of aliases, I use variables that I set in my .bashrc.

      For example, on WSL I have export WINDOWS_HOME=/mnt/c/Users/username. Then I can just cd $WINDOWS_HOME. Or cp $WINDOWS_HOME/Downloads/some_file .

    • @[email protected]
      link
      fedilink
      3
      edit-2
      2 years ago

      Instead of aliases, I just have lots of symlinks in my homedir.

      I do have .. and ... aliases though.

      Mostly if I’m gonna work with files I just use ranger, or FZF from my shell to find stuff.

      • @[email protected]OP
        link
        fedilink
        12 years ago

        Ranger looks like how my brain wants to work. I’ll have to check that out. I like the idea of symlinks too.

  • swartze
    link
    fedilink
    32 years ago

    Often I don’t find myself navigating directories when I reach for my file manager, but looking for something. Learning to use find or fzf gets rid of a fair amount of shuffling through your file system. Also, don’t be afraid to type out full paths when performing copy or move commands. There isn’t any reason to go to /home/documents/12/directories/deep when you can simply put the path in your ls or other command. And of course, tab complete is your friend (/ho[tab}/doc[tab]/12/[tab]/deep, etc…)

  • NumbersCanBeFun
    link
    fedilink
    32 years ago

    Not sure if it helps with navigating but ncdu is my favorite terminal app for figuring out where something is. Then I just jump to that. I’m sure there are better ways but that’s my method.

  • @[email protected]
    link
    fedilink
    32 years ago

    I felt the same. Simple tasks I do in terminal, but when I have to deal with too many files and folders I use filebrowser. Its amazing docker container with simple GUI

  • veroxii
    link
    fedilink
    562 years ago

    You’re pressing the tab key for auto completion right?

    • @[email protected]OP
      link
      fedilink
      122 years ago

      Um…no. I’ll admit I didn’t know that was an option. Weirdly I do it all the time in PowerShell. Though I am using Termius right now and at least on Android it doesn’t support tab auto complete. That said, it does auto suggest as you type to get you in the ballpark. I’ll have to try it again from my PC once I get my office put back together.

      • @[email protected]
        link
        fedilink
        32 years ago

        Oh and then there’s ncdu too with which your can navigate your fs, but that won’t allow you to open files, it is for finding what takes a lot of space.
        The vim text editor can also let you browse directories and open files in them, when you pass a folder’s path to it. But that may be an extension now that I think about it… maybe tpope’s plugin loader does it? But maybe it isn’t so it’s easiest to just try it out

      • @[email protected]
        link
        fedilink
        52 years ago

        I use Termius on iOS and double tapping the screen sends a tab (I may have enabled it in settings but I don’t think so). I think you can also put a button for it above the keyboard. In any case it does work for tab completion. I know I’m on iOS and not Android but I’d be really surprised if the Android version had no way to send a tab…

        • @[email protected]OP
          link
          fedilink
          22 years ago

          You are correct, I just tried it. I have a keyboard on my Galaxy Tab S7+ and it will recognize the Tab key in normal text entry fields but doesn’t seem to work in Termius. The double tap is pretty clutch!

      • @[email protected]
        link
        fedilink
        72 years ago

        Also make use of the up arrow on your keyboard, with which you can quickly reuse commands you have ran recently.
        For example you search for a directory with ls -alh in multiple steps, and when you have found the one you actually want to work in, then you once again press up, and either edit the command from ls to cd to switch to it, or just edit it to your favorite text editors command and put the file name at the end of the path. Tab helps with that too.
        Tab completion is done by the shell, not by the command you want to use, though worth mentioning that some tools install tab completion helpers your shell makes use of automatically.

        • @[email protected]
          link
          fedilink
          22 years ago

          It does not work on all terminal but you can also your the beginning of a command then the up key. It will show you only the previous command that start the same way.

  • @[email protected]
    link
    fedilink
    52 years 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

    • meow
      link
      fedilink
      3
      edit-2
      2 years ago

      you can also put !! for the most recent history entry, useful if you forget to put sudo

      • bayaz
        link
        fedilink
        32 years ago

        If you like those, using cdr within zsh is amazing. It automatically keeps track of where you’ve been, and you can set up tab completion to show the history with a number next to each directory for easy switching.

        Iirc, that was my main reason for switching to zsh a few years ago

        • @[email protected]
          link
          fedilink
          22 years ago

          That’s really cool. I guess the only advantage is pushd and popd is that they’re usually already installed.

  • lckdscl [they/them]
    link
    fedilink
    English
    32 years ago

    On my personal computer, zoxide, fzf, fzf tab completion allow me to jump around anywhere quite easily, I still use exa/cd for the most part. Look into this if you need more visualization. I still use a GUI file browser from time to time.

    Oh my server though, I still use the default shell, so yes I just memorize where things are. But a trick is to allow for a large history file, and I use the command history search (Ctrl-R) because I tend to run the same things constantly. My setup helps too, I run things in docker, and have a data and a config directory, things go into each accordingly, and I bind mount those directories instead of using volumes.

    If you edit config files a lot, in vim or nvim, :bro old will give you a list of files you recently edited and you can jump to them by inputting a number.

  • @[email protected]
    link
    fedilink
    English
    52 years ago

    I just type ls everytime I cd into something. It’s not that efficient honestly but I usually remember where I want to go after going there a couple times. Also if you hit tab twice after typing cd and a space, it shows all of the files in the directory.

    • @[email protected]OP
      link
      fedilink
      22 years ago

      That’s where I’m at now. And it does work. But I knew there had to be something out in the wild that folks use to traverse or at least understand where they are better. I do like Tree for a more in depth ls though. I don’t recall the options you can throw at the end of tree off the top of my head but you can specify how many layers you want to go down to see a visual of the file structure.

      • @[email protected]
        link
        fedilink
        22 years ago

        exa is a nice alternative to ls and tree commands. Just add an alias to them based on the views you want.

        But like other comment points out avoid lots of customization if you work on various shared systems, esp SSHing in.

        With my keyboard layout and other keybind customizations my system is pretty unusable to others except basic mouse on browser. Like wise i have trouble using others’ systems and need to setup any new installs to a precise way before able to work. Slightly regret going too much into customization in certain aspects.

      • @[email protected]
        link
        fedilink
        52 years ago

        Problem with most tips and tricks is that they require customizations to the OS. Many people who use Linux in a more advanced fashion, tend to also use lots of different systems, e.g. because they’re a system administrator. And you don’t want to have to make customizations to every system just to be able to get around. So, you learn to work with the lowest common denominator (mostly POSIX commands).

        Many of us do still choose to make some customizations to our most used systems, but yeah, we try to keep it lightweight and mostly just utilize tools that aid in using the POSIX commands, not replace them.

  • trompete [he/him]
    link
    fedilink
    English
    11
    edit-2
    2 years ago

    What file structure? I just put everything in /home and then try to vaguely remember part of the filename and glob *part-of-filename*.

      • @[email protected]
        link
        fedilink
        32 years ago

        You kid, but I just ripped a bunch of old data CDs and decided to also scan their covers and stick them in the tar.gz file along with the images. Some of them were pretty creative.

        • @[email protected]
          link
          fedilink
          12 years ago

          Back when I started my dream was go have folders of DVDs of all things I would need. Luckily for me cheat fast HDDs became a thing. Still should burn atleast my favourite contents.

          • @[email protected]
            link
            fedilink
            22 years ago

            Yeah. I recently bought a tape drive to do just that. Turns out fiber channel hbas are harder to get working than I thought. First one didn’t fit, like physically the card was too long and hit the CPU fan power connector. Second one fit, but the computer wouldn’t boot. Third I get a driver error, and since it’s enterprise stuff the threads I find on it basically say ‘contact your vendor’. At least they’re really cheap. Should have spent the extra money for a SAS compatible one.