Tim's Lemmy
  • Communities
  • Create Post
  • heart
    Support Lemmy
  • search
    Search
  • Login
  • Sign Up
cybercitizen4@lemm.ee to Asklemmy@lemmy.ml · 2 years ago

What's a handy terminal command you use often?

message-square
message-square
237
link
fedilink
1
message-square

What's a handy terminal command you use often?

cybercitizen4@lemm.ee to Asklemmy@lemmy.ml · 2 years ago
message-square
237
link
fedilink
alert-triangle
You must log in or register to comment.
  • kang@lemmy.ml
    link
    fedilink
    Español
    arrow-up
    0
    ·
    2 years ago

    $ z

    A great cd alternative

    Also $ sudo paru -Syu

    • theshatterstone54@feddit.uk
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      I think you can run paru without sudo and it should still do privilege escalation no problem

  • Korthrun@lemmy.sdf.org
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    Seems like an appropriate place to share https://github.com/agarrharr/awesome-cli-apps

    I’m a fan of ripgrep and lsd in particular.

    • x00za@lemmy.dbzer0.comBanned
      link
      fedilink
      English
      arrow-up
      0
      ·
      edit-2
      2 years ago

      Removed by mod

  • SorteKanin@feddit.dk
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    Zoxide, dust, fd, rg, btm, tokei. So many newer Rust tools that are way better than the old stuff.

  • Nicht BurningTurtle@feddit.org
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    nmtui. But that’s because my router is trash.

  • estutweh@aussie.zone
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    ls -al

    • avguser@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Another ls alias I’m a fan of is ls -latr which I alias to lt. It gives you a time sorted directory listing with the most recent next to your cursor (helpful for large directories).

    • walden@sub.wetshaving.social
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      I learned you can edit .bashrc (in your home dir) and update the alias for ls to include what I like. It has saved me lots of keystrokes. Mine is ‘ls -lha’ in addition to whatever color coding stuff is there by default.

      • 4am@lemm.ee
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        A lot of distros include a .bashrc with common ls aliases commented out, just waiting for you to activate them if you like.

      • jbrains@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        You might like eza even more!

        • Noxious@fedia.io
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          You might like lsd even more than that!

        • walden@sub.wetshaving.social
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          Hmm, that’s not working for me. You mean use those as options? ‘ls -eza’?

          • jbrains@sh.itjust.works
            link
            fedilink
            arrow-up
            0
            ·
            2 years ago

            No, eza is one of those modern Rust replacement programs. It replaces ls.

            • emb@lemmy.world
              link
              fedilink
              arrow-up
              0
              ·
              2 years ago

              There’s a whole bunch of cool modern replacements. Here’s a handy list: altbox.dev

              I personally use bat and rg all the time, and find them much more suitable for everyday tasks.

              • jbrains@sh.itjust.works
                link
                fedilink
                arrow-up
                0
                ·
                2 years ago

                Even better than rg is rga. Indeed, you have a fine list.

              • bradboimler@lemmy.world
                link
                fedilink
                English
                arrow-up
                0
                ·
                2 years ago

                The mobile site doesn’t have the list. I was so confused.

                • emb@lemmy.world
                  link
                  fedilink
                  arrow-up
                  0
                  ·
                  2 years ago

                  Ew, sorry. This list is similar and more accessible:

                  https://github.com/ibraheemdev/modern-unix

          • babeuh@lemmy.worlddeleted by creator
            link
            fedilink
            arrow-up
            0
            ·
            2 years ago

            No, it’s like an ls replacement: https://github.com/eza-community/eza

            • walden@sub.wetshaving.social
              link
              fedilink
              arrow-up
              0
              ·
              2 years ago

              Aha. Well, I guess I’m not the target audience because I can’t be bothered to go through the installation steps. It’s not in the LMDE repository, but I wish it were!

  • majestictechie@lemmy.fosshost.com
    link
    fedilink
    English
    arrow-up
    0
    ·
    2 years ago

    On my desktop: df -h to check disk usage htop to see resource usage ll list directory contents

    • Albbi@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      I recently found btop and am trying to use that instead of htop.

      • majestictechie@lemmy.fosshost.com
        link
        fedilink
        English
        arrow-up
        0
        ·
        2 years ago

        looks up btop ooooo

  • emb@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    I really like that cd command. :P

    • Jeena@piefed.jeena.net
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 years ago

      Hm I wonder, is it really a command? I thought it is just a function of the shell to change the working directory.

      • ClassifiedPancake@discuss.tchncs.de
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        A command is anything you execute in the shell.

        cd is just a built-in command

    • unknowing8343@discuss.tchncs.de
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      You’ll love zoxide then.

      • velox_vulnus@lemmy.mldeleted by creator
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        2 years ago

        deleted by creator

        • jeffreyosborne@lemm.ee
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          On arch the command is just z

        • alsimoneau@lemmy.ca
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          When you set it up you tell it which command you want. Default is “cdi” but I changed it to “cd” immediately.

        • Yoddel_Hickory@lemmy.ca
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          The command is ‘z’

          • velox_vulnus@lemmy.mldeleted by creator
            link
            fedilink
            English
            arrow-up
            0
            ·
            edit-2
            2 years ago

            deleted by creator

            • unknowing8343@discuss.tchncs.de
              link
              fedilink
              arrow-up
              0
              ·
              2 years ago

              It’s in the official docs for zoxide, you are supposed to use the z alias, and many distros just set it up directly like that. I love doing z notes from wherever I am.

              • 7dev7random7@suppo.fi
                link
                fedilink
                arrow-up
                0
                ·
                2 years ago

                Description fifth point (5.)

                That doesn’t require a separate package, especially one which uses eval on every new shell. And isn’t messing with my distros or personal aliases (and doesn’t introduce cargo-packaging).

                Simply adding one to two (you get the gist) directories and a keybind for cd .. is more slick. There are cases where you might use pushd . but even then other tooling should already cover your needs.

                It’s also so easy that you can temporarly append to $CDPATH for a specific session. But again, then a second pane or pushd is already available.

                Now downvote me, lemmy.

  • anonymouse2@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    I recently learned to use a for loop on the command line to organize hundreds of files in a few seconds.

    • makingStuffForFun@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Example of said Black Magik?

      • anonymouse2@sh.itjust.works
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        Let’s say, for example, you have a directory of files named x01-001; x01-002; x02-001; x02-002; x03-001… and so on.

        I want to create subdirectories for each ‘x’ iteration and move each set to the corresponding subdirectory. My loop would look like this:

        for i in {1…3}; do mkdir Data_x0$i && mv x0$i* Data_x0$i; done

        I’ve also been using it if I need to rename large batches of files quickly.

        • friend_of_satan@lemmy.world
          link
          fedilink
          English
          arrow-up
          0
          ·
          2 years ago

          Check out rename

          $ touch foo{1..5}.txt
          $ rename -v 's/foo/bar/' foo*
          foo1.txt renamed as bar1.txt
          foo2.txt renamed as bar2.txt
          foo3.txt renamed as bar3.txt
          foo4.txt renamed as bar4.txt
          foo5.txt renamed as bar5.txt
          $ rename -v 's/\.txt/.text/' *.txt
          bar1.txt renamed as bar1.text
          bar2.txt renamed as bar2.text
          bar3.txt renamed as bar3.text
          bar4.txt renamed as bar4.text
          bar5.txt renamed as bar5.text
          $ rename -v 's/(.*).text/1234-$1.txt/' *.text
          bar1.text renamed as 1234-bar1.txt
          bar2.text renamed as 1234-bar2.txt
          bar3.text renamed as 1234-bar3.txt
          bar4.text renamed as 1234-bar4.txt
          bar5.text renamed as 1234-bar5.txt
          
          • electric_nan@lemmy.ml
            link
            fedilink
            arrow-up
            0
            ·
            2 years ago

            In your second example, it looks like you have an escape character before the first ‘dot’, but not the second one. Is this a typo, or am I misunderstanding the command?

            • friend_of_satan@lemmy.world
              link
              fedilink
              English
              arrow-up
              0
              ·
              edit-2
              2 years ago

              It’s not a typo. The first section of the regex is a matching section, where a dot means “match any character”, and an escaped dot is a literal dot character. The second section is the replacement section, and you don’t have to escape the dot there because that section isn’t matching anything. You can escape it though if it makes the code easier to read.

              rename is written in Perl so all Perl regular expression syntaxes are valid.

              However, your comment did make me realize that I hadn’t escaped a dot in the third example! So I fixed that.

          • well5H1T3@lemmy.world
            link
            fedilink
            English
            arrow-up
            0
            ·
            2 years ago

            SED combinator, you win 🙌

        • tetris11@lemmy.ml
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          xargs is also fun, and assuming your for loop doesn’t update anything out of the loop, is highly parallelizable

          The equivalent of the same command, that handles 10 tasks concurrently, using %% as a variable placeholder.

          seq 1 100 | xargs -I'%%' -P 10 sh -c 'mkdir Data_X0%% && mv x0%%* Data_X0%%;'
          

          But for mass renaming files, dired along with rectangle-select and multicursors within Emacs is my goto.

  • CameronDev@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    touch 😏

    • sem@lemmy.blahaj.zone
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      I remember touch

  • blackstrat@lemmy.fwgx.uk
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    ll

    df -h

    du -sch

    Ctrl+r

    • notfromhere@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      ll

      Is an alias for

      ls -al
      

      yea?

      • subtext@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        I set mine to

        ls -lAh
        
  • sp451@lemmy.sdf.org
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    sudo rm -rf /

    Very powerful yet helpful command :-)

    • makingStuffForFun@lemmy.ml
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Someone has to say this. Don’t do it anyone

      • Diplomjodler@lemmy.world
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        Instructions unclear, dick now stuck in computer.

        • JetpackJackson@feddit.org
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          Lp0 on fire

      • sp451@lemmy.sdf.org
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        Agree. Don’t just copy and paste CLI commands you find on the internet, suggested by a stranger

      • Hux@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        For reference: https://en.m.wikipedia.org/wiki/Rm_(Unix)

        The rm -rf / variant of the command, if run by a superuser, would cause every file accessible from the present file system to be deleted from the machine.

    • papertowels@lemmy.one
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      The most deceptive joke I’ve seen on this is sudo rm -fr / to remove the French language pack

    • potentiallynotfelix@lemmy.fish
      link
      fedilink
      English
      arrow-up
      0
      ·
      2 years ago

      I did this on my personal computer just to prove a point.

  • LambdaRX@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    After using too much WINE, I type pwd, whoami

  • Jo Miran@lemmy.ml
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    sudo

    • LambdaRX@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Make me a sandwich.

      • Nicht BurningTurtle@feddit.org
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        LambdaRX is not in the sudoers file. This incident will be reported

        • LambdaRX@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          Eh, guess I won’t get anything for christmas.

  • itsame@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago

    pushd and popd to change directory and go back when done there.

    • jbrains@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      ·
      2 years ago

      Even better when cd automatically invokes pushd.

      • tetris11@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        what’s your alias?

      • lluki@feddit.org
        link
        fedilink
        arrow-up
        0
        ·
        2 years ago

        cd - undoes the last cd. Not quite push/popd but still useful. Pro tip, works also: git checkout -

        • med@sh.itjust.works
          link
          fedilink
          arrow-up
          0
          ·
          2 years ago

          Hell yeah. Every one of these threads makes me more inclined to read man pages

          • 7dev7random7@suppo.fi
            link
            fedilink
            arrow-up
            0
            ·
            2 years ago

            You should. These are the actually sources to learn.

  • TechnoCat@lemm.ee
    link
    fedilink
    arrow-up
    0
    ·
    2 years ago
    • man
    • fd
    • entr
    • rg
    • gitui
    • nvim
    • tee
    • cd
    • mv
    • rm
    • ls
    • tmux
    • htop
    • yazi
    • du
    • xargs
    • cat
    • less

Asklemmy@lemmy.ml

asklemmy@lemmy.ml

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: [email protected]

A loosely moderated place to ask open-ended questions

Search asklemmy 🔍

If your post meets the following criteria, it’s welcome here!

  1. Open-ended question
  2. Not offensive: at this point, we do not have the bandwidth to moderate overtly political discussions. Assume best intent and be excellent to each other.
  3. Not regarding using or support for Lemmy: context, see the list of support communities and tools for finding communities below
  4. Not ad nauseam inducing: please make sure it is a question that would be new to most members
  5. An actual topic of discussion

Looking for support?

  • [email protected]
  • [email protected]
  • [email protected]

Looking for a community?

  • Lemmyverse: community search
  • sub.rehab: maps old subreddits to fediverse options, marks official as such
  • [email protected]: a community for finding communities

Icon by @[email protected]

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 99 users / day
  • 445 users / week
  • 1.56K users / month
  • 4.48K users / 6 months
  • 0 local subscribers
  • 55.7K subscribers
  • 6.95K Posts
  • 200K Comments
  • Modlog
  • mods:
  • Evan@lemmy.ml
  • mekhos@lemmy.ml
  • tmpod@lemmy.pt
  • OrangeSlice@lemmy.ml
  • UI: unknown version
  • BE: 0.19.20
  • Modlog
  • Instances
  • Docs
  • Code
  • join-lemmy.org