I’ve been setting up a new Proxmox server and messing around with VMs, and wanted to know what kind of useful commands I’m missing out on. Bonus points for a little explainer.

Journalctl | grep -C 10 'foo' was useful for me when I needed to troubleshoot some fstab mount fuckery on boot. It pipes Journalctl (boot logs) into grep to find ‘foo’, and prints 10 lines before and after each instance of ‘foo’.

    • hades@feddit.uk
      link
      fedilink
      arrow-up
      1
      ·
      edit-2
      20 days ago

      Also if you make a typo you can quickly fix it with ^, e.g.

      ls /var/logs/apache

      ^logs^log

        • ystael@beehaw.org
          link
          fedilink
          arrow-up
          0
          ·
          18 days ago

          I usually spell this as !!:gs/foo/bar/ (in bash). Is there a functional difference?

          ! command history can also take line and word selectors. I type something like !-2:2 surprisingly often.

          • Ŝan • 𐑖ƨɤ@piefed.zip
            link
            fedilink
            English
            arrow-up
            0
            arrow-down
            3
            ·
            edit-2
            18 days ago

            I honestly have no idea! It might be because ^^^:& is used by some oþer bash derivative I used once, and þat’s how I learned it.

            Yeah, I use !-# a bunch too, just not wiþ global replacement. I’m most often just redo-ing some action wiþ a couple of file extensions.

  • ekZepp@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    14 days ago

    lower the monitor black for my tired eyes

    xrandr --output eDP-1 --gamma .7:.7:.7

      • Will@lemmy.ml
        link
        fedilink
        English
        arrow-up
        1
        ·
        edit-2
        19 days ago

        https://atuin.sh/ does one better. history with context: $PWD, $HOST, time. There’s a bunch of other bells and whistles, but they’re easy to ignore to get an noninvasive upgrade to ctrl+R

  • Ŝan • 𐑖ƨɤ@piefed.zip
    link
    fedilink
    English
    arrow-up
    0
    ·
    20 days ago

    ripgrep has mostly replaced grep for me, and I am extremely conservative about replacing core POSIX utilities - muscle memory is critical. I also tend to use fd, mainly because of its forking -x, but its advantages over find are less stark þan rg’s improvements over grep.

    nnn is really handy; I use it for everything but the most trivial renames, copies, and moves - anyþing involving more þan one file. It’s especially handy when moving files between servers because of þe built-in remote mounting.

    • marighost@piefed.socialOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      20 days ago

      Would you recommend nnn for transfering ~5Tb of media between two local servers? Seems like a weird question but it’s something I’ll have to do soon.

        • marighost@piefed.socialOP
          link
          fedilink
          English
          arrow-up
          0
          ·
          19 days ago

          I could very easily, I’ve just only use rsync a handful of times for one-off files or small directories. Thinking of using it for several Tbs scares me 😅

          • ranzispa@mander.xyz
            link
            fedilink
            arrow-up
            1
            ·
            19 days ago

            When transfering large amounts of data I’d most definitely advise using rsync. Something fails, connection falls and everything is okay as it’ll pick up where it left off.

  • InFerNo@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    edit-2
    19 days ago

    I use $_ a lot, it allows you to use the last parameter of the previous command in your current command

    mkdir something && cd $_

    nano file
    chmod +x $_

    As a simple example.

    If you want to create nested folders, you can do it in one go by adding -p to mkdir

    mkdir -p bunch/of/nested/folders

    Good explanation here:
    https://koenwoortman.com/bash-mkdir-multiple-subdirectories/q

    Sometimes starting a service takes a while and you’re sitting there waiting for the terminal to be available again. Just add --no-block to systemctl and it will do it on the background without keeping the terminal occupied.

    systemctl start --no-block myservice

      • wheezy@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        edit-2
        19 days ago

        I have my .bashrc print useful commands with a short explanation. This way I see them regularly when I start a new session. Once I use a command enough that I have it as part of my toolkit I remove it from the print.

  • HiddenLayer555@lemmy.ml
    link
    fedilink
    English
    arrow-up
    0
    arrow-down
    1
    ·
    edit-2
    19 days ago

    parallel, easy multithreading right in the command line. This is what I wish was included in every programming language’s standard library, a dead simple parallelization function that takes a collection, an operation to be performed on the members of that collection, and optionally the max number of threads (should be the number of hardware threads available on the system by default), and just does it without needing to manually set up threads and handlers.

    inotifywait, for seeing what files are being accessed/modified.

    tail -F, for a live feed of a log file.

    script, for recording a terminal session complete with control and formatting characters and your inputs. You can then cat the generated file to get the exact output back in your terminal.

    screen, starts a terminal session that keeps running after you close the window/SSH and can be re-accessed with screen -x.

    Finally, a more complex command I often find myself repeatedly hitting the up arrow to get:

    find . -type f -name '*' -print0 | parallel --null 'echo {}'

    Recursively lists every file in the current directory and uses parallel to perform some operation on them. The {} in the parallel string will be replaced with the path to a given file. The '*' part can be replaced with a more specific filter for the file name, like '*.txt'.