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

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • In this video, I discuss five incredibly useful command line utilities: uname, hostname, basename, dirname and logname. All of these programs are part of the GNU core utilities that are installed on every GNU/Linux distribution. You will find these utilities useful, not only as command line programs, but also in scripting.
    REFERENCED:
    ► linux.die.net/...
    ► linux.die.net/...
    ► linux.die.net/...
    ► linux.die.net/...
    ► linux.die.net/...
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.youtube.co...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/...
    DONATE CRYPTO:
    💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
    🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
    📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    📁 GitLab: gitlab.com/dwt1
    🗨️ Mastodon: fosstodon.org/...
    👫 Reddit: / distrotube
    📽️ LBRY/Odysee: odysee.com/@Di...
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    💻 VirtualBox: www.virtualbox...
    🗒️ Doom Emacs: github.com/hli...
    Your support is very much appreciated. Thanks, guys!

КОМЕНТАРІ • 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("/"));

  • @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?"

  • @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.

  • @it_spec_notes
    @it_spec_notes 2 роки тому +2

    You are the best Linux teacher on UA-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 UA-cam. From Russia with love ❤

    • @der_Grosse
      @der_Grosse 2 роки тому

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

  • @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...

  • @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.

  • @n0kodoko143
    @n0kodoko143 2 роки тому +1

    Thanks Derek! Thanks patrons!

  • @guilherme5094
    @guilherme5094 2 роки тому +1

    👍 DT!

  • @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 👍

  • @richardharding760
    @richardharding760 2 роки тому

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

  • @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

  • @emacsking4310
    @emacsking4310 2 роки тому +1

    Love from Denmark DT

  • @sussusamogus7831
    @sussusamogus7831 2 роки тому

    Great guide DT, thank you for this :)

  • @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

  • @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

  • @michaelnapitupulu9269
    @michaelnapitupulu9269 2 роки тому

    Thanks, dt :)

  • @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

  • @shriram5494
    @shriram5494 2 роки тому

    is whoami just syntactic sugar for echo $USER ?

  • @sotecluxan4221
    @sotecluxan4221 2 роки тому

  • @AnthonyGarnerAnthonyFJGarner

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

  • @siaal5001
    @siaal5001 2 роки тому +2

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

  • @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?

  • @QuoteVG
    @QuoteVG 2 роки тому

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

  • @xrafter
    @xrafter 2 роки тому

    *name

  • @rizkyadiyanto7922
    @rizkyadiyanto7922 2 роки тому

    third

  • @mrlithium69
    @mrlithium69 2 роки тому

    SHELL not SHILL

  • @joaopedroalbernaz
    @joaopedroalbernaz 2 роки тому

    "GNU/Linux"