1/9/2024 0 Comments Xkcd sudo![]() This is a common joke in the Linux community, an example of which can be found at this viral tweet which shows a humorous workaround for the issue. A side effect of this, however, is that an administrator may forget to prefix their command with sudo, and re-running it properly the second time. This prevents accidental errors and enables logging of all sensitive commands. Good unix practice dictates never logging in as root instead you stay logged in as your normal user, and run system admin accounts via sudo program name. One of the more subtle jokes in the comic is the inclusion of apt-get and sudo apt-get in the same script. Most of the commands would simply give an error and exit, but hopefully the correct one will proceed with the install. Near the end, it even tries copying the source code from an online source and then runs several commands which compile/build the program.Īll in all, this script would probably work it runs many standard popular repository programs and package managers, and runs the nearly-universal commands needed to build a program. The end result is the name being tried against a large number of software repositories and package managers, and hopefully, at least one of them will be appropriate and the program will be successfully installed. Everywhere the script says "$1", it substitutes in the name of the package you gave it. This value is then referenced as "$1" (argument number 1). The script accepts the name of a program or package as an argument when you run it. This has the effect of running all the install commands simultaneously all output and error text provided by them will be mixed together as they are all displaying on the screen around the same time. In between each of the install commands in the script is the & character, which in POSIX-compatible shells (including Bash, a popular shell scripting language) means it should continue to run the next command without waiting for the first command to finish, also known as "running in the background". This script in particular is interpreted by the Bourne Again Shell (Bash), which is denoted by the #!/bin/bash in the first line. The install.sh file provided in the comic is a shell script, which attempts to fix this problem by acting as a "universal install script" that contains a lot of common install commands used in various Unix-like systems. If you only know the name of a program or package, you may not know in which repository(ies) it resides. However, there are many such repositories, such as " pip" and "brew", among others listed in the comic. ![]() When you download the package, it automatically does most of the work of building the code into something executable if necessary and then installing it. To make this process simpler, there exist repositories of programs which host either packages of source code and the things needed to build it or the pre-built programs. Under Unix-like systems, which this universal install script is designed for, you may have to work with "build environments" and " makefiles", and command line tools. However, when things are more "homebrew", for example downloading source code, things are more complicated. Sometimes you don't even have to install anything at all, and it runs without any installation. pkg, double click it, and do what it says. Most users of computers today are used to simple, easy installation of programs. (Note: The 'yes' command and '2>/dev/null' are recommended additions.) Title text: The failures usually don't hurt anything, and if it installs several versions, it increases the chance that one of them is right. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |