7 Useful Shell Utilities That I Rarely Use

Поделиться
HTML-код
  • Опубликовано: 5 сен 2024

Комментарии • 67

  • @WR250a
    @WR250a Месяц назад +40

    \ls will also bypass any alias set and run the program with its defaults. \ls is the same as running /usr/bin/ls (or whatever program you need to run without an alias).

    • @DistroTube
      @DistroTube  Месяц назад +14

      Works in bash but not in fish, which is what I was using in this video. But 'command' works in all of the popular shells.

    • @Microphunktv-jb3kj
      @Microphunktv-jb3kj Месяц назад +6

      ls and dir are separate programs that behave similarly. As explained and referenced below, the purpose of dir is to provide a command like ls whose output does not vary depending on whether or not it is going to a terminal. To achieve this helpfully, dir must format its output in a way that is reasonable and useful both for viewing in a terminal and for writing to a file or pipe.
      There are two common misconceptions about dir:
      Many people believe dir is an alias of ls, but that is not the case. Neither command is an alias of the other, and by default in Ubuntu, dir is not an alias at all. ls and dir are provided by separate, non-identical executables.
      Many people believe dir exists for obscure historical reasons or to provide compatibility with some standard or some other OS. That is not the case either. ls behaves the way it does for compatibilty. dir, which doesn't have to be compatible because it's not a standard Unix command, behaves in an alternate way that the developers consider valuable in its own right and possibly even preferable.
      OK, but exactly how do ls and dir differ?
      Both ls and dir list the contents of directories. Two specific differences in their default behaviors distinguish them.
      When its standard output is a terminal, ls lists filenames in vertically sorted columns (like ls -C). When its standard output is not a terminal (for example, a file or pipe), ls lists filenames one per line (like ls -1).
      Whether or not its standard output is a terminal, dir lists filenames in vertically sorted columns (like ls -C).
      For both ls and dir, these defaults may be overridden by the --format= flag and by the -1, -C, -m, and -x flags, which abbreviate particular --format= options. See 10.1.4 General output formatting in the GNU coreutils reference manual for details.
      When its standard output is a terminal and a filename to be listed contains control characters, ls prints ? instead of each control character (like ls -q). When its standard output is not a terminal, ls prints control characters as-is (like ls --show-control-chars).
      Whether or not its standard output is a terminal, when dir encounters a control character or any other character that would be interpreted specially if entered into a shell, it prints backslash sequences for the characters. This includes even relatively common characters like spaces. For example, dir will list an entry called Documents backups as Documents\ backups. This is like ls -b.
      For both ls and dir, these defaults may be overridden by the flags listed in 10.1.7 Formatting the file names in the GNU coreutils reference manual. This includes -b, -q, --quoting-style=, and some others.
      Sources: ls invocation and dir invocation, in the GNU coreutils reference manual.
      Why have dir?
      The rationale for a separate dir utility is given in 4.5 Standards for Interfaces Generally of the GNU coding standards. I recommend reading that whole section to understand the developers' reasoning, but here are the highlights as applicable to ls/dir:
      Please don’t make the behavior of a utility depend on the name used to invoke it....
      Instead, use a run time option or a compilation switch or both to select among the alternate behaviors....
      Likewise, please don’t make the behavior of a command-line program depend on the type of output device....
      Compatibility requires certain programs to depend on the type of output device. It would be disastrous if ls or sh did not do so in the way all users expect. In some of these cases, we supplement the program with a preferred alternate version that does not depend on the output device type. For example, we provide a dir program much like ls except that its default output format is always multi-column format.
      The GNU Project considers it undesirable, from a technical perspective, for a utility to produce different output depending on what kind of device it is writing to (at least in the utility's default configuration). For some utilities, including ls, device-dependent output is necessary for compatibility and so it works the way users expect. Some users do also specifically prefer this device-dependent behavior.
      While ls could not reasonably be written to behave device independently, a separate dir utility was created to achieve this. Thus dir is not the utility that behaves strangely for reasons of historical compatibility--ls is.

    • @derrekvanee4567
      @derrekvanee4567 Месяц назад +1

      Alias runorig=/use/bin/$1 ? Could build a chain with a for or while loop in addition to any number of $num expansions.

    • @Voice_0f_Liberty
      @Voice_0f_Liberty Месяц назад +1

      @@Microphunktv-jb3kj N3RD

    • @Voice_0f_Liberty
      @Voice_0f_Liberty Месяц назад

      @@Microphunktv-jb3kj N3RD

  • @bwestbro
    @bwestbro Месяц назад +3

    I never used id until I had to use a compute cluster that strictly limited disk quota by group! Now I run id -gn pretty often to make sure I'm in the right group before submitting calculations.

  • @boyscout399
    @boyscout399 Месяц назад +10

    I never heard of cal thank you for that one

  • @j0hnny_R3db34rd
    @j0hnny_R3db34rd 25 дней назад +1

    The `ls` command came before the `dir` command. The `ls` command has its origins in the early 1960s, specifically in the Compatible Time Sharing System at MIT, where it was originally called `listf`. By 1963, `listf` had several options and was later renamed to `list`, which could be abbreviated to `ls` when it was implemented in Multics. When Bell Labs began Unix development in 1969, the `ls` command was retained and documented in the First Edition Unix manual by 1971.

  • @eduardofelippone4582
    @eduardofelippone4582 Месяц назад +2

    I have used the dir command mostly by accident, after spending some time in my company's computer running Windows and switching back to my personal Linux box, so sometimes the muscle memory of my fingers just type "dir" instead of "ls" or "ll", which reminds me that I am back at home in my lovely terminal and not in cmd or powershell (the opposites also happens, trying desperately to list the contents of a Windows directory by using ll or ls)

  • @Kaikaci07
    @Kaikaci07 Месяц назад +14

    My favorite that I never use is yes

    • @DistroTube
      @DistroTube  Месяц назад +7

      'yes' certainly fits into the moderately useful category. :D

    • @dhaneshdutta
      @dhaneshdutta Месяц назад +1

      yes i use arch btw XD

    • @Kaikaci07
      @Kaikaci07 Месяц назад +1

      @@dhaneshdutta same

    • @rouxgreasus
      @rouxgreasus Месяц назад

      "yes?"
      "y
      y
      y
      y
      y
      y
      y
      y
      y
      y
      y
      y
      y
      y"

  • @ShaunakHub
    @ShaunakHub Месяц назад +4

    The only command I knew about was cal.....

  • @SeaWasp
    @SeaWasp Месяц назад

    I just used dir to list my files without formatting in my hibernated windows partition, mount mounted them all as read-only and I couldn't actually read the names with it due to the read-only highlight colour. I don't know enough about ls, but dir was a quick workaround!

  • @FunctionGermany
    @FunctionGermany Месяц назад +5

    what's the deal with the math in your prompt? the answer is 267 if my mental math isn't garbage.

    • @micaelviana
      @micaelviana Месяц назад +2

      Its git status information, 279? Are untracked changes, +15 means that he adds new things. I dont know about the first number

    • @bwestbro
      @bwestbro Месяц назад +2

      ​@@micaelviana I think it's 3- (3 deletions), 15+ (15 additions), and 279 untracked changes as you said.

  • @RadioTeal
    @RadioTeal Месяц назад +3

    Hi DT! I thought that EXA was the name of the command you reference from the 'ls' alias? Did the project change names or is EZA another project? Thanks and great video!

    • @DistroTube
      @DistroTube  Месяц назад +3

      Yes, 'exa' is dead and now lives on as 'eza'.

  • @AdmiralJonB
    @AdmiralJonB Месяц назад +1

    I think you showcased more -- you showed you rarely use 'ls' as you have an alias to eza! I have the same.

  • @Tanmaydeshpande-nl5jy
    @Tanmaydeshpande-nl5jy Месяц назад +1

    i used to have my waybar configured to use cal

  • @umka7536
    @umka7536 Месяц назад +1

    I use `id` in some scripts. And I regularly use `cal` or `ncal` just because I don't want to open large app like Thunderbird or something. `ncal -M -A 2` gives me current month + 2 consequent months with weeks starting from Monday.

  • @Ocelot851
    @Ocelot851 Месяц назад +1

    Dominik toooooooreeeeeeeettttooooooooooo

  • @shanent5793
    @shanent5793 Месяц назад

    Relying on cal since I quit smoking (there was a calendar inside the pack)

  • @geremachek
    @geremachek Месяц назад +2

    I use cal all of the time, lol

  • @daveaws
    @daveaws Месяц назад

    cool
    literally

  • @vwagenjetta
    @vwagenjetta Месяц назад +1

    THE TERMINAL RICK ROLL?! LMAO

  • @d.e.v.z.e.r.o
    @d.e.v.z.e.r.o Месяц назад

    the type I have installed does not seems to support any parameter. I am using manjaro.

  • @bumblesby
    @bumblesby Месяц назад

    I'm weird. I use dir all the time and rarely use ls. I was used to dos at work before I started playing with Linux and it just stuck. I have dir aliased as dir -alh --color=always

  • @uberterminal
    @uberterminal Месяц назад

    i did not know that echo is a shell builtin

  • @xszl
    @xszl Месяц назад

    ls shows colors for files and folder. dir does not.
    cal shows calender month, but does not highlite the date on mine (mint)
    just saying

  • @moetocafe
    @moetocafe Месяц назад

    The output of dir on regular bash is not very pretty, so definitely not using it.
    For cal I use ncal -b, as it gives me the month , the name of the month, and weeks starting on Monday.
    For id, I usually use whoami or who, both very useful.
    command and type also very useful.

  • @CaribouDataScience
    @CaribouDataScience Месяц назад

    What does type dir return?

  • @Prakash1983Yes
    @Prakash1983Yes Месяц назад

    Why there are IT issues world wide today?

  • @elazar125
    @elazar125 Месяц назад +1

    How often do you use `rr` (at 6:15)? 😆

    • @DistroTube
      @DistroTube  Месяц назад

      At least once a year, I like to "terminal rick roll" myself. Just to remind myself how much I hate that song. :D

  • @boy_deploy
    @boy_deploy Месяц назад

    I typed in cal, it printed my weight 😮

  • @kill95
    @kill95 Месяц назад +2

    I used to use dir all the time until i realized ls was better

    • @rilian226
      @rilian226 Месяц назад

      I come from a long background of MS-DOS and Windows. I don't bother w/ the linux DIR command but due to that background, I alias dir to ls -lah. I am going to have to play around with esa though. Interesting tool.

  • @ShantanuAryan67
    @ShantanuAryan67 Месяц назад +2

    powershell has support for cd and ls commands!!

    • @Voice_0f_Liberty
      @Voice_0f_Liberty Месяц назад +1

      Boooooo ;)

    • @FunctionGermany
      @FunctionGermany Месяц назад +1

      they're default aliases to commads like Get-Items or something like that, so i'm pretty sure flags don't work remotely the same, so i probably wouldn't call it "support".

  • @Sisifando
    @Sisifando Месяц назад

    DT is not bald. He's astigmatic though..

  • @michgingras
    @michgingras Месяц назад

    when are you doing 10 Utilities that i dont know and dont use ?

  • @ChristianConrad
    @ChristianConrad Месяц назад

    1) Neither "dir" nor "vdir" look much at all like what the standard output of "dir" used to look like on DOS or looks like on Windows, so if that was the purpose, they've failed pretty hard IMO.
    2) Why on Earth do you spell it out in speech, in stead of just pronouncing "dir" as a word? It's not like it's an acronym, you know.

  • @MacroAcc
    @MacroAcc Месяц назад +1

    Third

  • @netbin
    @netbin Месяц назад +1

    First!

  • @dapenggao3014
    @dapenggao3014 Месяц назад

    Second!

  • @MerkDolf
    @MerkDolf Месяц назад

    ​​🐧 🖥 ​​🐧 🖥

  • @JorgeLopez-qj8pu
    @JorgeLopez-qj8pu Месяц назад +2

    Don’t use Command-line interface, result living a happier life 🤣

    • @asher5722
      @asher5722 Месяц назад +4

      no.

    • @littlepeon
      @littlepeon Месяц назад +3

      And become a slave to the mouse.....no way!

  • @jeffherdz
    @jeffherdz Месяц назад

    Why not just learn Linux commands, when moving to Linux. Not like it's rocket science.....even though NASA uses it.