How To Use Shell Environment Variables

Ғылым және технология

In this video, I am going to give a cursory introduction to shell environment variables, which come in two forms: global variables and local variables. I also discuss some of the global variables that I often use, including the PATH variable and how to add to the PATH.
REFERENCED:
► www.gnu.org/software/bash/man... - Bash Reference Manual
WANT TO SUPPORT THE CHANNEL?
💰 Patreon: / distrotube
💳 Paypal: www.paypal.com/cgi-bin/webscr...
🛍️ Amazon: amzn.to/2RotFFi
👕 Teespring: teespring.com/stores/distrotube
DONATE CRYPTO:
💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
SOCIAL PLATFORMS:
🗨️ Mastodon: distrotoot.com/@derek
👫 Reddit: / distrotube
📽️ LBRY/Odysee: odysee.com/$/invite/@DistroTu...
DT ON THE WEB:
🕸️ Website: distrotube.com/
🐿️ Gemini Capsule: gemini://distro.tube
📁 GitLab: gitlab.com/dwt1
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/
🎵 Ardour: ardour.org/
💻 VirtualBox: www.virtualbox.org/
🗒️ Doom Emacs: github.com/hlissner/doom-emacs
Your support is very much appreciated. Thanks, guys!

Пікірлер: 113

  • @Neucher
    @Neucher2 жыл бұрын

    Yes, please more videos on these UNIX/POSIX standards, whatever you call these.

  • @littlepeon
    @littlepeon2 жыл бұрын

    Random gives a number between 0-32767 as 32768 is notable in computer science for being the absolute value of the maximum value of a 16-bit signed integer.

  • @michaelhoefler5118

    @michaelhoefler5118

    2 жыл бұрын

    Or just the largest value of an unsigned 16-bit integer 🙃

  • @rcht9586

    @rcht9586

    2 жыл бұрын

    @@michaelhoefler5118 no, a 16 bit unsigned integer has values from 0 to 65535

  • @johanngambolputty5351

    @johanngambolputty5351

    2 жыл бұрын

    32767 = 2^15 - 1 = sum of 2^n from 0 to 14 inclusive. Silly question though, why don't they use an unsigned int? Since RANDOM output is always positive anyway

  • @sukhmandersingh4306

    @sukhmandersingh4306

    2 жыл бұрын

    @@michaelhoefler5118 largest value of 16 bit *signed integer.

  • @michaelhoefler5118

    @michaelhoefler5118

    2 жыл бұрын

    @@rcht9586 yes! You are right. My bad!

  • @PinakiGupta82Appu
    @PinakiGupta82Appu2 жыл бұрын

    Quite useful info. Most Linux beginners will find your video super helpful to understand the basics of Environment Variables whether they use the command line regularly or occasionally.

  • @agustinranieri
    @agustinranieri2 жыл бұрын

    Daniel: echo $VAR The cooler Daniel: printenv VAR

  • @sukhmandersingh4306

    @sukhmandersingh4306

    2 жыл бұрын

    It's the other way around. All the cool kids do echo $VAR.

  • @agustinranieri

    @agustinranieri

    2 жыл бұрын

    printenv's rarity makes it cooler (?)

  • @Phydoux2112
    @Phydoux21122 жыл бұрын

    The PATH stuff was getting to me. I have been wanting to dig deeper into this but never did. Your short and sweet description on how to add paths was a Godsend!

  • @12Q46HPRN
    @12Q46HPRN2 жыл бұрын

    Great video! Thanks for the education. Like a script-kiddie, I was just copy/pasting the line: PATH="$HOME/Applications:$PATH" (changing "Applications" to whatever I needed to add) without fully understanding the simple syntax. Now I do. This means worlds to me! I also agree that a playlist of these UNIX/Linux/POSIX commands would be great to help find them all.

  • @VeslorTV
    @VeslorTV2 жыл бұрын

    Awesome content DT cheers from Spain

  • @rafiahmed5017
    @rafiahmed50172 жыл бұрын

    Thank u. I thought installing arch would be really hard ; but your previous tutorial videos had really taught me a lot about that

  • @ikillyou96
    @ikillyou962 жыл бұрын

    Great video, btw 32767 is the highest number that can be represented in a signed 16-bit integer.

  • @ENTMusic-cj7wt

    @ENTMusic-cj7wt

    2 жыл бұрын

    Wait, it is from 0 to 32767, so wouldn't it be an unsigned int then?

  • @ikillyou96

    @ikillyou96

    2 жыл бұрын

    @@ENTMusic-cj7wt No, unsigned 16 bit int would be up to 65535. But due to the use of two's complement, we get half the positive range and no negative numbers :)

  • @supersoniqamanyi3075
    @supersoniqamanyi3075 Жыл бұрын

    Title should be “Environment Variable for 8years olds…” it’s actually that CLEAR !!! Thanks, man.

  • @owendavidmalicsi5900
    @owendavidmalicsi59002 жыл бұрын

    Wow DT. Your lighting is getting better and better

  • @Paul_I_S
    @Paul_I_S2 жыл бұрын

    Thx. for doing great job on this channel. Currently I'm migrating back to Linux. Currently I'm struggeling to set up my printer (ET-3750). But I guess it's just a matter of setting the right permissions or the right environment variables..... Your channel is doing a great job bringing me back up to speed!

  • @theamithsingh
    @theamithsingh Жыл бұрын

    love the explaination, why can't people keep videos nice and simple like this.

  • @nnywadd
    @nnywadd2 жыл бұрын

    You're looking lean bro. Great video.

  • @call_me_Lloydy
    @call_me_Lloydy2 жыл бұрын

    I keep on learning 😊

  • @RishiR
    @RishiR2 жыл бұрын

    THANK YOU!

  • @anikbiswasarnob
    @anikbiswasarnob2 жыл бұрын

    Wow! your T-Shirt is so awesome 😃

  • @Somabilbooks
    @Somabilbooks Жыл бұрын

    thank you Very Much

  • @gabrielbap1
    @gabrielbap12 жыл бұрын

    Great video

  • @parthachattopadhyay2181
    @parthachattopadhyay21812 жыл бұрын

    Hey DT, the range 32767 is int with size 2 (byte). So for a variable defined with integer size 2 can store -32768 to 32767. Thanks for the videos.

  • @vintovkasnipera
    @vintovkasnipera2 жыл бұрын

    Just the video I was looking for! Thanks

  • @dwillingham
    @dwillingham2 жыл бұрын

    Thanks!

  • @mightGalaxyBlackhole
    @mightGalaxyBlackhole Жыл бұрын

    You are very good and decently detailed with you presentations. How many years will it take a newbie to get to your level?

  • @PrashantSharma-ql4yb
    @PrashantSharma-ql4yb2 жыл бұрын

    love the T-Shirt

  • @shubham_srt
    @shubham_srt2 жыл бұрын

    thank youuuu

  • @socvirnylestela5878
    @socvirnylestela58782 жыл бұрын

    btw have u tried river? a tiling window manager for wayland?

  • @xarisfil58
    @xarisfil582 жыл бұрын

    do you have any dotfiles for the specific qtile or something else I think window manger setup?

  • @mikael5743
    @mikael57432 жыл бұрын

    Thanks

  • @edbeckerich3737
    @edbeckerich37372 жыл бұрын

    I need this info in a cheat sheet, i forget it everytime i need it, as long as its in Bash, it never changes

  • @TrueDetectivePikachu

    @TrueDetectivePikachu

    2 жыл бұрын

    @@fedup6127 or markdown, it's less verbose than html

  • @Gabifuertes

    @Gabifuertes

    2 жыл бұрын

    @@TrueDetectivePikachu markdown is great for this purpose, and if you need it as html there's pandoc

  • @GuyWhoChad
    @GuyWhoChad2 жыл бұрын

    hey dt!, i have a question, how can i make the dtos installer?, like when you launch dtos installer it is a GUI INSIDE TERMINAL LIKE NCURSES HOW CAN I DO THAT?

  • @milutinke
    @milutinke2 жыл бұрын

    Hey DT! Can you make a playlist with ordered tutorials for absolute beginners at GNU/Linux? A playlist that would include an explanation about what is GNU/Linux, how it came to be, what is POSIX compliance, how it differs from other Unix-like systems, then the basics about the OS, basics of the bash shell, why FOSS matters, etc. You already have made a lot of videos about those topics, so you could make shorter versions, in which you could link to longer versions, or just link the existing ones in order. (Shorter because people these days have attention span on the level of a goldfish) A lot of people I know want to switch to GNU/Linux because now Proton supports GNU/Linux gaming, it would be neat to point them to a propper source where they would get proper and good knowledge about GNU/Linux and FOSS, instead of not knowing much and being sheep who distro hop because they do not know how to properly configure things, or think the wrong things about GNU/Linux.

  • @xrafter

    @xrafter

    2 жыл бұрын

    How dare you insult me with that " people these days have attention span of goldfish" Please say sorry

  • @anantgupta1188

    @anantgupta1188

    2 жыл бұрын

    I have can have a small attention span like a goldfish but when I am @Linux it can be as long as 3-4 hours

  • @CyberDwarf1949
    @CyberDwarf19492 жыл бұрын

    Niceee! 👏👏👏

  • @007arek
    @007arek2 жыл бұрын

    Why if I put my envs in zprofile or zshenv system doesn't see they? For example sxhkd can't use it.

  • @user-si2vn2si5c
    @user-si2vn2si5cАй бұрын

    Cool T-shirt man, where buy??

  • @AndersJackson
    @AndersJackson2 жыл бұрын

    Actually, Environment variables are defined in the process that run any program, not just Shells. And in Bash, and other Shells, there are variables in the Shell (Bash has both local and global variables in the Shell). Environment variables are the ones in the process. The Good thing is that Environment variables are copyed to the child process. Then the parent process can't change them for the child process. And No process can change any other process Environment variables. Not even the patents. MS Dos have global Environment variables, so any process can change any other programs Environment variables. Which is bad.

  • @killistan

    @killistan

    2 жыл бұрын

    Isn't Dos basically single process though? I'd think that that would mitigate that problem pretty well... Unless future scripts don't initialize their variables properly.

  • @Jupiter__001_

    @Jupiter__001_

    2 жыл бұрын

    So DOS runs into a similar problem as if one were to attempt to use EMACS as an OS?

  • @elys7563
    @elys75632 жыл бұрын

    Hey dt, have you heard of ‘darling’(it’s like wine for Macos)... Btw very informational video

  • @AcidiFy574
    @AcidiFy5742 жыл бұрын

    How about videos about making POSIX compliant Scripts or POSIX compliance in general???

  • @Aleksandar0100

    @Aleksandar0100

    2 жыл бұрын

    shellcheck

  • @zvezdan956

    @zvezdan956

    2 жыл бұрын

    he uses fish

  • @AcidiFy574

    @AcidiFy574

    2 жыл бұрын

    @@zvezdan956 It's worth a shot

  • @longhoacaophuc8293
    @longhoacaophuc82932 жыл бұрын

    Hey DT, how do you colourize your ls command?

  • @HontoNeet

    @HontoNeet

    2 жыл бұрын

    I believe his “ls” is actually an alias for the program “exa” which is an alternative to ls with more features

  • @le0nz

    @le0nz

    2 жыл бұрын

    Yup dt uses exa and the set ls as an aliaz

  • @longhoacaophuc8293

    @longhoacaophuc8293

    2 жыл бұрын

    @@HontoNeet oh, thanks for the information!

  • @Spiritualitydefined
    @Spiritualitydefined2 жыл бұрын

    shell-color-scripts: local (1.0.r52.3dbdfac-1) is newer than AUR (1.0.r39.143937f-1) getting this how do you fix it?

  • @theodiscusgaming3909

    @theodiscusgaming3909

    2 жыл бұрын

    read the error. It looks like the version you have is newer than the one available in the AUR for some reason, so just wait.

  • @itdepends604
    @itdepends6042 жыл бұрын

    can someone explain the difference between ~ and $HOME. When should you use one over the other?

  • @itdepends604

    @itdepends604

    2 жыл бұрын

    @Obvious Honeypot what shell doesn't support ~?

  • @theodiscusgaming3909

    @theodiscusgaming3909

    2 жыл бұрын

    use $HOME in scripts for better compatibility, and ~ in commands.

  • @Paul_I_S
    @Paul_I_S2 жыл бұрын

    👍

  • @dhrubajitchakravarty54
    @dhrubajitchakravarty542 жыл бұрын

    Sir when is DTOS coming sir pls reply waiting for it eagerly

  • @SimGunther

    @SimGunther

    2 жыл бұрын

    When it's ready

  • @peenywallie

    @peenywallie

    2 жыл бұрын

    Why do Indians always say "sir"?

  • @Jupiter__001_

    @Jupiter__001_

    2 жыл бұрын

    @@peenywallie I suppose it must be good etiquette in their languages.

  • @PhilipHarwell
    @PhilipHarwell2 жыл бұрын

    Surprised it isn’t uid == 0, typically in programming, you need two = for equality check. Single = is for assigning value to a variable.

  • @xrafter

    @xrafter

    2 жыл бұрын

    You can use == with the shell built-in that starts with [[ and end with ]]>

  • @stephan6530

    @stephan6530

    2 жыл бұрын

    Bash accepts both '==' and '=' for string equality comparison. '=' is usually used with the 'test' command for POSIX conformance.

  • @boblol1465
    @boblol14652 жыл бұрын

    do a video on hannah montana linux

  • @plasmalife5532
    @plasmalife55322 жыл бұрын

    Difference between $HOME AND ~/ ??

  • @xrafter

    @xrafter

    2 жыл бұрын

    same thing in the man page of ls or something idr, "~" is almost always $HOME .

  • @killistan

    @killistan

    2 жыл бұрын

    do this in a shell to get a behavioral idea: echo ~ echo "~" echo $HOME echo "$HOME" basically, $HOME is a variable, ~ is something more like a glob (It's not technically a glob). You'll notice that when quoted, the variable is expanded, but ~ is not.

  • @xrafter

    @xrafter

    2 жыл бұрын

    @@killistan Wow i just try it and it blew my mind . ~ is rigged .

  • @killistan

    @killistan

    2 жыл бұрын

    @@xrafter Yeah, almost always use $HOME in scripts, but who wants to type that in the command line all the time?

  • @plasmalife5532

    @plasmalife5532

    2 жыл бұрын

    Thanks to everyone

  • @kapellimestari0078
    @kapellimestari00782 жыл бұрын

    Hello, i just watched you video about irssi, and do you know some chat program like this one? but safety and privacy... Or batter, maybe could you teach how create a chat between two computer? wait, a better topic, if you know could you please make a video about cryptography, and the asymmetric cryptography, and the most important, how to apply the asymmetric, because for example , I know about it, but I don't really know how to use it, how to implement and so on and so forth. Or maybe anyone who is reading this comment could please send me a video or a site or a book about it please

  • @Tn5421Me
    @Tn5421Me2 жыл бұрын

    I just realized you have /home/dt/.local/bin in your path twice

  • @chiranjeevinaidu3660
    @chiranjeevinaidu36602 жыл бұрын

    Bro can you make a video on how we can setup our own cross platform terminal that can run all the commands of bash and cmd it will be really cool if you could make a video on this topic.

  • @sourabhk2373
    @sourabhk23732 жыл бұрын

    What is a Hindu Goddess doing on your t-shirt ? PS: Nice video!

  • @MaxHeroGamer
    @MaxHeroGamer2 жыл бұрын

    32767 is the maximum number you can represent with 15 bits. I don't know why they used 15 bits for it, though.

  • @hughesd.mungus9819

    @hughesd.mungus9819

    2 жыл бұрын

    it's the max of a signed 16 bit number so -32768 to 32767

  • @MaxHeroGamer

    @MaxHeroGamer

    2 жыл бұрын

    @@hughesd.mungus9819 Oh it's signed...

  • @praetorxyn
    @praetorxyn2 жыл бұрын

    It's a pity there's not a good "shell agnostic" way of setting global environment variables for things like XDG compliance... at least not when you include the fish shell in the criteria for "shell agnostic." I know you could edit .profile or /etc/profile or something... but the whole point of forcing XDG compliance is to get rid of things like .profile. I suppose you could set the default shell to bash and just have bash set the variables and launch fish, and I think the variables might persist to the fish session and your desktop environment... but eh. Such a hack.

  • @AndersJackson

    @AndersJackson

    2 жыл бұрын

    No, XGD are not about remove /etc/profile etc. It is about being able to use locale adjusted directories, like ~/Document is used in English locale and ~/Dukument in Swedish. And config files in ~/.config etc. Has nothing to do with Shell init files. You still need Them That is what the environmen

  • @praetorxyn

    @praetorxyn

    2 жыл бұрын

    @@AndersJackson I never said it was supposed to get rid of anything in /etc... but /etc is beyond the scope of user configuration, so changes there can't easily be stored in a dotfiles repo. You literally just said XDG is so that user configuration goes in ~/.config. ~/.profile, ~/.vim, ~/.ssh, etc literally all violate this. It should be ~/.config/profile, ~/.config/vim, ~/.config/ssh, etc. fish is the only shell that respects XDG (though you can sort of force zsh to do so by setting ZPROFILE early enough... though you'd probably need to face the same sort of conundrum to do so.

  • @billfarley9015
    @billfarley90152 жыл бұрын

    I don't have mouseface. not in repo. I found it in Github. Can someone please tell me the command to download it. The Github-clueless among us would appreciate it. I do have fortune though. The first time I tried it I got this : Q: How many existentialists does it take to screw in a light bulb? A: Two. One to screw it in and one to observe how the light bulb itself symbolizes a single incandescent beacon of reality in a netherworld of endless absurdity reaching out to a maudlin cosmos of nothingness.

  • @kerodfresenbetgebremedhin1881
    @kerodfresenbetgebremedhin18812 жыл бұрын

    it is 32767 because it uses 16 bits to store

  • @aer0449
    @aer04492 жыл бұрын

    That print on his T-shirt is of religious Goddess in Hinduism...

  • @tomoghnosen
    @tomoghnosen2 жыл бұрын

    Is it goddess Kali maa in your tshirt

  • @anantgupta1188

    @anantgupta1188

    2 жыл бұрын

    I guess yes

  • @williemaddox9919
    @williemaddox99192 жыл бұрын

    You have an extra /home/dt/.local/bin in your $PATH just fyi...

  • @punishr90
    @punishr902 жыл бұрын

    Thats a 'KALI' on his t-shirt

  • @arkvsi8142
    @arkvsi81422 жыл бұрын

    I use MS DOS

  • @send2gl
    @send2gl2 жыл бұрын

    Why would someone use a sub shell?

  • @Gabifuertes

    @Gabifuertes

    2 жыл бұрын

    Try fish and you'll be invoking bash for opening scripts or just out of frustration

  • @send2gl

    @send2gl

    2 жыл бұрын

    @@Gabifuertes I can understand an alternative terminal but can't quite get why someone would use a terminal to open another terminal. Unless of course there are circumstances (of which I am not aware) whereby one terminal is preferable to another.

  • @neuzen
    @neuzen2 жыл бұрын

    BTW I use fish

  • @bahathir_
    @bahathir_2 жыл бұрын

    $ p='Hello. ' $ echo $p Hello, $ p+='world!' $echo $p Hello, world!

  • @leviticus8930
    @leviticus89302 жыл бұрын

    First?

  • @Waffelo
    @Waffelo2 жыл бұрын

    Waffelo

  • @plasmalife5532
    @plasmalife55322 жыл бұрын

    Are you supporting hindu religion 🤔 (t-shirts)

  • @vintovkasnipera

    @vintovkasnipera

    2 жыл бұрын

    doesn't necessarily mean so

  • @anantgupta1188

    @anantgupta1188

    2 жыл бұрын

    not sure but in one video he says that he read holy books of many religions like the bible, Quran, Bhagavad Gita If anyone notices that he also have lord buddha statute

  • @ignisimmensus2568
    @ignisimmensus25682 жыл бұрын

    Can you please use timestamps on your videos? thanks

  • @dkosmari
    @dkosmari2 жыл бұрын

    I'm gonna try to offer some constructive criticism, since I feel like this was of lower quality than, say, your org-mode videos. One mistake you're making here is trying to reword and rename concepts, to the point of being technically wrong. For instance, your usage of "local" vs "global" variables doesn't match what is actually local vs global variables in shell scripting. You meant "variables" vs "environment variables", because that's what Bash (and POSIX) names them. Questions that I think should have been answered in the video: - What is a variable? - What is the environment? - How do you add, change or remove a variable in the environment? - How do you modify the environment only for the child process? - What are the standard ways to persistently customize the environment? That last one is the single most useful information for people that don't want to dive into shell programming, yet you devoted the least amount of time to it. - "Why does my PATH have the same location twice?" - "Why does my shell see the variable, but the script I invoke doesn't?" - "Why isn't ~/.config/environment.d working is the documentation says it should work?" (Spoiler: because systemd.)

  • @MrTAL69
    @MrTAL692 жыл бұрын

    Sorry DT but there are actual definitions for concepts of local and global variable, and that's not it. Since you're being (for a good reason!) followed by total newbies, you really shouldn't be playing it fast and loose. Oher people may at a later point need to un-teach incorrect concepts before they can learn correct ones; and that's a bi*ch job.

  • @aaronspeedy7780
    @aaronspeedy7780 Жыл бұрын

    11:02 You can just do $PATH+=:/path_to_dir

  • @thalhas9760
    @thalhas97602 жыл бұрын

    Thanks

Келесі