The Biggest Lie You're Told About Shell Programming? A response to Terminalforlife
Terminalforlife recently released a video in which he argues that a reliance on external programs, particularly in shell scripting instructional content, is the biggest lie of shell programming. In many cases, calling out to an external program is slower and less efficient (in terms of resource utilization) than simply writing the equivalent functionality yourself directly within the shell language itself.
I disagree with him that this is a serious problem, and lay out my reasoning why in this video.
This was recorded away from my usual setup, so the audio quality isn't as good as I'd like. Apologies for that.
Recently, Kyoto University lost a large amount of research data to a poorly timed script update. In this video I conjecture as to what happened, and provide some advice on how to prevent a similar thing from happening to you.
The root cause of the issue seems to be the manner in which POSIX shells (and others) interpret an undefined variable, combined with they way in which shells process the script file itself.
On encountering an undefined variable, rather than throwing an error, many shells assume the variable to be empty-valued. This is very convenient, but can lead to subtle bugs as well. Most shells have a way to change this behavior, so that an error is thrown instead, but these are not commonly used as they are inconvienent.
That issue seems to have been combined with the fact that some interpreters (including bash), only read small sections of the script from disk at a time. This means that, if the script on disk is changed while the script is running, variables can spontaniously become undefined within the running script. If that variable is used as part of the path in an rm command, for example, this can result in the unintended deletion of files.
Original Article
https://www.techspot.com/news/92822-japanese-university-loses-77tb-research-data-following-buggy.html
...
https://www.youtube.com/watch?v=DlT1qhtY76s
In my earlier video, Linux Terminal Tutorial Episode 3, I had a misunderstanding as to what the commands su and sudo actually did. Well, perhaps not a misunderstanding, but an incomplete one. Su and sudo stand for "substitute user" and "substitute user do" respectively and allow a user on a Linux system to temporarily log in to another user's account and gain that user's permissions.
By default, both commands log into the root user account. However, by typing a username following su, or by using the -u tag with sudo, one can swap into any user on the system.
Additional reading:
Archwiki page on sudo : https://wiki.archlinux.org/index.php/Sudo
Archwiki page on su: https://wiki.archlinux.org/index.php/Su
man pages (type "man" followed by the command you want the manual for into the terminal, "man su")
...
https://www.youtube.com/watch?v=UON-owbAsc0
In this video I discuss the basics of managing processes in Bash using the job ID. I discuss putting processes in the foreground and background using fg and bg, killing processes by job ID using the kill command, stopping processes with ctrl-z, and using nohup and disown to prevent a process from stopping when the parent terminal is killed.
...
https://www.youtube.com/watch?v=VP-Zshwy-1I
I've been looking into different data archival solutions, particularly for video footage, and decided to give Blu-ray disks a shot. Unfortunately, Gnome's burning program, Brasero, doesn't work (or at least I wasn't able to get it to work) with them, so I had to find a different option: xfburn. This video discusses burning blu-rays using xfburn, as well as some other general commentary on the topic. It's a deep rabbit hole that I've only just looked down, but if there's interest I can pursue the topic further. Let me know in the comments!
...
https://www.youtube.com/watch?v=VGXb0UOhvBU
Find is a pretty powerful UNIX command that has a lot of functionality. Unfortunately, this makes it a little difficult to use. In particular, getting it to do what its name implies (locate files) is a little tricky, and the GNU man page doesn't have a good minimal example of how to use it.
The upshot is that you can use,
$ find DIR -name STR
To recursively search the directory DIR and all its sub-directories for files which have a name of STR. You can also use wildcards as part of STR. For example, so find all C source and header files in your home directory, you could do
$ find ~ -name *.[ch]
This is a video "from the archives". I recorded it ages ago and stumbled across the file on a hard drive recently. Figured I'd upload it.
...
https://www.youtube.com/watch?v=BmPkzi0T8Uw
This video discusses setting up Geary, Calendar, and Contacts in Pop!_OS 20.04, though the principles should apply to any computer running a Gnome desktop environment. As an example, I use a random email account hosted through Namecheap, and set up IMAP, SMTP, CalDav, and CardDav.
...
https://www.youtube.com/watch?v=MmWT9Uuc5Xs
Finally, we can get to serving web pages. In this video we discuss configuring a simple Web server and deploying our html files to it.
...
https://www.youtube.com/watch?v=DjtsRPof-8U