Ticker

6/recent/ticker-posts

Linux essential

 

open source refers to computer software or programs in which the source code is readily available for public use or modification from its original design.

So what are some examples of great open source software?
Well if you just take a look at a simple web server, you're going to find a ton of open source software being used.
For example, if you're running an Apache web server then you're running open source software.
WordPress is used to run over 30% of the internet's websites these days. And guess what, it's all open source software. This means you can go to WordPress.org, download the entire code base

for the WordPress content management system and you can modify it, edit it, and change it as much as you like.

This is a great thing about open source software. You have full access to all of the code that's used to make these programs run and you can modify them to meet your exact needs.

Now there are many different types of software licenses used in the open source community. These include the new 
General Public License 
The Apache License
The MIT License and even the Unlicense. 
These licenses represent the entire spectrum of open source licenses, from highly protected to unconditional.

Depending on your specific needs for your open source project you can choose which of these open source licenses work best for you.

Linux is packaged into something known as a distribution. 

Distributions are also called distros for short. Each distro consists of a Linux kernel, which is the core computer program with complete control over everything in the system. It's supporting software, it's libraries, and it's configuration files. 
All of these components make Linux a complete operating system, just like Microsoft, Windows, or macOS X platform.

Linux distributions differ from one another depending on who the developers are and what they want their distribution to achieve..

Now at the core of any Linux distribution is what's known as a kernel. A kernel is a low-level computer program that functions as the bridge between the user and the computer's resources.

Some of it's functions include memory management and management of input and output devices.

Now since a Linux distribution is a complete operating system, additional software such as server and networking programs, desktop environments, and productivity tools also ship with most Linux distributions.

This supplemental software helps to provide specific types of branding for some distributions, especially when it comes to the desktop environment and the ability to manage the system easily.

For example, you may need to add a printer or you may want to find and install commonly used productivity software, like a word processor, a spreadsheet program, or a presentation program. These things can all be bundled as part of the distribution.

Now a unique feature of Linux is the way the start up processes are managed by the system. Different distributions have different scripts and utilities to launch programs that link the computer to the network, or present the log in prompt, and many other common functions.

Now this gives each distribution a unique personality, which can then be configured according to your own unique specific preferences.

Typically, Linux distributions are available for download directly from their developers websites. You can download the image file, and then burn it to a CD or DVD. Or, you can use a small program to install that to a USB flash drive and use that as your installation media.

Now if you're a large company or a commercial user, you can also install the distro directly onto a private virtual server or a commercial cloud service, something like Amazon's AWS, the Google Cloud, or Microsoft's Azure Cloud service.

When new versions are going to' be released to the public. Generally, only the final release version, which is the most stable, is recommended for you to use. However, developers can also publish versions that are recommended to be used

only for testing and debugging, called pre-release versions. These versions are categorized as alpha, which is the very new, and contains a lot of bugs, or beta, which is where most testing is really done.

After beta testing, the final release version is put out, and it's considered to be stable. Now, most of the release schedules are publicly announced months or years in advance. However, some delays may be encountered due to security enhancements, debugging, and other factors.

This practice is generally acceptable as long as the delay doesn't take too long, and causes everyone to think that the distro has been abandoned by the developers.

OS X is the operating system that runs on Macintosh computers by Apple. It is not a Linux distribution, but instead is based on BSD. Both Linux and BSD share a lot of the same features as they are both based on Unix, so you can use many of the things you learn in this class in your Mac OS X system, too!

Linux is based on the Unix operating system.

Which of the following is TRUE about open source software?
It is alwasy free
It is a prominent example of open collaboration
It is more secure than closed source software
There is no support for open source software
While all the other options are SOMETIMES true, they are not true for all open source software. The only statement that is ALWAYS TRUE is that open source software is a great example of open collaboration.

Which of the following is NOT TRUE about the Linux distribution life cycle?
Linux distros are always short term release
Most of the release schedules are publically announced months or years in advance
Some developers come up with cathy names for version
The final version is considered to be the stable version

Android is an embedded operating system variant of Linux that is used in smartphones, tablets, and Smart TVs.

The HCL (Hardware Compatibility List) provides a list of all supported devices within a given distro.

There is no perfect operating system. Each operating system has its strengths and weaknesses, so it is up to the user to decide which is best for their specific use case.

There are multiple ways to install the Linux operating system, including from a disk, a usb drive, over the network, and more.

Preemptive multitasking is a task in which a computer operating system uses some criteria to decide how long to allocate to any one task before giving another task a turn to use the operating system. The act of taking control of the operating system from one task and giving it to another task is called preempting.

Smart TVs often run an embedded version of Linux. For example, the Roku TVs and Roku devices all run an operating system called Roku OS (which is a manufacturer created version of Linux).

Well open source software is software which is released under a license in which the copyright holder grants users the right to study it, change it, and distribute it to anyone for any purpose. As such the source code, that human readable core of the software, is actually available for inspection, modification, and enhancement.

Open source software is usually developed in collaboration in a public manner and it's a good example of how open collaboration can be used to create some great products and services.

Now because of this collaboration, software developers may want to publish their software with an open source license, such as the GNU, general public license, or GPL so that anybody can develop the same software or understand its internal functioning.

The open source initiative is a public benefit corporation that promotes the usage of open source software and they actually published a definition called the open source definition, or OSD. Now the OSD is a document that determines whether a software license can actually be labeled with the open source certification mark.

Now unlike Windows users, Linux users normally won't download and install applications from different application websites. Instead, each Linux distribution hosts its own software repository.

These repositories contain software packages specifically complied for your version of Linux and it's distro. For example, if you're using Ubuntu 12.04, the repositories you use will contain packages specifically compiled for Ubuntu 12.04 and not for the latest version like 18.04. Now, package managers automatically will download the appropriate packages from its configured software repository, then install it, and then configure it and set it up for you.

This is in contrast to installing software in a Windows or a Mac environment, where you have to click through a wizard or locate executable files on a certain website. When an update is released, your package manager will actually notice that and download the appropriate update as well.

On Windows or Mac, each application has its own updater to receive automatic updates. But, in Linux, the package manager handles updates for every piece of installed software as long as they were installed from within the software repository originally.

Linux has many different package formats. These packages are essentially the archives, contain the list of files that are needed for installation.

The package manager will open up the archive and then install the files into the location that the package specifies. This package manager will remain aware of all the files that belong to each of the packages. And packages can also contain scrips that will run when the package is installed or removed.

Some of our package formats within Linux are .deb, .rpm, and .tar files. Now a .deb file gets its name from Debian. And it's also used by Debian-based distros like Ubuntu. RPM originally stood for the Red Hat Package Manager and it was used by Red Hat and now it's also used by Fedora and Opensuse. A tar package, or TAR file, can be ending in a .tar, .tgz., or .tar.gz. And this is sometimes considered our universal package format.

These are used by distributions like Slackware and ArchLinux. Now, while your Linux distribution ships with its own repositories that are pre-configured, you can also add other repositories to your system if you want. You can then install software from those repositories and receive updates for that software as well.

For example, Ubuntu offers a wide variety of personal package archives, or PPAs. These contain software that is compiled by individual user and teams that have new features that aren't in the official distributions.

When it comes time to install new software on Linux, it's a little bit different than what you're used to on a Windows or a Mac machine.

So for example, on a Windows machine, you might be familiar going to something like the Windows store. And from here you can search and figure out whatever game it is you want or whatever program you want, and you'd be able to click on it and install it that way. Another way you'd install something is by going to the website of a software you want.

The GNU General Public License (GNU GPL or GPL) is a widely-used free software license, which guarantees end users the freedom to run, study, share and modify the software.

Just because a piece of software is open source, that doesn’t mean it is necessarily more popular. For example, Windows is a more popular desktop operating system than Linux, and Windows is not open source.



A Software Repository is basically a database of application installation packages and upgrade packages available for your Linux distro. When you install Linux, your Software Centre will come pre-configured with a default Repository.

The .exe file format is used by Windows systems, not Linux. The other three formats are used by different Linux distros (debian-based, Red Hat-based, and the universal installer format).

each binary much be compiled for the specific distribution being used. This is why it is easier to install software from your distro’s repository directly.

True, each distro comes with the default repositories, but additional repositories can be added with newer versions, such as alphas and betas.

Open-source software (OSS) is a type of computer software in which source code is released under a license in which the copyright holder grants users the rights to study, change, and distribute the software to anyone and for any purpose. Open-source software may be developed in a collaborative public manner.

The Kernel.

Linux, Windows and Mac all have a kernel. We've already discussed this in one of our previous lessons. The kernel is what directly controls hardware, and translates the commands from a given piece of software into something the hardware can actually understand and act upon.

It's going to manage hardware resources intelligently, such as the memory management, and various software and utilities that it uses. Now, due to the need for the kernel to consume the least amount of resources itself, it's going to be accessed through the command line. In order to do certain tasks on the command line, it's users need to be familiar with text based commands, what these commands do, and the rules in which the commands need to be run, also called the command syntax.

Simply put, the Linux Shell is the program that takes commands from the keyboard and gives them to the kernel, so that way it can be executed. In the old days it was only available as a text based command line interface.

But nowadays we have the desktop environment or GUI, that sits on top of the command line interface, and makes execution of the commands much easier. An example is when you click on a shortcut on the desktop. The shortcut may contain a predefined set of commands that you can use with the correct syntax to execute a program. So if I double click on the Chrome icon it might open up the Chrome web browser in incognito mode. On most Linux systems there's a program called Bash. Which stands for the Bourne Again Shell.

This acts as a shell program within the command line interface. Besides Bash there are other Shell programs that can be installed in a Linux system. These include ksh, the Korn shell, tcsh, the Tee See shell and zsh, the Zee shell. The Shell can be accessed by running a program known as a terminal emulator or, simply known as the terminal. The terminal is going to open up a window and let the user interact with that Shell. There are a bunch of different terminal emulators out there that you can use.

Now most Linux distributions are going to come with several different terminals. Things like the gnome-terminal, konsole, xterm, rxvt, kvt, nxterm, and eterm. While there are a number of different terminal emulators they all do basically the same thing. They give you access to a Shell session. Now there are a ton of commands that you can use from the command line environment that interact with that shell


Almost every Linux Distribution has pre-installed applications. Now, besides these applications that already are installed on your Linux Distribution, these distros also have package repositories with a large collection of other applications that you can install as packages. Now, a package refers to a compressed file archive, and it contains all the files that come with a certain application.

These files are usually stored in the package according to their relative installation path on the system. Now most packages also contain installation instructions for a specific distro. As well as a list of all the other packages that are prerequisites and required for installation of that software. These prerequisites are known as dependencies.

The main difference between the desktop environments of Windows/Mac OS and Linux is:
Windows/Mac OS each have an inseparable desktop environment while Linux desktop environments are modular

Linux allows the user to install a different GUI, if desired. There are several options, including Unity, KDE, Gnome, and XFCE.

The shell is a command interpreter in an operating system such as Unix or GNU/Linux, it is a program that executes other programs. It provides a computer user an interface to the Unix/GNU Linux system so that the user can run different commands or utilities/tools with some input data.

The terminal is the text-based command line program that is used in Linux to directly access the shell.

The default Shell in most Linux distributions is what's known as BASH, The Bourne Again Shell.

Each Linux user account can specify their own default Shell. So individual users can change their Shells if they like a different one better. Now, this can be done with an account management tool.

A command is essentially a sequence of characters in a line and you're going to end that line by pressing the enter key. Once you do that, that command is going to be evaluated by your shell. Now many commands are vaguely inspired by the English language and they form a part of dedicated command syntax language. Commands in this language must follow certain rules known as syntax for the shell you're using. Now if you use the wrong syntax, your shell is not going to be able to interpret them.

To interpret the command line, the shell first tries to divide the line into individual words. Just like in real life, words are separated by spaces. Now the first word on a command line is usually the actual command name. All of the other words on the line are parameters

And the shell allows us to automate things through the writing of shell scripts. Now, in the simplest terms, a shell script is a file containing a series of commands. The shell is going to read this file and carry out all of the commands as if you've been entering them directly on the command line themself.

To see all of the variables that are in the user's environment, you're going to use the printenv command, which stands for print environment. This will display all of those environmental variables right to your screen as you can see here.

Now, the shell is going to treat a number of characters in a special way on the command line, and these characters are known as meta-characters. The most common shell meta-characters is the blank or the space character, and this tells the shell to use separate arguments between those things.

The shell does not pass any blanks or any spaces to any command. Instead, the shell is going to use those blanks and spaces to separate and identify the individual arguments for that particular command.

Other shell meta-characters include things like the dollar sign, the star, the semi-colon, the greater-than symbol, the question mark, the ampersand and the pipe.

Now, quoting is the generic name given to the action of protecting shell meta-characters from being treated specially by the shell. A quoted blank does not separate arguments, while an unquoted blank will. A quoted semi-colon doesn't separate commands the way an unquoted semi-colon does. Quoting is used to prevent the shell from acting on and expanding these meta-characters. The quoting causes the shell to ignore that special meaning of the character, and instead the character gets treated like plain text. This way, it can be used as part of an argument, if it needs to be.

Quoting is also done either with double quotes, single quotes or backslash characters. Quotes and backslashes tell a shell which parts of the input to treat as ordinary plain text characters, and which to treat as special characters. The quoting delimits or identifies this string of characters, and the quoting mechanism is removed, and is not part of the string that's passed to the command. Only the characters being quoted are going to be passed into that command. This allows the shell to remove the quoting mechanism, before passing that delimitated text as an argument back into the command, and allows it to be understood.

echo hello; ls
both commands are separated echo hello will execute first and then ls, if you want to print hello; ls without putting double quote then you need to ignore semi-colon by putting backslash before semi-colon

Info Pages are like man pages, but they're much more detailed. They're divided into different nodes or pages that can be read with an info reader, which works much like a web browser. You can use p to go backwards or previous, you can click n to go next and go forward when you're inside of a info page. If you press q, this is going to exit the info page and bring you back to the command line.

The correct order is to wait for user input, the user enters a command to the computer, and then the computer executes the command.

A command is split into an array of strings named arguments. Argument 0 is (normally) the command name, argument 1, the first element following the command, and so on. An option is a documented type of argument modifying the behavior of a command, e.g. -l commonly means "long", -v verbose.

Since the beginning of Linux's development, it was designed as a multiuser system. This means that any number of users can simultaneously work on one single machine. These users can connect to the system using different terminals or network connections, while all their personal information and individual desktop configurations are stored separately. Among the users working on a machine, Linux is going to differentiate between two types of users.
We have a general user, which is known as a normal user, and then we have this super user or an administrator, we call this root.

Now, all Linux files and directories are located in a tree like structure. The topmost directory is referred to as the root of the file system. This is represented by a single slash.
/ -> slash
\ -> backslash


All though each Linux distribution has it's own way of doing certain things, all Linux developers recognize the need for some standardization in the layout of their directories. To address this need, the Filesystem Hierarchy Standard, or FHS was created, and it's used by most distributions in Linux. The FHS, makes an important distinction between shareable files, and unsharaeble files. When you have a sharable file, this will be reasonably shared between different computers.

Such as user data files, program binary files, and things like that. Unshareable files, are going to contain things that are system specific, thing like configuration files.

Hard links & soft link:
In Linux sometimes it's handy to refer to a single file using multiple names, rather than to create several copies of it. So users can create multiple links to a single file. These are known as hard links or symbolic links and both of these are created using the LN command or the link command. Let's first take a look at the hard link. The hard link is a duplicate directory entry and both the entries are going to point to the same file. Because they both work together by tying together this low level, file system data structures, hard links can only exist on a single file system.


Now the other type of link we have is a symbolic link. This is also known as a soft link or a sym link. It's a file that refers to another file by its name. This means the symbolic link is a file that holds another files name and when you tell that program to read or write from a symbolic link file, Linux is just going to redirect the access back to the original file. Because symbolic links work by file name references, they can actually cross file system boundaries.

wildcart
??
b??l -> ball, bowl, bpql

*
b*l -> bl, blaafdl, baal

[]
b[ao][lw]l -> bowl, ball, not bull


Globbing (*):

Globbing is the operation that expands a wildcard pattern into the list of pathnames matching the pattern. 
$ echo *.txt
a.txt b.txt


Case sensitivity is a function of the linux filesystem not of the operating system.

directories are just special files as far as the file system is concerned
I/O redirection

#!/bin/bash
you know it's bash shell

/usr/bin/xterm &
open xtern program in new windows
The ampersand (&) allows for multiple programs to be launched

variables that are passed to the script. These are also called parameters.

$0 -> name of the script
$1 -> 1st parameter of the script

Environment variables should be written in all uppercase, like $CURRENT_PWD.

The kernel is going to manage your memory, provide softwares with a way to access hard discs, doles out CPU time and resources, and preforms all other sorts of critical low level tasks.

The kernel is loaded early up in the boot process, and it's the kernel that's responsible for managing every other piece of software on a running Linux computer. Now, one of the many ways that the kernel imposes order on a potential chaotic set of software running on the computer, is to create a hierarchy.

Now, when it boots up, the kernel is going to run just one program. This is known as slash bin slash I N I T, or the init process. Now, the init process is then responsible for starting up all of the other basic programs that Linux needs to run. So, this would be programs that manage the logins, and the servers, and all the other things like that. Now, these programs, if launched directly by init, are then called its Children.

The Children of init can in turn launch their own children, and this happens when a user logs into Linux for example. The process that launched a given process is called the Parent. So, init is the ultimate Parent, with a lot of different Children underneath it, But each Child itself can also be a Parent. Now, the result of this is a tree like hierarchy of processes which are illustrated often in an upside down manner. This figure shows a small subset of the many process that run on a typical Linux installation. You'll see, just a few process are associated with a text mode login. Including the login tool, that manages the login, a couple of bash shells, and a few user programs. A working Linux system will likely have dozens or hundreds or running processes at any given time. Now, each process has it's own unique process ID, or PID, P I D, that's associated with it. These numbers begin with a one. So a nits process ID, is normally going to be one. Each process also has a Parent process ID, Or a PPID, and this is going to point back to its parent. So, if init was to launch something else, that thing would have a parent process ID of 'one' because init is what launched that child. Now, many of the tools from managing processes are going to rely on these numbers. Particularly the PID or process ID number.

Boot Process of Linux:


From Linux essential book:

Here Documents
Unlike the output redirections, the << operator acts in a different way compared to the other
operators. This input stream is also called here document. Here document represents the block of code
or text which can be redirected to the command or the interactive program. Different types of
scripting languages, like bash, sh and csh are able to take input directly from the command line,
without using any text files.
As can be seen in the example below, the operator is used to input data into the command, while the
word after doesn’t specify the file name. The word is interpreted as the delimiter of the input and it
will not be taken in consideration as content, therefore cat will not display it:
$ cat << hello
> hey
> ola
> hello
hey
ola

Combinations
The first combination that we will explore combines the redirection of the standard output and
standard error output to the same file. The &> and &>> operators are used, & representing the
combination of channel 1 and channel 2. The first operator will overwrite the existing contents of the
file and the second one will append or add the new information at the end of the file.

tar -zxvf foo.tar.gz -C /tmp/foo

Searching and Extracting Data from Files
*
Zero or more of the preceding pattern
+
One or more of the preceding pattern
?
Zero or one of the preceding pattern

All lines that end with at least one e.
$ grep -E "e+$" /usr/share/hunspell/en_US.dic
Anglicize
Anglophobe
Anthropocene
...

All lines that contain one of the following words: org , kay or tuna.
$ grep -E "org|kay|tuna" /usr/share/hunspell/en_US.dic
Borg/SM
George/MS
Tokay/M
fortunate/UY
...


Number of lines that start with one or no c followed by the string ati.
$ grep -cE "^c?ati" /usr/share/hunspell/en_US.dic
3

Defining the Interpreter
As we have demonstrated, we were able to simply enter text into a file, set it as an executable, and
run it. new_script is functionally still a normal text file, but we managed to have it be interpreted by
Bash. But what if it is written in Perl, or Python?
It is very good practice to specify the type of interpreter we want to use in the first line of a script.
This line is called a bang line or more commonly a shebang. It indicates to the system how we want
this file to be executed. Since we are learning Bash, we will be using the absolute path to our Bash
executable, once again using which:
$ which bash
/bin/bash
Our shebang starts with a hash sign and exclamation mark, followed by the absolute path above.
Let’s open new_script in a text editor and insert the shebang. Let’s also take the opportunity to
insert a comment into our script. Comments are ignored by the interpreter. They are written for the
benefit of other users wishing to understand your script.
#!/bin/bash
# This is our first comment. It is also good practice to document all scripts.
echo "Hello World!"

We will make one additional change to the filename as well: we will save this file as new_script.sh.
The file suffix ".sh" does not change the execution of the file in any way. It is a convention that bash
scripts be labelled with .sh or .bash in order to identify them more easily, the same way that Python
scripts are usually identified with the suffix .py.

#!/bin/bash
# This is our first comment. It is also good practice to comment all scripts.
username=Carol
echo "Hello $username!"
In this case, we have created a variable called username and we have assigned it the value of Carol.
Please note that there are no spaces between the variable name, the equals sign, or the assigned
value.
In the next line, we have used the echo command with the variable, but there is a dollar sign ($) in
front of the variable name. This is important, since it indicates to the shell that we wish to treat
username as a variable, and not just a normal word. By entering $username in our command, we
indicate that we want to perform a substitution, replacing the name of a variable with the value
assigned to that variable.

Executing the new script, we get this output:
$ ./new_script.sh
Hello Carol!
• Variable names must contain only alphanumeric characters or underscores, and are case
sensitive. Username and username will be treated as separate variables.
• Variable substitution may also have the format ${username}, with the addition of the { }. This is
also acceptable.
• Variables in Bash have an implicit type, and are considered strings. This means that performing
math functions in Bash is more complicated than it would be in other programming languages
such as C/C++:

One important thing to note in Bash is that double quotes and single quotes (') behave very
differently. Double quotes are considered “weak”, because they allow the interpreter to perform
substitution inside the quotes. Single quotes are considered “strong”, because they prevent any
substitution from occurring. Consider the following example:
#!/bin/bash
# This is our first comment. It is also good practice to comment all scripts.
username="Carol Smith"
echo "Hello $username!"
echo 'Hello $username!'

Returning the Number of Arguments
While variables such as $1 and $2 contain the value of positional arguments, another variable $#
contains the number of arguments.
#!/bin/bash
# This is our first comment. It is also good practice to comment all scripts.
username=$1
echo "Hello $username!"
echo "Number of arguments: $#."
$ ./new_script.sh Carol Dave
Hello Carol!
Number of arguments: 2.


there are two
arguments Carol and Dave, assigned to $1 and $2 respectively. If the second argument is missing, for
example, the shell will not throw an error. The value of $2 will simply be null, or nothing at all.

Exit code 
Exit codes are usually not seen by human users, but they are very useful when writing scripts.
Consider a script where we may be copying files to a remote network drive. There are many ways
that the copy task may have failed: for example our local machine might not be connected to the
network, or the remote drive might be full. By checking the exit code of our copy utility, we can
alert the user to problems when running the script.
It is very good practice to implement exit codes, so we will do this now. We have two paths in our
script, a success and a failure. Let’s use zero to indicate success, and one to indicate failure.

Handling Many Arguments
A user’s first instinct might be to use more positional variables such as $2, $3 and so on.
Unfortunately, we can’t anticipate the number of arguments that a user might choose to use. To
solve this issue, it will be helpful to introduce more built-in variables.

$ ./friendly2.sh Carol Dave Henry
Hello Carol Dave Henry!
There are two built-in variables which contain all arguments passed to the script: $@ and $*. For the
most part, both behave the same. Bash will parse the arguments, and separate each argument when it
encounters a space between them. In effect, the contents of $@ look like this:

0 - Carol
1 - Dave
2 - Henry

FOR loops
#!/bin/bash
FILES="/usr/sbin/accept /usr/sbin/pwck/ usr/sbin/chroot"
for file in $FILES
do
  ls -lh $file
done

#!/bin/bash

# a friendly script to greet users

if [ $# -eq 0 ]
then
echo "Please enter at least one user to greet."
exit 1
else
 echo -n "Hello $1"
 shift
 for username in $@
 do
 echo -n ", and $username"
 done
 echo "!"
 exit 0
 fi
Using -n with echo will suppress the newline after printing. This means that all echoes will print
to the same line, and the newline will be printed only after the !` on line 16.
• The shift command will remove the first element of our array, so that this:

$ ./friendly2.sh Carol
Hello Carol!
$ ./friendly2.sh Carol Dave Henry
Hello Carol, and Dave, and Henry!

When should I wrap quotes around a shell variable?
General rule: quote it if it can either be empty or contain spaces (or any whitespace really) or special characters (wildcards). Not quoting strings with spaces often leads to the shell breaking apart a single argument into many.

$? doesn't need quotes since it's a numeric value. Whether $URL needs it depends on what you allow in there and whether you still want an argument if it's empty.

I tend to always quote strings just out of habit since it's safer that way.


Using Regular Expressions to Perform Error Checking


Choosing an Operating System
What is an Operating System?
Linux-based Operating Systems
◦ Enterprise Linux
◦ Consumer Linux
• UNIX
• macOS
• Windows-based Operation Systems
◦ Windows Servers
◦ Windows Desktops


If you have access to a Linux command line at the moment, you can easily check the
version of the Linux kernel that you are running by reading the kernel release:
$ uname -r
4.15.0-1019-aws


Enterprise Grade Linux Distributions
◦ Red Hat Enterprise Linux
◦ CentOS
◦ SUSE Linux Enterprise Server
◦ Debian GNU/Linux
◦ Ubuntu LTS
• Consumer Grade Linux Distributions
◦ Fedora
◦ Ubuntu non-LTS
◦ openSUSE
• Experimental and Hacker Linux Distributions
◦ Arch
◦ Gentoo


We make use of the option -s in this case to return the OS name. We previously
used -r to return the kernel version number.
$ uname -s
Darwin

Understanding Computer Hardware
Motherboard

Logical Volume Manager (LVM) is a software capability that allows administrators
to combine individual disks and disk partitions and treat them as if they are a
single drive.

Memory and Memory Types

Using history -c will clear the current users’ history.

Globbing is a feature provided by the UNIX/Linux shell to represent multiple filenames by using special characters called wildcards with a single file name. A wildcard is essentially a symbol which may be used to substitute for one or more characters. The only answer choice with a wildcard is ls /etc/*.txt since the * is a wildcard character. Therefore, this is the only answer choice that is using globbing.

Using the <> redirection operator causes the specified file to be used for both standard input and standard output.

>name means 1>name -- redirect stdout to the file name
&>name is like 1>name 2>name -- redirect stdout and stderr to the file name (however name is only opened once; if you actually wrote 1>name 2>name it'd try to open name twice and perhaps malfunction).
So when you write git status 2&>1, it is therefore like git status 2 1>1 2>1 , i.e.

the first 2 actually gets passed as an argument to git status.
stdout is redirected to the file named 1 (not the file descriptor 1)
stderr is redirected to the file named 1
This command should actually create a file called 1 with the contents being the result of git status 2 -- i.e. the status of the file called 2 which is probably "Your branch is upto-date, nothing to commit, working directory clean", presuming you do not actually track a file called 2.

Archieve vs Compression:

The archive file is not compressed — it uses the same amount of disk space as all the individual files and directories combined. A compressed file is a collection of files and directories that are stored in one file and stored in a way that uses less disk space than all the individual files and directories combined.

Archiving means that you take 10 files and combine them into one file, with no difference in size. If you start with 10 100KB files and archive them, the resulting single file is 1000KB. On the other hand, if you compress those 10 files, you might find that the resulting files range from only a few kilobytes to close to the original size of 100KB, depending upon the original file type.

The most common programs for archiving files and directories are:
  • Tar
  • Zip

Popular compression utility programs, on Linux distributions, are:
  • gzip (frequently used);
  • bzip2 (less frequently used, yet produces smaller output file than gzip);
  • xz (most space-efficient tool, in Linux, so far)
  • zip (often used for decompressing data, that was compressed on other systems using zip, like Windows OS).

The following commands will create .tar archives  and compress them using the different methods that are available

For .tar archives
tar -c -f archive.tar $FILES_TO_ARCHIVE;

For .tar.bz2 archives
tar -c -j -f archive.tar.bz2 $FILES_TO_ARCHIVE;

For .tar.xz archives
tar -c -J -f archive.tar.xz $FILES_TO_ARCHIVE;

For .tar.gz and .tgz archives
tar -c -z -f archive.tar.gz $FILES_TO_ARCHIVE;


-z or --gzip instructs tar to filter the archive through gzip
-j or --bzip2 filters the archive through bzip2
-J or --xz filters the archive through xz
-f or --file=OUTPUT uses the archive file OUTPUT
-c or --create a new archive


umask command:

By default, on Linux systems, the default creation permissions are 666 for files and 777 for directories
so when you create a file and folder according to umask that you have set files and directory permission will get applied.

You can set umask command in the following files

vi /etc/profile.d/set-umask-for-all-users.sh
vi ~/.bashrc

so suppose if the umask is umask 022 that means defualt permission on file would be 666-022 = 644 and on the directory it would be 777-022 = 755.

Post a Comment

0 Comments