Essential Linux Commands - uname, hostname, basename, dirname & logname
Vložit
- čas přidán 26. 08. 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!
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.
you can also:
#!/bin/node
let elems = process.argv.split("/");
elems.pop();
console.log(elems.join("/"));
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.
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.
@@Finkelfunk your explanation explains it exactly
Literally every Arch user once they are done setting up Arch: _installs neofetch to show off_
uname: "Am I a joke to you?"
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.
You are the best Linux teacher on CZcams! 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 CZcams. From Russia with love ❤
4uck you ruZZia from Ukraine! Слава Україні! Смерть російським ворогам!!!
Thanks Derek! Thanks patrons!
👍 DT!
Well, the first sentence in this video is guaranteed to send windows users running screaming ,back to their favourite spyware
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.
@@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.
@@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...
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 👍
Probably a manual tiling wm like openbox
Great guide DT, thank you for this :)
Hey dt hi from England,your content is great, have you written any books on Linux?
Thanks, dt :)
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
It's odd to me that these can be useful. Linux feels infinite.
Wonderful statement describing Linux fascination and curiosity.
Love from Denmark DT
Happy Easter also
I wonder why uname maybe unix name?
But GNU's Not Unix . :D
user name?
edit: "uname (short for unix name) is a computer program in Unix"
-Wikipedia
@@paulg3336 Oh nice I was right
@@DistroTube I recall in the old days is was called unix/PG
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
how did you manage to stretch this video out this long lol
is whoami just syntactic sugar for echo $USER ?
Is it "safe" to change from time to time the hostname via /etc/hostname though ?
Not sure but on systemd-based distros you probably want to use the hostnamectl command.
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.
doesnt uname -a give you the hostname?
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?
dirname and basename can be replaced with bash parameter expansion ${0%/*} and ${##*/}/
You should show people how to quit VIM. I'm a new user following along and had to google it. Just a thought!
*name
third
SHELL not SHILL
10:00 Missed opportunity to demonstrate the thing you're talking about, instead of just talking about it.
"GNU/Linux"