Bash Scripting for Beginners: Complete Guide to Getting Started - Where to Store Scripts (Part 10)

preview_player
Показать описание
So at this point, you've written a ridiculous number of scripts and these files are all over your hard drive. Wouldn't it be cool if there was a central place to store these? Well, there is - the Linux filesystem has designated places for these kinds of things. And that's what we'll take a look at in this video.

*LEARN LINUX TV - YOUR HOME FOR LINUX-RELATED FUN AND LEARNING!*

*🎓 BRAND NEW UDEMY COURSES AVAILABLE!*
Check out my new courses on Udemy and learn something new!

*🐧 SUPPORT LINUX LEARNING!*
_Note: Royalties and/or commission is earned from each of the above links_

*⏰ TIME CODES*
00:00 - Intro
00:48 - The weaknesses of how we've been running scripts so far
02:39 - Where should you store your Bash Scripts? (and the FHS)
04:20 - Moving a script into /usr/local/bin
06:24 - Why it's not necessary to use file extensions in Linux filenames
08:08 - Understanding $PATH on the Linux shell
10:48 - Adding a directory to your $PATH variable in Linux

OTHER BASH SCRIPTING SERIES EPISODES

*🌐 LEARN LINUX TV ON THE WEB*

*⚠️ DISCLAIMER*
Learn Linux TV provides technical content that will hopefully be helpful to you and teach you something new. However, this content is provided without any warranty (expressed or implied). Learn Linux TV is not responsible for any damages that may arise from any use of this content. Always make sure you have written permission before working with any infrastructure and that you are compliant with all company rules, change control procedures, and local laws.

#linuxforbeginners #commandline #technology
Рекомендации по теме
Комментарии
Автор

Finally I know what's `/usr/local/bin` and how to properly use it. Thank you, Jay.

yuzhu
Автор

I usually have my scripts on a folder in my home directory, and then to make them executable from anywhere I just create a symbolic link to the script in a path folder. Cheers!

Miguel_GM
Автор

And I finally understand how to add permanent scripts to the terminal! Thanks Jay!!

jojobobbubble
Автор

I really like your videos and would like to thank you for all your work.
In this video a small carelessness has crept in, to which I would like to draw attention briefly.

At minute 6 after ls -l /usr/locacl/bin you see the following output:
"-rwxrwxr-x" (775)

However, it would be better and above all safer to set the permissions as follows:
"-rwxrwxr--" (774)

This way only root or root privileged user can execute this command.

Hope this helps.

Thanks again for your wonderful work. - Big THANK YOU!

emanuelwieland
Автор

Love this serie but would be handy if you also added the link in description to the wiki page you ran

Theborg
Автор

I’m not sure if i heard it wrong or it’s an honest mistake. But usr stands for Unix system resources instead of user. Very informative video tho!

jiasonghuang
Автор

Just make sure to backup usr/local/bin if you upgrade your linux version. Also, i think using the export command that way only changes your path for that session.

noweare
Автор

Just amazing pedagogy. Thank you much!

maxbilo
Автор

I use ~/.local/bin/ for my scripts mainly because it is added to the $PATH (if present) via the .profile file (it also looks for ~/bin/ directory as well). This works for me as I have a single user system, however I would use /usr/bin/ as Jay suggests to make it system wide if I had more that one user.

busdriver
Автор

What desktop system do you have? I don't know why but I want that background and green glowy border very badly 😂

DannyRoberts-ul
Автор

Does "export" to reconfigure the $PATH work only in that shell? I think so but I can't test it at the moment. Seems to me that we need a script that sets $PATH whenever we open a new shell.

zeppelinmexicano
Автор

I mostly keep my scripts in /home/$USER/scripts or /home/$USER/.local/bin because mostly it's just me using them; the .local/bin directory is in my $PATH but scripts is not.

I find the Linux Filesystem Hierarchy Standard a little confusing, or maybe it's confused (even that's confusing). You're not supposed to create directories off the root, but the standard Linux directories seem liable to be not updated properly if you e.g. have to reinstall or you have a new installation. On Windows every app goes under the Program Files directory and e.g. Windows and Windows\System32 is not (usually these days) updated with user or application binaries. On Linux you have a plethora of directories under /usr and there's also the /opt directory if you're installing an application, maybe. Some apps install themselves there, some go in various directories under /usr. It doesn't seem like there are hard and fast rules as to what goes where, and I know that files go in slightly different locations on different distros which makes it even more confusing!

If you're a developer with several users on a machine and you want to share source and include files for example, where are you supposed to put them? Include files probably go under /usr/include. but you don't really want to put them there because that's a distro-created directory that contains files specific to the C compiler. You could create a subdirectory but of course that won't be migrated to a new system without manual copies. Source files probably go somewhere under /usr/share or /usr/src or maybe it's /var. I really find it difficult to know where files should go that won't interfere with system/distro-provided files, and which won't get clobbered or left out on a system upgrade or migration.

These days I'm considering putting my source and includes in containers and accessing them via HTTP or SMB e.g. (or NFS if I can ever figure it out). That won't answer my questions regarding directory hierarchy, but will make migration more straighforward, in theory.

treyquattro
Автор

This video is 1337 .... I mean length ;)

Roje
Автор

the shop linux tv store is blocking the LIKE button

tobaakanbi