Essential Linux Commands - uname, hostname, basename, dirname & logname

แชร์
ฝัง

ความคิดเห็น • 46

  • @scheimong
    @scheimong 2 ปีที่แล้ว +16

    A somewhat common use of `dirname` is if you want to write to a file (e.g. a log) in the same directory as your script. You can't simply do `echo text >log` because the user of the script may be calling it from a different working directory.
    So what you would do is first call `cd $(dirname $0)` to set your working directory to where your script is, then write to your file.

    • @bobrieber535
      @bobrieber535 2 ปีที่แล้ว

      you can also:
      #!/bin/node
      let elems = process.argv.split("/");
      elems.pop();
      console.log(elems.join("/"));

  • @it_spec_notes
    @it_spec_notes 2 ปีที่แล้ว +2

    You are the best Linux teacher on TH-cam! Thank you for the video! I started using Emacs after your videos. I love it when you talk more and more about new packages in Emacs and new useful programs for Linux. I hope you continue posting your videos on TH-cam. From Russia with love ❤

    • @der_Grosse
      @der_Grosse 2 ปีที่แล้ว

      4uck you ruZZia from Ukraine! Слава Україні! Смерть російським ворогам!!!

  • @vince6792
    @vince6792 2 ปีที่แล้ว +2

    Great info! No one should be afraid of the terminal or think they need to remember every command. I've been on Arch for years and I still find looking up a command or script necessary.

    • @Finkelfunk
      @Finkelfunk 2 ปีที่แล้ว +1

      The only thing you need to remember is how you have to look up stuff you don't remember. The man pages exist for a reason too, no one can remember 15 flags for 60 different commands you most likely have to use less than once a year.

    • @vince6792
      @vince6792 2 ปีที่แล้ว

      @@Finkelfunk your explanation explains it exactly

  • @wyattarich
    @wyattarich 2 ปีที่แล้ว +2

    You skipped a beat here DT, you should have used the SystemD way of hostnamectl! It also feels appropriate to mention base/dirname is never really used outside of shell scripting. Logname is also a good opportunity to introduce people to the `who` command for viewing logged in users. Great video as always.

  • @Finkelfunk
    @Finkelfunk 2 ปีที่แล้ว +4

    Literally every Arch user once they are done setting up Arch: _installs neofetch to show off_
    uname: "Am I a joke to you?"

  • @n0kodoko143
    @n0kodoko143 2 ปีที่แล้ว +1

    Thanks Derek! Thanks patrons!

  • @richardharding760
    @richardharding760 2 ปีที่แล้ว

    Hey dt hi from England,your content is great, have you written any books on Linux?

  • @sussusamogus7831
    @sussusamogus7831 2 ปีที่แล้ว

    Great guide DT, thank you for this :)

  • @sukhchainsingh398
    @sukhchainsingh398 2 ปีที่แล้ว +1

    Hey DT, Which Desktop Environment would you prefer using if tiling window managers weren't an option ?
    Please tell us reason for your choice too.
    Love your videos by the way 👍

  • @guilherme5094
    @guilherme5094 2 ปีที่แล้ว +1

    👍 DT!

  • @theodorealenas3171
    @theodorealenas3171 2 ปีที่แล้ว +11

    It's odd to me that these can be useful. Linux feels infinite.

    • @vince6792
      @vince6792 2 ปีที่แล้ว +3

      Wonderful statement describing Linux fascination and curiosity.

  • @JHACbiz
    @JHACbiz 2 ปีที่แล้ว

    DT: have you ever done a video on Avahi. I'm particularly interesting in messing with Zget but not sure how to create the service for zeroconf

  • @davidprock904
    @davidprock904 2 ปีที่แล้ว

    Replying here cause this is your latest video, but about Appimage, I want to get back into gentoo, and I see this solving my annoyances. But I want to make an app image of what I Installed that better/perfectly matches my hardware, and then install and move on to the next,.
    So everything that can NOT run as an appimage... install that to stay, but everything else temporarily to be put into an appimage.
    But I need to know if an app creates/modify a configuration file ETC. Will it be permanent ? If it's permanent, will the change stay within the single appimage file, or will it be stored outside of it?
    Side note if all changes are lost, it would be great for browser privacy, close or open another instance for each individual website, to stop cross tracking... or what ever its called.
    Also when creating it, is there a way for it to automate all the applications dependency, and those dependency on top of others and grab them all, or do you manually have to copy everything

  • @paulg3336
    @paulg3336 2 ปีที่แล้ว +9

    Well, the first sentence in this video is guaranteed to send windows users running screaming ,back to their favourite spyware

    • @gadflyofhumanity_6847
      @gadflyofhumanity_6847 2 ปีที่แล้ว +4

      Good, f-em we need to keep desktop Linux a niche, NOT make it mainstream! When things go mainstream they get ruined by the normies.

    • @gimcrack555
      @gimcrack555 2 ปีที่แล้ว +1

      @@gadflyofhumanity_6847 I thinks that's why Linux never fought hard to make to the mainstream. I like how you put it; The normies would just ruin it for the rest of us geek people.

    • @astroid-ws4py
      @astroid-ws4py 2 ปีที่แล้ว

      @@gadflyofhumanity_6847 Linux will never be a normy thing due to the terminal and due to the availability of so many options to tweak the system and due to Linux being built around the concept of open source software code availability and the ability to compile and run it directly from the terminal. And it is a good thing. But we as Nerds should make the transition to Linux for “would be Nerds” and “potentially Nerds” as clean and seamless as possible and thankfully due to the many great channels about Linux that info becomes available to anyone who wants to start this adventure...

  • @emacsking4310
    @emacsking4310 2 ปีที่แล้ว +1

    Love from Denmark DT

  • @michaelnapitupulu9269
    @michaelnapitupulu9269 2 ปีที่แล้ว

    Thanks, dt :)

  • @keltyll
    @keltyll 2 ปีที่แล้ว +1

    Is it "safe" to change from time to time the hostname via /etc/hostname though ?

    • @BurgerKingHarkinian
      @BurgerKingHarkinian 2 ปีที่แล้ว +3

      Not sure but on systemd-based distros you probably want to use the hostnamectl command.

    • @KyleRassweiler
      @KyleRassweiler 2 ปีที่แล้ว +1

      The hostname is used in the /etc/hosts file as well (this is where the -i flag gets the ip from) so it would need changed there if done manually.
      I'm sure there's a better way to change this all but I just do it manually.

  • @nrdfoss
    @nrdfoss 2 ปีที่แล้ว +1

    how did you manage to stretch this video out this long lol

  • @shriram5494
    @shriram5494 2 ปีที่แล้ว

    is whoami just syntactic sugar for echo $USER ?

  • @0__alfie__0
    @0__alfie__0 2 ปีที่แล้ว +2

    I wonder why uname maybe unix name?

    • @DistroTube
      @DistroTube  2 ปีที่แล้ว +5

      But GNU's Not Unix . :D

    • @paulg3336
      @paulg3336 2 ปีที่แล้ว +1

      user name?
      edit: "uname (short for unix name) is a computer program in Unix"
      -Wikipedia

    • @0__alfie__0
      @0__alfie__0 2 ปีที่แล้ว +3

      @@paulg3336 Oh nice I was right

    • @dougtilaran3496
      @dougtilaran3496 2 ปีที่แล้ว

      @@DistroTube I recall in the old days is was called unix/PG

  • @pwall
    @pwall 2 ปีที่แล้ว

    doesnt uname -a give you the hostname?

    • @JamesWoodard1222
      @JamesWoodard1222 2 ปีที่แล้ว

      Yes. In the second field.
      Also, uname -n (or --node) prints only the network nodes hostname.'
      Maybe this is part of the reason 'hostname' isn't included in coreutils on Arch Linux?

  • @AnthonyGarnerAnthonyFJGarner
    @AnthonyGarnerAnthonyFJGarner ปีที่แล้ว

    You should show people how to quit VIM. I'm a new user following along and had to google it. Just a thought!

  • @sotecluxan4221
    @sotecluxan4221 2 ปีที่แล้ว

  • @QuoteVG
    @QuoteVG 2 ปีที่แล้ว

    10:00 Missed opportunity to demonstrate the thing you're talking about, instead of just talking about it.

  • @siaal5001
    @siaal5001 2 ปีที่แล้ว +2

    dirname and basename can be replaced with bash parameter expansion ${0%/*} and ${##*/}/

  • @xrafter
    @xrafter 2 ปีที่แล้ว

    *name

  • @mrlithium69
    @mrlithium69 2 ปีที่แล้ว

    SHELL not SHILL

  • @rizkyadiyanto7922
    @rizkyadiyanto7922 2 ปีที่แล้ว

    third

  • @joaopedroalbernaz
    @joaopedroalbernaz 2 ปีที่แล้ว

    "GNU/Linux"