How To Use Shell Environment Variables

  Рет қаралды 33,997

DistroTube

DistroTube

Күн бұрын

Пікірлер: 112
@Neucher
@Neucher 3 жыл бұрын
Yes, please more videos on these UNIX/POSIX standards, whatever you call these.
@PinakiGupta82Appu
@PinakiGupta82Appu 3 жыл бұрын
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.
@littlepeon
@littlepeon 3 жыл бұрын
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 3 жыл бұрын
Or just the largest value of an unsigned 16-bit integer 🙃
@rcht9586
@rcht9586 3 жыл бұрын
@@michaelhoefler5118 no, a 16 bit unsigned integer has values from 0 to 65535
@johanngambolputty5351
@johanngambolputty5351 3 жыл бұрын
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 3 жыл бұрын
@@michaelhoefler5118 largest value of 16 bit *signed integer.
@michaelhoefler5118
@michaelhoefler5118 3 жыл бұрын
@@rcht9586 yes! You are right. My bad!
@Phydoux2112
@Phydoux2112 3 жыл бұрын
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!
@agustinranieri
@agustinranieri 3 жыл бұрын
Daniel: echo $VAR The cooler Daniel: printenv VAR
@sukhmandersingh4306
@sukhmandersingh4306 3 жыл бұрын
It's the other way around. All the cool kids do echo $VAR.
@agustinranieri
@agustinranieri 3 жыл бұрын
printenv's rarity makes it cooler (?)
@Not-THAT-ChrisPratt
@Not-THAT-ChrisPratt 3 жыл бұрын
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.
@supersoniqamanyi3075
@supersoniqamanyi3075 Жыл бұрын
Title should be “Environment Variable for 8years olds…” it’s actually that CLEAR !!! Thanks, man.
@theamithsingh
@theamithsingh Жыл бұрын
love the explaination, why can't people keep videos nice and simple like this.
@miguelperezpal
@miguelperezpal 3 жыл бұрын
Awesome content DT cheers from Spain
@rafiahmed5017
@rafiahmed5017 3 жыл бұрын
Thank u. I thought installing arch would be really hard ; but your previous tutorial videos had really taught me a lot about that
@Paul_I_S
@Paul_I_S 3 жыл бұрын
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!
@owendavidmalicsi5900
@owendavidmalicsi5900 3 жыл бұрын
Wow DT. Your lighting is getting better and better
@nnywadd
@nnywadd 3 жыл бұрын
You're looking lean bro. Great video.
@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?
@edbeckerich3737
@edbeckerich3737 3 жыл бұрын
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 3 жыл бұрын
@@fedup6127 or markdown, it's less verbose than html
@Gabifuertes
@Gabifuertes 3 жыл бұрын
@@TrueDetectivePikachu markdown is great for this purpose, and if you need it as html there's pandoc
@parthachattopadhyay2181
@parthachattopadhyay2181 3 жыл бұрын
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.
@RishiR
@RishiR 3 жыл бұрын
THANK YOU!
@vintovkasnipera
@vintovkasnipera 3 жыл бұрын
Just the video I was looking for! Thanks
@anikbiswasarnob
@anikbiswasarnob 3 жыл бұрын
Wow! your T-Shirt is so awesome 😃
@milutinke
@milutinke 3 жыл бұрын
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 3 жыл бұрын
How dare you insult me with that " people these days have attention span of goldfish" Please say sorry
@anantgupta1188
@anantgupta1188 3 жыл бұрын
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
@call_me_Lloydy
@call_me_Lloydy 3 жыл бұрын
I keep on learning 😊
@Somabilbooks
@Somabilbooks 2 жыл бұрын
thank you Very Much
@AndersJackson
@AndersJackson 3 жыл бұрын
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 3 жыл бұрын
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_ 3 жыл бұрын
So DOS runs into a similar problem as if one were to attempt to use EMACS as an OS?
@PrashantSharma-ql4yb
@PrashantSharma-ql4yb 2 жыл бұрын
love the T-Shirt
@AcidiFy574
@AcidiFy574 3 жыл бұрын
How about videos about making POSIX compliant Scripts or POSIX compliance in general???
@Aleksandar0100
@Aleksandar0100 3 жыл бұрын
shellcheck
@zvezdan956
@zvezdan956 3 жыл бұрын
he uses fish
@AcidiFy574
@AcidiFy574 3 жыл бұрын
@@zvezdan956 It's worth a shot
@IronLung-x7d
@IronLung-x7d 5 ай бұрын
Cool T-shirt man, where buy??
@socvirnylestela5878
@socvirnylestela5878 3 жыл бұрын
btw have u tried river? a tiling window manager for wayland?
@dwillingham
@dwillingham 3 жыл бұрын
Thanks!
@aer0449
@aer0449 3 жыл бұрын
That print on his T-shirt is of religious Goddess in Hinduism...
@GuyWhoChad
@GuyWhoChad 3 жыл бұрын
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?
@xarisfil58
@xarisfil58 3 жыл бұрын
do you have any dotfiles for the specific qtile or something else I think window manger setup?
@gabrielbap1
@gabrielbap1 3 жыл бұрын
Great video
@longhoacaophuc8293
@longhoacaophuc8293 3 жыл бұрын
Hey DT, how do you colourize your ls command?
@HontoNeet
@HontoNeet 3 жыл бұрын
I believe his “ls” is actually an alias for the program “exa” which is an alternative to ls with more features
@le0nz
@le0nz 3 жыл бұрын
Yup dt uses exa and the set ls as an aliaz
@longhoacaophuc8293
@longhoacaophuc8293 3 жыл бұрын
@@HontoNeet oh, thanks for the information!
@mikael5743
@mikael5743 3 жыл бұрын
Thanks
@elys7563
@elys7563 3 жыл бұрын
Hey dt, have you heard of ‘darling’(it’s like wine for Macos)... Btw very informational video
@007arek
@007arek 3 жыл бұрын
Why if I put my envs in zprofile or zshenv system doesn't see they? For example sxhkd can't use it.
@PhilipHarwell
@PhilipHarwell 3 жыл бұрын
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 3 жыл бұрын
You can use == with the shell built-in that starts with [[ and end with ]]>
@stephan6530
@stephan6530 3 жыл бұрын
Bash accepts both '==' and '=' for string equality comparison. '=' is usually used with the 'test' command for POSIX conformance.
@shubham_srt
@shubham_srt 2 жыл бұрын
thank youuuu
@Tn5421Me
@Tn5421Me 3 жыл бұрын
I just realized you have /home/dt/.local/bin in your path twice
@sourabhk2373
@sourabhk2373 3 жыл бұрын
What is a Hindu Goddess doing on your t-shirt ? PS: Nice video!
@dhrubajitchakravarty54
@dhrubajitchakravarty54 3 жыл бұрын
Sir when is DTOS coming sir pls reply waiting for it eagerly
@SimGunther
@SimGunther 3 жыл бұрын
When it's ready
@peenywallie
@peenywallie 3 жыл бұрын
Why do Indians always say "sir"?
@Jupiter__001_
@Jupiter__001_ 3 жыл бұрын
@@peenywallie I suppose it must be good etiquette in their languages.
@tomoghnosen
@tomoghnosen 3 жыл бұрын
Is it goddess Kali maa in your tshirt
@anantgupta1188
@anantgupta1188 3 жыл бұрын
I guess yes
@itdepends604
@itdepends604 3 жыл бұрын
can someone explain the difference between ~ and $HOME. When should you use one over the other?
@itdepends604
@itdepends604 3 жыл бұрын
@Obvious Honeypot what shell doesn't support ~?
@theodiscusgaming3909
@theodiscusgaming3909 3 жыл бұрын
use $HOME in scripts for better compatibility, and ~ in commands.
@boblol1465
@boblol1465 3 жыл бұрын
do a video on hannah montana linux
@CyberDwarf1949
@CyberDwarf1949 3 жыл бұрын
Niceee! 👏👏👏
@MaxHeroGamer
@MaxHeroGamer 3 жыл бұрын
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 3 жыл бұрын
it's the max of a signed 16 bit number so -32768 to 32767
@MaxHeroGamer
@MaxHeroGamer 3 жыл бұрын
@@hughesd.mungus9819 Oh it's signed...
@CreachterZ
@CreachterZ 2 ай бұрын
Make those local scripts functions.
@kerodfresenbetgebremedhin1881
@kerodfresenbetgebremedhin1881 3 жыл бұрын
it is 32767 because it uses 16 bits to store
@punishr90
@punishr90 3 жыл бұрын
Thats a 'KALI' on his t-shirt
@praetorxyn
@praetorxyn 3 жыл бұрын
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 3 жыл бұрын
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 3 жыл бұрын
@@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.
@kapellimestari0078
@kapellimestari0078 3 жыл бұрын
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
@Paul_I_S
@Paul_I_S 3 жыл бұрын
👍
@plasmalife5532
@plasmalife5532 3 жыл бұрын
Difference between $HOME AND ~/ ??
@xrafter
@xrafter 3 жыл бұрын
same thing in the man page of ls or something idr, "~" is almost always $HOME .
@killistan
@killistan 3 жыл бұрын
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 3 жыл бұрын
@@killistan Wow i just try it and it blew my mind . ~ is rigged .
@killistan
@killistan 3 жыл бұрын
@@xrafter Yeah, almost always use $HOME in scripts, but who wants to type that in the command line all the time?
@plasmalife5532
@plasmalife5532 3 жыл бұрын
Thanks to everyone
@chiranjeevinaidu3660
@chiranjeevinaidu3660 3 жыл бұрын
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.
@bahathir_
@bahathir_ 3 жыл бұрын
$ p='Hello. ' $ echo $p Hello, $ p+='world!' $echo $p Hello, world!
@williemaddox9919
@williemaddox9919 3 жыл бұрын
You have an extra /home/dt/.local/bin in your $PATH just fyi...
@billfarley9015
@billfarley9015 3 жыл бұрын
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.
@neuzen
@neuzen 3 жыл бұрын
BTW I use fish
@send2gl
@send2gl 3 жыл бұрын
Why would someone use a sub shell?
@Gabifuertes
@Gabifuertes 3 жыл бұрын
Try fish and you'll be invoking bash for opening scripts or just out of frustration
@send2gl
@send2gl 3 жыл бұрын
@@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.
@arkvsi8142
@arkvsi8142 3 жыл бұрын
I use MS DOS
@leviticus8930
@leviticus8930 3 жыл бұрын
First?
@ignisimmensus2568
@ignisimmensus2568 3 жыл бұрын
Can you please use timestamps on your videos? thanks
@dkosmari
@dkosmari 3 жыл бұрын
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.)
@plasmalife5532
@plasmalife5532 3 жыл бұрын
Are you supporting hindu religion 🤔 (t-shirts)
@vintovkasnipera
@vintovkasnipera 3 жыл бұрын
doesn't necessarily mean so
@anantgupta1188
@anantgupta1188 3 жыл бұрын
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
@Waffelo
@Waffelo 3 жыл бұрын
Waffelo
@MrTAL69
@MrTAL69 3 жыл бұрын
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
@thalhas9760 2 жыл бұрын
Thanks
Three Incredibly Useful Command Line Tools (shuf, sort, uniq)
10:57
Shell Aliases Every Linux User Needs
29:03
DistroTube
Рет қаралды 38 М.
Can You Find Hulk's True Love? Real vs Fake Girlfriend Challenge | Roblox 3D
00:24
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 1,6 МЛН
Essential Linux Commands - Cat, Tac and Tee
21:07
DistroTube
Рет қаралды 24 М.
Linux for Programmers #7 | Environment Variables
12:31
Akamai Developer
Рет қаралды 40 М.
The 12 Linux Apps Everyone Should Know About
21:20
DistroTube
Рет қаралды 475 М.
Understand Bash Environment Variables With This Deep Dive
20:41
theurbanpenguin
Рет қаралды 11 М.
Why Are Open Source Alternatives So Bad?
13:06
Eric Murphy
Рет қаралды 682 М.
Essential Keybindings For Bash, Fish and Zsh
16:41
DistroTube
Рет қаралды 29 М.
Understanding Variables on the Linux Command-Line
18:01
Learn Linux TV
Рет қаралды 17 М.
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 258 М.
7 Apps Better Than The Defaults Your Distro Ships
12:43
DistroTube
Рет қаралды 102 М.