Let's take a look at command line basics, displaying a calendar of the current month. At the command line, there is a simple command that you can use to display a calendar of the current month, CAL. Let's take a look at command line basics, displaying the current date and time. At the command line, there is a simple command that you can use to display the current date and time. The date command. Let's take a look at command line basics, PWD. PWD is one of the simple commands that you need to learn. PWD stands for print working directory. This command gives us the location where we're currently located in the directory structure. Let's take a look at the manual page. PWD prints the name of the current working directory. There are a couple of options which you usually won't need to use. When we run PWD currently we see that I'm in my home directory. We can explore other places in the file system and use PWD to identify where we are. Let's use the cd command to go somewhere else. Let's try a few more. You'll see that wherever I go I can use PWD to find out the location where I am. Let's take a look at command line basics using exit to end a terminal session. When you are done at the command line it is good practice to explicitly terminate your bash terminal session. This is done using the command exit. After you execute this command your bash session ends. If you were connected to a remote server via SSH as I was here executing the exit command also terminates your SSH session. Let's take a look at command line basics using up and down arrow keys to navigate the command history. Let's begin by running a few simple commands. We'll start by running a command to see the current date and time. Next we'll print a simple message and next let's display a calendar of the current month. When working at the command line it is likely that you may want to run a command again. Bash provides a simple mechanism for navigating the commands that you have used recently the up arrow and the down arrow. Pressing the up arrow will instruct bash to recall the previous command from the list of recently used commands. Let's try pressing the up arrow as you can see the most recently used command now appears. Let's try pressing the up arrow again the next most recently used command which in this case was echo now appears. Let's try pressing the up arrow again the next most recently used command which in this case was date now appears. Just as we can use the up arrow to navigate backwards in time through the command history we can also use the down arrow to navigate forwards in time through the command history. Let's try pressing the down arrow doing so takes us forward one command to the echo command. Let's try pressing the down arrow again doing so again takes us forward one command this time to the call command and finally let's press the down arrow one more time doing so takes us back to an empty command line this corresponds with where we were before we first pressed the up arrow. Let's take a look at command line basics using left and right arrow keys to navigate within the current command. Let's begin with a command that displays a simple message. After entering this command what can I do if I want to change what I just typed? One option would be to delete what I typed using the backspace key and then type something else. However there is a more efficient option by using the left and right arrow keys I can navigate backwards and forwards within the command as I type. Let's take a look at command line basics, makedir. Makedir is used to create directories. After using makedir to create a directory we can use the ls command to verify that that directory was successfully created. Let's try again this time let's ask makedir to be verbose. By calling makedir with the dash of v flag makedir prints a message for each created directory we can of course still use ls to verify that the directory was created. Makedir can also be used to create multiple directories at one time. If you attempt to create a directory and a directory with that name already exists makedir will produce an error message. In the previous examples we created directories directly within the current working directory. It is also possible to use makedir to create directories elsewhere. This command creates a sub directory called edu inside the src directory. This behavior can be extremely useful however the advice that if the parent directory does not exist makedir will produce an error message and will fail to create the sub directory. This command failed because the examples directory doesn't exist. There's a solution. Let's take a look at the manual for makedir to find it. The dash p flag instructs makedir to make parent directories as needed. The dash p flag can also be used so that makedir doesn't complain if the directory already exists. Recall that we already created a directory called bin. As we saw earlier if we try to create a directory that already exists makedir will normally fail but by calling makedir with the dash p flag makedir will silently succeed. In all of the examples so far we've asked makedir to create directories within the current working directory. We can alternatively call makedir using absolute paths. Makedir is an essential Linux command that you will use frequently. You should practice using it to create directories in your current working directory and elsewhere. While you may never use the dash z or dash m flags you should learn to use the dash p flag. Let's take a look at command line basics using ls to list the contents of the current working directory. ls is one of the most commonly used commands. Let's take a look. If I run ls with no arguments it will display the contents of the current working directory. We can now see that this directory contains five other directories. Baz, foo, homework, canlm, and zork. Let's navigate to another directory and use ls to view its contents. We can now see that the current working directory, kenlm, contains a number of files and directories. Now let's use cd to change to a different directory. Now if I run ls with no parameters it's going to print the contents of the current working directory which is slash user. In conclusion invoking ls with no parameters will display the contents of the current working directory. Let's take a look at command line basics using ls to view text files. When working at the command line it is likely that you will commonly want to view the contents of various files you were working with. There are a number of programs you can use to accomplish this goal. One of the most widely used programs for viewing text files is ls. Like many programs you will encounter the name ls is a play on words. ls was developed as a more fully featured replacement for an earlier text viewing application whose name is more. ls can be used to view the contents of text files. Notice that unlike on windows on linux file extensions such as .md, .txt, .zip, and .py are not meaningful. Even though readme.md has an extension it is still a plain text file and can be opened by ls. ls can be navigated page up and page down using various key shortcuts including space to page forward and b to move backwards. To exit ls press q. ls has lots of options. One helpful option is the display of line numbers. This option can be enabled with the dash n flag. Notice that if necessary ls will wrap lines if the line is too wide to be viewed on the current display. Line 10 in this file begins here but continues through here. This line is marked as line 10 throughout. Let's take a look at some other files. Here is George Washington's inaugural address and here is Johnson's and here is Obama's. The text files don't have to be in English. ls is capable of displaying text in other languages. For example here's a swadish list for russian. ls can also open more than one file at a time. When using ls to view multiple files the command colon n is used to navigate to the next file and the command colon p is used to navigate to the previous file. ls is one of the most commonly used programs you will encounter when using the command line. It is well worth your while to learn how to use it and to learn some of its more commonly used shortcuts. Let's take a look at command line basics using ls to list the contents of a non-current directory using a relative path. Let's take a look. If I run ls with no arguments it will display the contents of the current working directory. ls also accepts an argument. When I provide an argument to ls it will list the contents of that directory rather than the current directory. So here we see that there are a number of files and directories within the kenlm directory. If we want to see the contents of one of these subdirectories one approach would be to use cd to navigate to that sub directory and then use ls to view its contents. However, there is a faster way. Let's go back to the home directory and try the faster way. Rather than calling cd and then calling ls we can directly call ls providing the directory as an argument. In the above invocation of ls we provided a relative path. kenlm slash include as an argument to ls. After doing so ls listed the contents of the specified directory. We can also call ls using other relative paths including those that make use of dot and dot dot. Recall that dot dot refers to the parent of the current working directory. In this case the parent of the current working directory is kenlm. Let's try another. In this case dot dot refers to the parent of the current working directory kenlm and dot dot slash util refers to the util directory that is within the kenlm directory. Let's take a look at kenlm blind basics using ls to list the contents of a non-current directory using an absolute path. Let's take a look. If I run ls with no arguments it will display the contents of the current working directory. ls also accepts an argument. When I provide an argument to ls it will list the contents of that directory rather than the current directory. So here we see that there are a number of files and directories within the kenlm directory. If we want to see the contents of one of these subdirectories one approach would be to use cd to navigate to that sub directory and then use ls to view its contents. However, there is a faster way. Let's go back to the home directory and try the faster way. Rather than calling cd and then calling ls we can call ls directly providing the directory as an argument. In the above invocation of ls we provided an absolute path slash home slash lane s slash kenlm slash include as an argument to ls. Let's take a look at kenlm blind basics identifying and understanding symbolic links. Let's take a look. So far everything looks normal. User bin python is a file. More specifically we can use this file to invoke the python interpreter. Let's look more closely at this file. In the above invocation of ls we used the dash l flag to direct ls to use the long listing format. Notice that in this long listing there is an arrow. The arrow means that user bin python is not a regular file. Instead it is a symbolic link that points to another file. In this case user bin python points to the file python 2.7. We can confirm that user bin python is a symbolic link by invoking the program file. File can be used to determine the type of a file. This confirms that user bin python is a symbolic link. Let's take a look at user bin python 2.7. We see now that user bin python 2.7 is an actual executable file. So when we call python the system redirects our call so that python 2.7 is called instead. Now let's look at a slightly more complex example. We see that user bin emacs is a symbolic link to etsy alternatives emacs. Okay that's a little strange. Normally executable files are located in user bin not in etsy. Let's take a look at etsy alternatives emacs. We see now that we have another symbolic link. Etsy alternatives emacs is actually a symbolic link to user bin emacs 24x. So when we run user bin emacs the system redirects our call twice. First to etsy alternatives emacs and then finally to user bin emacs 24x. In conclusion symbolic links like shortcuts in windows and aliases in the mac os provide a mechanism for referring to another file. Symbolic links can be easily identified by using ls with the dash l flag and also by using the file command. Let's take a look at command line basics using ls to view hidden files. If I run ls with no arguments it will display the contents of the current working directory. We can see now that this directory contains five other directories bazz foo homework canlm and zork. However this directory actually contains a number of other hidden files. By default ls ignores any file whose name begins with dot. We can force ls to display these otherwise hidden files by using the dash a flag. As you can see when we invoke ls with the dash a flag in the home directory a number of hidden files can be seen. Let's take a look at command line basics using ls with additional options. If I run ls with no arguments it will display the contents of the current working directory. We can now see that this directory contains five other directories bazz foo homework canlm and zork. There are a number of additional options we can use to configure ls. One commonly used option is the dash l flag. The dash l flag causes ls to use a long listing format. Using the long listing format shows us additional information for each file. This information includes the file type, file permissions, the owner, and group associated with the file, the file size, the modification date, and the file name. The file sizes reported by ls dash l aren't particularly readable. By using the dash h flag ls will report file sizes in a more human readable format. Notice that when we specify multiple flags we can either list each flag separately or list the flags together. The above two commands are equivalent. There are a number of other useful flags in ls which can be found by reading through the ls man page. Let's take a look at command line basics using rm to delete files and directories. Let's take a look. The rm command can be used to delete files. Let's use rm to delete the file license in the current directory. After using rm the specified file has been deleted. Note that by default rm does not prompt you for confirmation. It simply deletes the file. If you use the dash i flag rm will prompt you for confirmation before it begins deleting files. Let's use rm to delete a file in the food directory. Because we specified the dash i flag rm prompted us for confirmation before it deleted the file. Let's see what happens if I say no. rm did not delete the file. Let's try again and this time we'll say yes to the confirmation. We can also use the dash v flag to force rm to explain what is being done. Let's try removing another file this time using the dash v flag. By invoking rm with the dash v flag rm printed a message confirming that the file was deleted. We can also invoke rm with an absolute path. Now let's try to use rm to delete the food directory. What just happened? We called rm providing foo as the argument for what to delete and rm failed to delete the directory. Let's look at the man page for rm to see if we can figure out what just happened. By default rm does not remove directories. To force rm to remove a directory and any contents it might have we can invoke rm with the dash r flag. In many cases especially when you are new to the command line it is advisable to use the dash i or dash capital i flag when invoking rm recursively. Here we'll use the dash capital i flag. We will also use the dash v flag so that rm will confirm what files it deletes. Let's take a look at command line basics using cd to navigate to a directory using a relative path. Let's take a look at where we are the current working directory. Now let's use ls to view the contents of the current working directory. We can use the bash built-in command cd to change directories. To use cd we provide the name of the directory into which we wish to navigate. Let's use pwd to verify that we've changed directories. Notice that in the above invocation of cd we only specified the name bas. We did not type slash home slash lane s slash bas. This style of referring to a directory by only part of its name shows the use of cd using a relative path. The absolute path in this case would be slash home slash lane s slash bas. The relative path that we used was simply bas. Because we were located in the directory slash home slash lane s at the time we invoked cd the part of the path corresponding to the current directory can be omitted through the use of a relative path. There are two special relative path components dot and dot dot. Dot refers to the current working directory. Dot dot refers to the parent of the current working directory. Let's recall where we are. The current working directory bas is located within the directory lane s. We could refer to the parent by its absolute path slash home slash lane s or we could refer to it as dot dot. Let's use cd and dot dot to navigate to the parent of the current working directory. Let's practice some more. What just happened? We told cd to navigate to dot. Dot is another name for the current working directory. Consequently we stayed in the same current working directory. In other words we didn't go anywhere. What just happened? We were in slash home slash lane s slash foo. We used dot dot twice from slash home slash lane s slash foo. Dot dot would refer to the parent directory slash home slash lane s but we used the relative path dot dot slash dot dot. If dot dot is the parent then dot dot slash dot dot is the parent of the parent. In this case the parent is slash home slash lane s and its parent is slash home. So invoking cd dot dot slash dot dot from home lane s foo takes us to home. Notice what we just did. We used a relative path lane s slash ken lm to navigate from slash home to slash home slash lane s slash ken lm. We could have called cd twice but this way was faster. Let's go back and see the slower way. We used cd here to navigate one directory at a time. Just as we can use ls to look into subdirectories we can also use cd to navigate directly into subdirectories. Let's take a look at command line concepts. Understanding complex relative paths using dot and dot dot. Now let's take a look at one example of a relative path that uses both dot and dot dot multiple times. Now let's go back and take a closer look at this complex relative path. We'll begin by visualizing the directory tree in which we're operating. The directory tree looks like this. For convenience in keeping track of subdirectories I have color coded the subdirectories we'll be discussing. The current working directory is slash home slash lane s slash ken lm slash util slash stream. Notice that I've color coded the names in this path to match the corresponding subdirectories in the directory tree. Now let's look at our complex relative path. Again notice that I've color coded the names in this relative path to match the corresponding subdirectories in the directory tree. Dot dot which you see here in red refers to the parent of the current working directory. In our case the parent is the util directory which is also drawn in red here in the tree. Double conversion is a subdirectory of util. Thus given that stream is the current working directory dot dot slash double conversion refers to the subdirectory colored in gold in the tree slash home slash lane s slash ken lm slash util slash double conversion. Dot is another name for the current directory. This means that dot dot slash double conversion slash dot means exactly the same thing as dot dot slash double conversion. The parent of double conversion is util thus dot dot slash double conversion slash dot slash dot dot refers to the red node in the tree whose absolute path is slash home slash lane ls lane s slash ken lm slash util. The parent of util is ken lm so dot dot slash double conversion slash dot slash dot dot slash dot dot refers to slash home slash lane s slash ken lm which we see colored orange in the tree lm which you see in blue is a subdirectory of ken lm so dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm refers to slash home slash lane s slash ken lm slash lm and because dot which we see here in blue refers to the current directory dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm slash dot refers also to lm. Rappers is a subdirectory of lm so dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm slash dot slash wrappers refers to slash home slash lane s slash ken lm slash lm slash wrappers dot dot which we see here in blue refers to the parent of the current working directory so this path refers to lm and finally builder is a subdirectory of lm and so dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm slash dot slash wrappers slash dot dot slash builder refers to home lane s ken lm lm builder let's take a look at command line concepts understanding complex relative paths using dot and dot dot now let's take a look at one example of a relative path that uses both dot and dot dot multiple times note that the following example is intentionally complex deliberately made convoluted to illustrate how dot and dot dot can be used within other paths maybe a while before you encounter an example that says complex in real life but it is good to understand what's going on now let's go back and unpack that messy path dot dot refers to the parent of the current working directory in our case the parent is the utl directory double conversion is a subdirectory of utl its absolute path is slash home slash lane s slash ken lm slash utl slash double conversion dot is another name for the current directory that means dot dot slash double conversion slash dot means exactly the same thing as dot dot slash double conversion the parent of double conversion is utl the parent of utl is ken lm so dot dot slash double conversion slash dot slash dot dot slash dot dot refers to home lane s ken lm lm is a subdirectory of ken lm so dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm refers to home lane s ken lm lm and because dot refers to the current directory dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm slash dot is the same as dot dot slash double conversion slash dot slash dot dot slash dot dot slash lm Also referring to HOME, LANE, S, KEN, LM, LM. Rappers is a subdirectory of LM, so dot dot slash double conversion slash dot slash dot dot dot slash dot dot slash LM slash dot slash wrappers refers to HOME, LANE, S, KEN, LM, LM, wrappers. Dot dot refers to the parent of the current working directory, so dot dot slash double conversion slash dot slash dot dot slash dot slash LM slash dot slash wrappers slash dot dot refers to HOME, LANE, S, KEN, LM, LM. And finally, builder is a subdirectory of LM, so dot dot slash double conversion slash dot slash dot dot slash dot dot slash LM slash dot slash wrappers slash dot dot slash builder refers to HOME, LANE, S, KEN, LM, LM, builder. Let's take a look at command line basics using CD to navigate to a directory using an absolute path. Let's take a look at where we are, the current working directory. Now, let's use LS to view the contents of the current working directory. We can use the bash built-in command CD to change directories. To use CD, we provide the name of the directory into which we wish to navigate. Let's use PWD to verify that we have changed directories. Notice that in the above invocation of CD, we specified the full path slash HOME slash LANE, S slash BAS. This style of referring to a directory by its full name shows the use of CD using an absolute path. Let's navigate somewhere else. In the above command, the absolute path that we used was slash user slash local. Notice that an absolute path always begins with a slash. The layout of the Linux directory structure is a tree. There is a single unique root of the file system tree. The notation slash represents the root of the file system. All directories have slash as their ultimate ancestor. Every absolute path begins with slash. Every absolute path specifies a sequence of contains relations beginning with the current file or directory and ending at the root of the file system. Let's look at another absolute path. We used CD to navigate to slash user slash share slash man slash user slash share slash man is an absolute path. Let's decompose this absolute path to understand it better. Man is a directory. We can use ls to view its contents. The parent directory of man is share. In other words, the share directory contains the man directory. Let's verify this by using ls to view the share directory. The share directory contains the man directory. The parent directory of share is user. In other words, the user directory contains the share directory. Let's verify this by using ls to view the user directory. The user directory contains the share directory. And finally, the parent of user is root. In other words, the root directory contains the user directory. Let's verify this by using ls to view the contents of the root directory. The root directory contains the user directory. Let's take a look at command line basics using CD without options to navigate to the home directory. Let's take a look at where we are, the current working directory. We are currently located in the home directory. Each user has a unique home directory. The path of the home directory can also be observed by printing the value stored in the home environment variable. Now let's navigate to a different directory. Let's use pwd to verify that we have changed directories. Now let's call cd again. This time we're going to call cd without providing a directory path. What just happened? Normally when we call cd, we provide a relative or absolute path to a directory, and cd then takes us to that specified directory. In this case, we didn't provide a directory. So where did we go? Let's use pwd and the documentation for cd to figure out what just happened. By running pwd, we can see that cd took us to the home directory. Each user's home directory is different. My home directory is slash home slash lane s. We invoked cd without any options. Doing so took us to the home directory. Let's take a look at the documentation for cd to find out why. Recall that cd is a bash built-in command. Documentation for bash built-in commands can be accessed using the help command. The documentation states that cd is used to change the shell working directory. Specifically, cd is used to change the current directory to dir. Normally dir is provided by the user. However, the square brackets in the usage means that providing this value is optional. In other words, users are allowed to call cd without providing a directory. When this happens, cd falls back to a default value for dir. The default dir is the value of the home shell variable. As we saw earlier, the home shell variable stores the value of the user's home directory. Thus, calling cd without any options takes us to the home directory. Let's take a look at command line basics using mv to move files. The mv command can be used to move files. mv takes two mandatory arguments. When moving a single file, the first argument is the path to the file you want to move. The second argument is the path where you want the file moved to. In the above invocation of mv, I moved the license file from the knlm directory. The result is a file in my current working directory called abc. Another way to invoke mv is by giving mv a destination directory. For example, let's say we wanted to move the file abc from the current directory into the directory baz. To do so, we call mv using abc as the source file and baz as the destination directory. As you can see, after the above invocation of mv, the baz directory now contains abc. Usually, it is not necessary to supply any options to mv. However, if you want confirmation of what mv is doing, invoking mv with the dash v flag will explain what is being done. By calling mv with the dash v flag, mv confirms that it moved the file baz slash abc to knlm slash license. mv can also be used to move multiple files to a common destination directory. Let's use touch to create several empty files. Now, let's use mv to move all four of these files into the foo directory. The dot dot dot notation here indicates that mv allows us to specify multiple source files. As you can see, all four files have been moved to the foo directory. Let's take a look at command line basics. Using cd to navigate using tilde. Let's take a look at where we are, the current working directory. We are currently located in the home directory. Each user has a unique home directory. The path of the home directory can also be observed by printing the value stored in the home environment variable. Let's look and see what other users have home directories on this system. Navigating to or referring to a user's home directory is so common, there is a special shorthand syntax for doing so. Tilde. The notation tilde username refers to the home directory for username. For example, let's try navigating to the home directory for the user Brice2. We can use pwd to verify that we have successfully navigated to the home directory for the user Brice2. Let's try again with another user. I can also use this notation to refer to my own home directory. My username on this system is laness, so I can refer to my own home directory using tilde laness. It turns out that referring to your own home directory is even more common than referring to someone else's home directory. Consequently, there's an even shorter shorthand notation for referring to your own home directory, tilde. When used as a directory, a bare tilde without an accompanying username refers to the user's own home directory. You can also use this notation to refer to files and directories within your home directory. Notice that in the above invocation of cd, tilde slash canlm refers to the canlm directory that is in my home directory. In conclusion, the notation tilde username can be used to refer to the home directory associated with the specified username. For example, the notation tilde can be used to refer to your own home directory. Let's take a look at command line basics. Using lan to create symbolic links. The lan command, when used with the dash s flag, can be used to create symbolic links. Symbolic links, like shortcuts and windows and aliases in the macOS, provide a mechanism for referring to another file. In its first form, lan takes two mandatory arguments. The first argument is the path to a file that already exists. The second argument is the path where you want the new symbolic link created. In the above invocation of lan, I created a new symbolic link called abc that points to the license file in the canlm directory. abc is not a copy of license. It is a symbolic link to license. We can verify this by using the file command to ascertain the type of abc. We can also verify this by calling ls with the dash l flag. The long file format shows that abc is a link and that it points to canlm slash license. Now, let's take a look at the second form of invoking lan. In the second form, we only provide the path to the file that already exists. When we invoke lan in this manner, providing only a single file as an argument, lan creates a symbolic link to that file with the same name. In the current working directory. The third form of invoking lan is more advanced and can involve some additional subtleties, so we'll cover that in a separate video. Let's take a look at command line concepts. Using lan to create symbolic links in another directory. The lan command, when used with the dash s flag, can be used to create symbolic links. Symbolic links like shortcuts and windows and aliases in the macOS provide a mechanism for referring to another file. We're going to look at the third form of invoking lan. The first argument is the path to a file that already exists. The second argument is a directory in which you want the new symbolic link created. Something's not right here. The symbolic link is broken. Let's remove the broken link and try again. In the above invocation of lan, we attempted to create a symbolic link in another directory. When we provided the first argument, it was a relative link. This use of a relative link in the third form of lan is the cause of our broken link. There are a couple of possible solutions. The first solution is simply to use an absolute path instead of a relative path. Now, let's remove the symbolic link and figure out how to make a symbolic link in another directory using a relative path. Let's try to figure out why this link is broken. Within the BAS directory, license is a symbolic link pointing to canlm slash license. Canlm slash license is a relative path. Within the BAS directory, what does the relative path canlm slash license mean? Well, it would mean that there should be a directory, a subdirectory called canlm within the current directory, BAS. And within that subdirectory, there should be a file called license. There's the problem. Is there a canlm directory inside BAS? No, there's not. We just ran ls from within BAS and there is no canlm subdirectory. The broken link is looking for something that doesn't exist. That's why it's broken. We can confirm this by using read link to determine the absolute path that the symbolic link is attempting to point to. This confirms that the symbolic link is looking for a file that doesn't exist. So what would happen if the missing file were to be created? Let's find out. To do so, let's create a directory called canlm within the BAS directory. Now, let's use the touch command to create an empty file called license within our newly created canlm directory. Finally, let's see if our symbolic link is still broken. The symbolic link license in the BAS directory is no longer broken. Why? Because the file it was looking for for now exists. So, our link is no longer broken, but it's pointing to the wrong file. Specifically, it's pointing to the empty file we just created. That's not what we want at all. Let's remove these dummy files and try again. In order to use the third form of ln to correctly create a link, it's helpful to realize two things. First, ln interprets this first argument as a string. And second, if that string represents a relative path, the file system will interpret that relative path relative to the directory in which the symbolic link is to be created. Recall from above that our broken symbolic link was looking for a canlm directory within the BAS directory. So, let's think about things relative to the BAS directory. From within the BAS directory, what relative path can we use to refer to slash home slash lanes slash canlm slash license? Well, canlm and BAS are both in the home directory. In other words, they have a common parent. We can refer to the parent of the current working directory as dot dot. So, from the bar from the BAS directory, dot dot slash canlm refers to slash home slash lanes slash canlm. And dot dot slash canlm slash license refers to the file that we want. Armed with that information, let's try making that symbolic link again. It worked. We can use read link to confirm that the symbolic link is now pointing to the correct file. We have succeeded in creating a symbolic link in another directory using a relative path. To do so, we had to think about the relative path from the perspective of the directory in which the link is being created. It turns out that we can ask ln to do this change of perspective for us. When invoked with the dash r flag, ln will create the symbolic link relative to the link location. Let's remove the existing link and give this a try. By running ls dash l, we can observe that when the dash r flag was passed to ln, ln correctly translated the relative path we provided canlm slash license into a relative path that is correct in the context of the BAS directory. Dot dot slash canlm slash license. Calling read link confirms that the symbolic link in the BAS directory is indeed pointing to the correct file slash home slash lane s slash canlm slash license. Let's take a look at command line concepts using file to determine a file's type. Let's take a look. The file command accepts a file name as an argument. The command attempts to determine the type of the specified file. Using file, we observe that user local is a directory. Great. That's exactly what we would expect. Let's look at some more files and use the file command to determine their respective types. The above invocation of file tells us that mail q dot one dot gz is comprised of data that was compressed using gzip. Here we see that license is a plain text file encoded using ASCII. Let's take a look at command line basics using cp to copy a single file. The cp command can be used to copy files. cp takes two mandatory arguments. When copying a single file, the first argument is the path to the file you want to copy. The second argument is the path where you want the file copied to. In the above invocation of cp, I copied the license file from the knlm directory. The resulting copy is a file in my current working directory called abc. abc is a copy of license. We can use the diff command to verify that the two files are identical. Another way to invoke cp is by giving cp a destination directory. For example, let's say we wanted to copy the file abc into the directory baz. To do so we can call cp using abc as the source file and baz as the destination directory. As you can see, after the above invocation of cp, the baz directory now contains a copy of abc command line basics using cp to copy a single directory. The cp command can be used to copy files and directories. Let's say we want to make a copy of the knlm directory. The first thing we might try is a simple invocation of cp. What just happened? We tried making a copy of the knlm directory called wxyz. If we run ls, we see that our attempts to copy the knlm directory failed. By default, cp will not copy directories. To get cp to copy a directory, we must add an additional option when invoking cp. If cp is invoked with the dash r flag, it will copy directories, including their contents. As you can see, after the above invocation of cp with dash r, the wxyz directory now exists. And is a copy of the knlm directory. Let's take a look at command line basics using echo to print simple strings. Echo is typically used to display a single line of text. Here, the message was hello world. Echo prints this message to standard output. Notice that the message was not printed until after the enter key was pressed. While it may not always be necessary to enclose the message within quotation marks, doing so is good practice. Let's use echo to display another simple message. As you can see, the message we gave to echo is printed to standard output. It is possible to redirect the standard output stream to a file or use a pipe to send it as input to another process. In this case, we aren't doing either of those things. As a result, we see the default behavior where messages sent to standard output are displayed on the terminal. Let's use echo to display some more simple messages. Let's take a look at command line basics using echo to display multi-line messages. Echo is typically used to display a single line of text. However, echo can be used to print messages that span multiple lines of text. Let's start by using echo to print a simple message consisting of a single line of text. Let's try again, but this time we're going to make a mistake. Notice what happened. We typed the opening quotation mark, then we typed the message, then hit the enter key. Instead of printing our message, we see something that looks like a greater than sign. Notice that we forgot to type the closing quotation mark. Let's add the closing quotation mark, then hit enter again. Notice what just happened. Our message was printed, but in addition, an extra blank line was printed. Do you see the extra blank line? It's there. Let's try another example. In our next example, the second line will contain more of the message. Here, it should be clear that echo printed a message that consisted of two lines of text. When entering a multi-line message in this manner, we're not limited to just two lines. The contents of our message will continue until we enter a closing quotation mark. After we enter the closing quotation mark and then press the enter key, the entire multi-line message is printed to standard output. Let's take a look at command line basics using echo to display messages with escape sequences. Echo is typically used to display plain text messages. However, echo can be used to print messages that include special characters. Let's start by using echo to print a message consisting of a single line of text. Now, let's try again. But this time, we're going to include something new. And to do so, we're going to take a look at the documentation for echo. The documentation for most commands is found by accessing the command's manual pages using the command man. But echo is special. Echo is a bash built-in command. The documentation for bash built-in commands is obtained using the command help. By reading the bash help page, we can observe that echo is capable of reading a number of backslash escaped characters. A backslash escaped character is just a character that is immediately preceded by a backslash character. Of the backslash escape sequences you see here, it's likely that you'll only ever need to use one or two of them. The two that we'll examine here are the escape sequences for new line backslash n and for horizontal tab backslash t. Now, let's try printing our message again. However, this time, instead of placing a space between the two sentences, we're going to try to place a tab character between the two sentences. Recall that the escape sequence for a horizontal tab character is backslash t. What just happened? The escape sequence backslash t represents a horizontal tab character. We wanted echo to replace backslash t with an actual tab character. Let's take another look at the help page for echo. In the above invocation of echo, we did not use any options. Notice that echo has an option dash e that does exactly what we want. If echo is called with the dash e option, then echo will replace the escape sequence with its corresponding literal character. Let's try again, this time using the dash e flag. It looks like there is a space character between the sentences, but it's actually a tab. To see the difference more clearly, let's try again, but this time, let's add another tab. Now we can see a difference. Let's try again with three tabs. Compare that to the same thing, but with three spaces between the sentences. Now let's try again using the escape sequence for a new line, backslash n. Whoops, I did backslash t again. Let's try again with backslash n. Now let's add another new line. And now again with three new line characters. By using escape sequences, we can use echo to print a multi-line message even while we enter the command using a single line. Let's take a look at command line basics, grep. The grep command finds text patterns in files. It prints out all the lines containing a matching pattern. Grep can match very complex patterns with the use of regular expressions. Let's take a look at grep's man page. Grep searches the named input file or files or standard input if no file is named. Let's use grep to find all the files that have the word zip in the name in the directories bin and userbin. To do this, we first use ls to list the files in those directories. Then pipe the result to grep to search for the pattern zip. A list of file names containing zip is displayed. Grep pattern matching is case sensitive by default. Let's try to list the file names in bin and userbin that contain the word zip in uppercase. We get zero matches. To allow grep to ignore case when matching the pattern, we can use the dash i flag with grep. The dash i flag specifies that grep should ignore case distinctions. If instead of a list of lines that match the pattern, we want a list of lines that do not match the pattern, we can use the dash v flag with grep to invert the match. We now get a list of file names in bin and userbin that do not contain the word zip. To output the number of matches instead of the actual matching lines, we can use the dash c option with grep. Here we observe that there were 19 items which matched the pattern zip. Let's take a look at command line basics, head and tail. Head and tail are commands that print the first and last parts of a file respectively. By default, head prints the first 10 lines of a file and tail prints the last 10 lines. Let's take a look at their man pages. By default, head prints the first 10 lines of a file to standard output. This can be changed using the dash n flag to specify the number of lines instead of assuming the default of 10. Tail behaves very similarly. Let's create a text file and use head and tail to examine its first and last lines. We can observe that foo.txt now contains a sorted list of the files in userbin. We can use head to display the first 10 lines of the file. We can use tail to display the last 10 lines of the file. To view a different number of lines, say the first or last 5 lines of a file, we can use the dash n option with head and with tail. These are the first 5 lines of foo.txt and these are the last 5 lines of foo.txt. Head and tail can also be used in a pipeline. Let's list the last 7 items of the contents of the directory userbin. To do this, we will use ls to list the contents, ls to sort them, and pipe the output to tail with the appropriate option, listing the last 7 items in the directory userbin. Let's take a look at command line basics, echo. Let's take a look at echo's man page. The command echo accepts 0 or more strings provided by the user and prints those strings to standard output. If the standard output of echo has not been otherwise redirected, then those strings will be displayed to the screen separated by spaces. As we can see, echo printed the string hello. If we provide more than one string to echo, it will print each string and will put a single space between each pair of strings. Here's the first string followed by a space followed by the next string. If we provide more than one space between each string, echo ignores the extra spaces and only a single space is printed. If we want to print a string preserving all spacing and other formatting, we can enclose the string in quotation marks. When we do this, echo will treat everything within the quotation marks as a single string. Let's take a look at command line basics, wildcard expansion. Let's try to use echo to display a single line of text. See that the line we typed is displayed just as we typed it. Extra white space in the arguments of echo will be removed in the output. Here we typed extra spaces, but the output in those locations only included a single space. When there are special characters in the line of text, we see something else. To check this, let's cd to a different directory and look at the contents of that directory using ls. Now let's try to use echo with a wildcard character as the argument. The star or asterisk here is treated as a wildcard character. Notice echo did not display the character star itself. Instead, it displayed a listing of the files in the current working directory. Notice that this output of echo is the same in terms of the files listed as that we saw with ls. This is because before the echo command is executed, the shell itself has expanded the wildcard character into a list of file names in the current working directory. It is very important to understand how the shell carries out expansion for different kinds of characters. Echo is a good way to observe the effects of different special characters and their respective expansions before we use these special characters with other commands. Let's take a look at command line basics. Path name expansion. Bash is capable of performing certain types of expansions. Let's try to use ls to see how path name expansion works. In this command, the wildcard character has been expanded. The result is a listing of all file names in the specified directory whose file names end in .h. Let's try another example. Here, the wildcard expanded again, resulting in a list of all files in the user bin directory whose file names begin with the character's py. Let's take a look at command line basics. Tilda expansion. Tilda expansion is a special expansion involving the Tilda character. When the Tilda character is used at the beginning of a username, it expands into the name of the home directory for that user. Let's try to use echo to see how Tilda expansion works. Here, we see an expansion resulting in the full path to this user's home directory. If no username is supplied after the Tilda character, the result expands into the home directory of the current user, which in this case is lane s. We observe here that the Tilda character has been expanded into the home directory of the current user. Let's take a look at command line basics. Arithmetic expansion. Arithmetic expansion allows the shell to perform calculations before passing the results to a command as arguments. Arithmetic expansion uses the dollar sign character and double parentheses around an arithmetic expression. Let's use echo to see how arithmetic expansion works. See that this arithmetic expression, 7 plus 3, has been calculated with the result 10. Note that arithmetic expansion only supports integers or whole numbers. The expansion would result in an error if decimals are present in the expression. See that bash has displayed an error message for the decimal, invalid arithmetic operator indicating that the decimal point caused the error. Arithmetic expansion supports addition, subtraction, multiplication, integer division, modulo, or remainder, and exponentiation. Arithmetic expansion may also be used alongside text. Let's try to use echo to see how the integer division and modulo operators work. If the result of the division is not an integer, integer division will cause the result to be truncated to the integer part and will not be rounded. So, using integer division, 7 divided by 2 is 3 with a remainder of 1. The 1 was calculated using the modulo operator. The 3 was calculated using integer division. Now, let's use echo to observe how the exponentiation operator works. This calculation has raised 5 to the exponent of 2, or 5 squared, which is 25. Inside the double parentheses of an arithmetic expression, it is possible to nest another arithmetic expression. Here we have nested an arithmetic expression 1 plus 1 within a larger expression 5 to the power of 1 plus 1. Here, the inner expression calculates 1 plus 1, resulting in a value of 2. The outer expression performs the exponentiation 5 to the power of 2, resulting in 25. We can also use single parentheses to group the order of operations without actually causing a second expansion of the arithmetic expression to occur. This will calculate the same result of 25 using only one arithmetic expansion instead of 2. Let's take a look at command line basics. Brace expansion. Brace expansion creates multiple text strings from a pattern. The pattern takes the form of an unchanging preamble, followed by a variable expansion component, followed by an unchanging post script. The varying part of the pattern is enclosed by a pair of curly braces. The constant part before the opening brace is called a preamble, and the constant part trailing after the closing brace is a post script. Let's try to use echo to see how brace expansion works. This pattern has expanded into three text strings. Each string has the same preamble at the beginning and the same post script at the end. The middle part of each string varies, and is present in the same order as specified in the pattern. If we had changed the order in the pattern, the order would be correspondingly different in the created strings. Both the preamble and the post script are optional. Here, we expand a pattern with a preamble, but no post script. Here, we expand a pattern with a post script, but no preamble. And finally, we expand a pattern with no preamble and with no post script. Now, let's try to use brace expansion with a preamble that includes white space. Here, bash considers i, love, and Brahms Beethoven Bach to be separate tokens. As a result, the brace expansion is performed, but i, love, is not considered a preamble to the brace expansion. To get around this problem, let's try enclosing i, love in quotes. This is slightly better. Now, bash sees two tokens instead of three. The first token is the quoted string i, love, and the second token is Brahms Beethoven Bach. But bash still in this case does not consider i, love to be a preamble to the brace expansion. We can fix this by placing the quoted string immediately adjacent to the brace expansion with no intervening spaces. Now, in this case, bash sees only one token, the entire string, where i, love, is taken to be a preamble because it immediately precedes the opening brace with no intervening white space. Finally, let's add an additional space but place it inside the quoted preamble and also add a post script. I'm adding a space but placing it inside the quoted preamble and leaving no intervening space between the preamble and the start of the pattern inside the braces. Finally, I'm going to place a post script, a single period. A brace expansion can contain a comma separated list of strings as we have just seen. It can also contain a range of integers or characters using the operator dot dot. Let's try to use echo to see how to specify a range in brace expansion. Notice that I am not placing a space between the preamble and the pattern to be expanded. An underscore is fine but a space is not. This is expanded to five strings, number one, number two, number three, number four, number five. We can also use a sequence of characters with the dot dot operator. Here the pattern has expanded to a sequence of lowercase letters. Integers within a brace expansion can be zero padded. Here we have zero padded numbers one through nine and here we have zero padded numbers 90 through 100. Brace expansions can also specify numbers in reverse order. Here we have something expanded to strings where the numerical part is in reverse order from five through one. Brace expansions can specify a range of characters as we have seen above and character ranges can also be reversed. We observe that this character range has expanded to lowercase characters in reverse order. Brace expansions can also be nested. Let's work through this expansion part by part. In the expansion the preamble lowercase a and the postscript lowercase b are constant. In the variable part of the expression the brace expression is a list of items separated by comma. So bash starts with the first item a one two. This is a brace expansion as well. Now this expands to two strings uppercase a one and uppercase a two.  Now the first nested brace expansion is complete. Bash now starts with the second item b three four. The next two strings produced are the expansions b three which is then prepended with the preamble a and postpended with the suffix b followed by the expansion b four ultimately resulting in a b four b. Brace expansions are particularly useful for making lists of files or directories where the names are of a fixed format. For example imagine that we want to organize a sequence of photos by month and year. We may wish then to create a series of directories in numeric format in chronological order. Instead of creating the directories one by one using the command maker by hand we can use a command using brace expansion. Now using a single maker command we can create a series of directories. With this one command we have created directories for all of the months over a range of 10 years. Let's take a look at command line basics. Path name expansion. Bash is capable of performing certain types of expansions. Let's try to use ls to see how path name expansion works. In this command the wildcard character has been expanded. The result is a listing of all file names in the specified directory whose file names end in .h. Let's try another example. Here the wildcard expanded again resulting in a list of all files in the user bin directory whose file names begin with the character's py. Let's take a look at command line basics. Command substitution. Command substitution allows us to use the output of a command as an argument of another command. This is done by using the dollar sign character followed by a pair of single parentheses. The command whose output we want to use goes inside the parentheses. Let's begin by using ls to list the contents of the etsy x11 directory. Now let's enclose this ls command using the command substitution syntax. Here we have first executed the command ls to output a list of items in the etsy x11 directory. Command substitution then causes this output to be used as the arguments to echo. Echo finally displays a list of those items. Note that command substitution is very different from piping. Piping allows us to redirect the output of one command to the standard input of another command. For example a pipeline could be used to pipe the output from ls to the input of sort. If we were to reverse that pipeline in an attempt to pipe the output of sort to the input of ls this wouldn't work and it would have no effect on ls because ls does not make use of standard input. On the other hand command substitution allows us to use the output of one command as the argument or arguments of another command. Therefore if we wish to configure the behavior of a command such as ls with the output of another command we would use command substitution not piping. Let's try to use command substitution to provide arguments to ls. In the outer command we are attempting to use ls with the dash l flag to create a long listing in this format. We're using the command which with an argument of cp to determine the full directory the full absolute path to the cp command. The result of which is bin cp. Bin cp is then substituted as the argument to ls dash l resulting in the output that we see here. There is also an older syntax for command substitution that we do not recommend that you use however you may occasionally see it that older syntax uses back ticks instead of the dollar sign parentheses syntax. Again we do not recommend using this back tick syntax however it's important to be able to recognize it if you see it in someone else's scripts. Let's take a look at command line basics escaping characters. By default the dollar sign has special significance to the shell. Use of the dollar sign here tells bash that we want to refer to the variable called user. Bash then looks for a variable called user gets the contents of that variable and replaces user with the contents of the user variable. If we want to print a string containing an actual dollar sign we can precede the dollar sign with a backslash. The character we wish to quote in this case a dollar sign is then preceded with a backslash which prevents this particular dollar sign from being interpreted as a special character. If that dollar sign is followed by text then the quoting of the dollar sign prevents expansion by treating the dollar sign as an actual literal dollar sign rather than a special character which in normal cases would indicate that expansion is to be done. This type of quoting is used to selectively suppress expansions. It is handy when we occasionally want a special character such as the dollar sign to appear as itself. Let's see the effect of this type of character escaping in commands. In this command there are two expansions that could take place. Here we have a variable that is expanded to the value of that variable here lane s. Secondly escaping transforms backslash dollar sign into the literal dollar sign character and prevents the prevents dollar five from being treated as a variable expansion. The dollar sign is a character with special significance to bash. There are other characters that also have special significance to bash. These include the dollar sign which we just discussed, the exclamation point, the ampersand, the backslash itself, and the space character which bash uses to delimit tokens. Any of these special characters can be escaped using a backslash. Since the backslash is itself a special character if we want a backslash character to appear as ordinary text we would also need to escape it with a preceding backslash character. Here the first backslash character escapes the second backslash character resulting in a literal backslash character. Because this second character was escaped it does not in turn escape the dollar sign and the dollar sign here normally acts as normal to cause a variable expansion. See that we get this backslash character in front of the username. Let's see an example using multiple other escaped characters. Here we have escaped a literal space, an ampersand, another literal space, and an exclamation point. The ampersand and exclamation point have special significance to bash and can be explored in other situations. Needless to say without this escaping we would not get this exact output. Another way that we can confirm that special treatment is occurring here is by using brace expansion. Recall from our discussion of brace expansion that normally brace expansion with a preamble needs the preamble to not be separated by a space. The reason is that a preamble is only considered if it is part of the same token as the token containing the braces. Here we're going to see that because we are using the backslash to escape the spaces this entire string is taken to be a single token by bash meaning that we will get greetings and salutations taken as the preamble to this brace expansion. We confirm this here, we get greetings and salutations Joe, greetings and salutations Jane. Let's take a look at command line basics. Double quoted strings. Many times when passing arguments to a command it is desirable for a string containing spaces to be treated by bash as a single token. As we previously discussed one mechanism for obtaining this behavior is to escape the relevant space characters using the backslash character. Here we have created a file with literal spaces in the file name. An alternative method to using escaped spaces is to use double quoted strings to enclose the entire file name. By first quoting the string myfirstfile.text bash treats this entire string as a single token. Within double quotes some characters which normally have special significance to bash are treated as normal characters without special meaning. Normally the ampersand character has special meaning to bash inside the quotes that special meaning is lost. Wild card characters including the star, the tilde character, curly braces will all be treated as ordinary text and not special characters. Within double quotes therefore the following operations are suppressed. Word splitting, path name expansion, tilde expansion and brace expansion. Let's observe the effects of double quotes in some commands. In this command the argument to echo includes extra spaces between two of the words. The output of echo does not have these extra spaces between the word A and the word test. This is because without double quotes space is interpreted as a special character for the purposes of performing word splitting and the extra spaces are simply ignored. If we put this argument in double quotes the spaces within the string are no longer interpreted as special characters. Rather the entire quoted string is treated as a single token for the purposes of word splitting. All of these spaces remain in the output as ordinary text. Let's try command where double quotes will suppress expansions. We observe in these examples that when the tilde is used outside of double quotes the tilde expands to the full path name of the current user. We also observe that when the star wild card character is used outside quotes it is expanded here to bar and here to foo. However when the same string is enclosed within double quotes the tilde expansion and the wild card expansion are both suppressed. The tilde is treated simply as a tilde character. The star character is treated simply as a star character. Let's look at another example. Here we observe brace expansion in action. The preamble color followed by red or green or blue. Color red, color green, color blue. This is the result of the expansion. When we enclose this same string in double quotes the brace expansion does not take place and the curly braces are treated simply as literal curly brace characters. There are other special characters that retain their special meaning inside double quotes. These exceptions include the dollar sign character, curly braces when used with the dollar sign character, single parentheses when used with the dollar sign character, double parentheses when used with the dollar sign character, back ticks and the backslash character when used to escape these other special characters. This allows the following operations to be carried out within double quotes. Parameter expansion using the dollar sign, arithmetic expansion using the dollar sign in parentheses and command substitution. Let's try a command that is not affected by these double quotes. This command contains two examples of parameter substitution here using a dollar sign and curly braces and here using simply a dollar sign. The result of that expansion is observed here for this first case where the variable user is replaced with its value lane s which is the name of the current user and again the variable user is replaced with the value of that variable lane s. Here arithmetic expansion is performed. The dollar sign double parentheses indicates that arithmetic expansion will be performed. The arithmetic expression two plus two is replaced with the result of that arithmetic operation the integer four and finally command substitution. The command cal is run and the output is substituted for this expression here. All of these operations expanded as expected despite being within double quotes. Parameter expansion gives us the value of the variable named user arithmetic expansion calculated the result of two plus two and command substitution has displayed the output of the command cal. Let's take a look at command line basics single quoted strings. Many times when passing arguments to a command it is desirable for a string containing spaces to be treated by bash as a single token. As we previously discussed one mechanism for obtaining this behavior is to escape the relevant space characters using the backslash character. Another alternative is to enclose the string within double quotes. A third alternative which we will discuss now is the use of single quotes. Just as when double quotes are used to enclose a string when a string is enclosed in single quotes that string will be treated by bash as a single token. Recall that when using double quoted strings word splitting parameter expansion tilde expansion and brace expansion are suppressed but parameter expansion arithmetic expansion and command substitution are still performed. When a string is enclosed within single quotes none of these expansion operations are performed. Let's look at an example but first let's create a new directory containing a couple of empty text files. Now let's try a command involving tilde expansion brace expansion command substitution arithmetic expansion and parameter expansion bash begins by tokenizing the argument line resulting in seven tokens which are passed as arguments to echo. The first argument is the plain text string hello comma the second argument is the plain text string world. The third argument is the string tilde slash example slash star dot txt. This argument is expanded using tilde expansion and wildcard expansion into home lanus example a dot text and home lanus example b dot text. The fourth argument is three dot dot seven within curly braces. This is expanded using brace expansion into three four five six seven. The fifth argument is file etsy chron tab within dollar parentheses. This expands via command substitution into the result of performing the file command with the argument etsy chron tab resulting in etsy chron tab colon ascii text just as if we had typed it at the command line. The sixth argument is the arithmetic operation two plus two which is expanded using arithmetic expansion into the result four. The seventh argument is the variable user which is expanded using parameter expansion into lanus. The echo command prints each of these results separated by a single space character each. Now let's see what changes when we enclose this argument list within double quotes. First of all we can see that the literal space characters in the string are preserved. This is because the entire quoted string is treated by bash as a single token when the string is enclosed in double quotes tilde expansion is suppressed wildcard expansion is suppressed brace expansion is suppressed but command substitution still takes place arithmetic expansion still takes place and parameter expansion still takes place. Now let's see what happens when we enclose the argument within single quotes instead of double quotes. Again we first see that the literal space characters are again preserved this is because as before the entire quoted string is treated by bash as a single token when the string is enclosed in single quotes all forms of expansion are suppressed tilde expansion is suppressed wildcard expansion is suppressed brace expansion is suppressed command substitution is suppressed arithmetic expansion is suppressed and parameter expansion is suppressed instead we get the exact literal string that we typed in being returned by the echo command.


On outside Africa, Ukrainian President Vladimir Zelensky has complained about division inside the European Union over more sanctions against Russia and asked why some nations were being allowed to block the plan. The EU is discussing a sixth round of punitive measures, including an embargo on Russian oil imports. Such a move requires unanimity, but Hungary opposes the idea for now on the ground its economy would suffer too much. Zelensky is in a late-night address wondering how many more weeks it takes the European Union to agree on a sixth package, noting that Russia was receiving a billion euros a day from the 27 nation block for energy supplies.


Hi and welcome to this session. I am Asha and I am going to help you with the following question that says, find the remainder when xq minus ax square plus 6x minus a is divided by x minus a. So before finding the remainder, let us first learn what does remainder theorem say. It says if px is any polynomial of degree greater than or equal to 1 in real number, then when px is divided by the linear polynomial x minus a, then remainder is equal to the key idea that we will be using in this problem to find the remainder when the given polynomial xq minus ax square plus 6x minus a is divided by x minus a. Let us now start with the solution and let the given polynomial be denoted by px. So px is equal to xq minus ax square plus 6x minus a and we are required to find the remainder when px is divided by x minus a. Then according to the key idea, so replacing x by a in the polynomial px we have aq minus a into a square plus 6 into a minus a which is further equal to aq minus a into a square is minus aq plus 6 a minus a and aq cancels with minus aq and 6 a minus a is 5 a. Thus the remainder is equal to 5 a. This completes the solution. Hope you enjoyed this session. Take care and bye for now.


Hello, I'm Ryan Metivier. I'm here with ST Mercury Electronics at CES and today we're showing you some great demos for our integrated motion control products. At ST we have a number of solutions ranging from fully discreet solutions using an MCU to full monolithic solutions as well as various partitioning for integrated devices. The main star today is going to be the ST Spin 32 G4. We're demonstrating the integration of using a STM32 with gate drivers, DC to DC power supplies, switchers and analog components along with a 32 bit G4 processor. And here we're showing the capability of the G4, how it has enough processing resources and advanced timers in the same package to be able to drive two brushes DC motors at the same time with a high level of precision. One of the main benefits of integrating the STM32 G4 alongside the analog componentry and drive circuitry is you can substantially shrink your design and simplify your PCB layout. Here you can see on the left where we have a traditional approach where you're driving two discreet brushless motor drivers with two discreet MCUs, two discreet sets of gate drivers and a DC to DC conversion set up there. With ST Spin 32 G4, most of this is integrated into the same package and the only additional componentry you need for active circuitry is an ST Drive 101 gate driver for the second brushless DC motor. Another demo that we have to show you today is again using the ST Spin 32 G4 in combination with some of our monolithic ST Spin devices, the ST Spin 8 and 9 family. In a typical implementation of a complex robotic vacuum cleaner, we have six brushed and brushless DC motors with several discreet components. It's a complex system with a number of devices. In this particular demo we've integrated the EV Spin 32 G4 development kit with this ST Spin 32 G4 motor driver to handle the control of the vacuum motor as well as the sweeper brushes. An ST Spin 840 includes all of the power MOS as well as the controls for brushed DC motors. And in this particular demonstration, one push turns the vacuum on and another push turns on sweeper motors. But this is an example of using a development kit to go do rapid prototyping of systems directly from ST.com. Another implementation is for a new product coming out very soon as the ST Spin 948. In this example, we're using the ST Spin 32 G4 to handle all of the controls for the motion as well as the sensing for all six of the motors. Thanks to the integration of the ST Spin 9 family, we have four discreet half-bridge power devices as well as all of the controls. And in this implementation, you can control all six motors in the sensing with a single ST Spin 32 G4 while offloading the requirements of the application host processor to simplify what you need there. And the third and final demo here at CES is another example of using the EV Spin 32 G4 development suite on an e-mobility or an e-bike platform. This is controlling the motor as well as a start-stop for an e-bike. And what I was just going here was just going to our motor pilot tool just to illustrate some of the additional pieces of the development suite and debug kit for the ST Spin 32 G4 family. For those that are already comfortable with the ST Spin 32 development environment, the ST Spin 32 G4 family fits right in that environment so you can get up and going real quickly. Thanks for joining us at CES. Go to ST.com for more information on any of our products or contact your local friendly ST salesperson.


What's up guys, Mike the coder here today. We are going to go over trailing zeros. So essentially is that given a number N and our task is to calculate the number of trailing zeros in the factor of N factorial. So in this case we have 20 factorial and they have four trailing zeros. And when they mean by trailing zeros, it's the number of zeros at the end. So there's four zeros for the zeros at the end. That's why there's four trailing zeros. So our task is just to find calculate the number of trailing zeros. Okay, so how do you do this problem? Essentially is, let's say N is equal to 20, given that we need to find the number of trailing zeros at the factorial, factorial event factorial. Okay, so yeah. Okay, so what we could do first is we could list out the factorial of 20 factorial. So N is equal to 20 and then 20 factorial. What is that? It's equal to 20 times 19, times 18, times 17, times 16, times 15, times 14, times 13, times 12, times 11, 10, nine, eight, seven, six, five, four, three, two, one. Okay. Okay, now to find trailing zeros, essentially is that if we look at this, right? Trailing zeros, we have like, what does it mean by having trailing zeros? Well, it means that essentially we have this last number of 20 factorial, all these values here. They have four zeros at the end, four zeros at the end. So that means there's four zeros at the end. That means it could, it's divisible by 10, right? You know, like it's divisible by 10. So if you were to divide this last number by 10, right? And you keep dividing it, you're gonna get four, right? Because there's four zeros at the end. Therefore that, because there's four zeros at the end, if you divide by 10 repeatedly, right? We're gonna keep getting, we'll get four in the end, right? So because of this, essentially what they're doing is they're dividing by 10 over and over and over again. Okay, so if you have to zero, zero, zero, zero, zero, there's 10, right, it's gonna divide it. So essentially is that it's like 10 to the fourth, right? 10 to the fourth, right? Maybe I should list out this number. I'll list out this number. Just to help you guys see what I'm talking about. So here, can I paste this? Yeah, right here, I'll paste it here. Okay, so this number. So this number, this number, right? There's four trailing zeros, four trailing zeros. There's four trailing zeros at the end. So these four zeros are at the end, right? So essentially what we could do is how we know, how we count these number trailing zeros, right? Is you could keep dividing it by 10, right? So we could divide 10, 10, 10, 10, 10. So essentially this number, this first number, this whole number, which I'm gonna just copy this whole number down, this whole number. I'll just copy this because I'm too lazy to write it again. So copy this. This number is multiplied. So this whole number that we have, we're given here after calculating the factorial, right? Is equal to this number, multiply 10 to the fourth, right? Because there's one, two, three, four, four of them here. So essentially what we're trying to find is like the number of 10s we could divide after, number of 10s we could divide after after we calculate the factorial, right? So this factorial, remember 20 factorial is equal to this number that they gave us, right? This factorial, 20 factorial is equal to this giant number that they gave us, right? So we just need to find how many times we could divide by 10 in order to get this number, okay? To get four. So to do that, what you could do essentially is that 10 is basically just two times five, right? 10 is two times five, right? So if you wanna look at this, 10 is two times five. We could do two times five and there is the fourth power, right? Because this is 10 to the fourth, right? So we have this number multiplied 10 to the fourth, which is equal to the same number, the same number, let me paste this again. The same number multiplied by two times five to the fourth, right? Because literally I'm just rewriting this is equal to this. This is equal to this, okay? I'm just rewriting that. And then this is equal to two to the fourth times five to the fourth, right? Okay, so essentially is that as long as you count the number of times we're divided by five, we get our answer, okay? So instead of evaluating 20 factorial and then doing the number of times doing all this stuff, right? What we could do is we could loop through from 20 and then going down to one and then we just add up how many times we're dividing by five, okay? Keep dividing by five, add up how many times that happens and then that should give us the answer. So what I'm gonna do right now is I'm going to essentially just split all the numbers in 20 factorial. So I wrote down all the 20 factorial and I'm just gonna try to split them into powers of five and two. And then maybe you'll guys see the pattern for that. So 20 is five times four, right? 20 is five times four, which is five times two square, right? 19 is just 19. 18 is nine times two, right? That's what 18 is. 17, we leave 17. 16 is two to the fourth power, right? 16 is two to the fourth power. 15 is five times three, right? 15 is five times three. 14 is two times seven, 14 is two times seven. 13 is, what is 13? 13 is just 13. 12 is two times, 12 is four times three, which is three times two squared, right? 14 times three is 12, right? Which is a three times two squared. But what I'm doing is I'm just rewriting all the powers. Rewriting all the numbers in powers of two and five, okay? Yeah, and then, yeah. So we're at 12, then we have 11, which is times 11, times 11. 10 is two times five, which is just, I'll just five times two, there. 10 is five times two. Nine is three times three. Actually, I'll just leave nine as it is because you can't really do anything there. Eight is two to the third, right? Two four, two times four, times two is eight, yep. Times is just seven. Six is three times two. Five is just five. Four is two squared. Three is just three, and then two is two, and then we have one, okay? So then, now let's just count how many twos, powers of twos, and powers of fives we could have, right? How many powers of twos? Powers of fives. So if I just go here and just count how many powers of twos and powers of fives, I should be able to get my answer. Okay, so we have one power of five, one, two, so there's two fives, three, four. There's four fives, there's four fives, so there's four fives, so five to the fourth. How many powers of twos do I have? Well, we have two to the two, right? So two to the two. So we have two to the two, and we have two to just two also. So two to the two times two is two to three times two. Okay, I'll just write them all out down because this is really hard to count them in my head. So I have this one, right? Two to the two, and I have this one, this two times two. I have this one to the fourth. I have this one, this two, I have this one. Two to the second. I have this one, right? I have this two also, this two. I have this one, this two, two to the third. I have this two, which is one, two. I have this two to the second, and I have this two. Okay, I think I've listed out most of the powers of twos and the power of fives. The rest we don't have to care about because who cares about the rest of the numbers, right? We're mostly focusing on powers of fives and twos because that's how you make 10, right? Okay, so then, now that we have that. Yeah, now that we have that, let's just add up all the number of powers of twos to make this more simplified. So this is equal to five to the fourth. Times two plus one is, let's just add up all the powers. So two plus one is three. Three plus four is seven. Seven plus one is eight. Eight plus two is 10. Plus one is 11. 11 plus three is 14. 14 plus one is 15. 15 plus two, 17, 17 plus one is 18. So it is two to the 18th. Okay, so as you could see here, in the end here, after evaluating doing all the primes, listing the powers of twos and fives, we got five to the fourth times two to the 18th, okay? So if we go back to the original number, oh, whoops, not this one. Go back to the original number of this. It only had four trailing zeroes, right? It only had four trailing zeroes. So essentially is that no matter how many twos you have, the rest of these twos don't matter, right? Because in order to make 10, in order to make 10 is that we need fives, right? You have to pair a five with a two, right? So essentially is it's just like the maximum number of fives you could have because the twos don't matter because without the fives, without the, yeah, without the fives you can't really do anything. You can't pair them up, right? So essentially all we have to do is find the number of fives that is divisible by this power and then we'll just get, we'll just get like, essentially we just get the answer, right? Five to the fourth, okay?  That'll be the answer, essentially the number of zeros you have. So yeah, I can show you what I wrote for the code for mine. It's a little difficult to understand. Actually it's not that difficult. Okay, so essentially is we need to find the number of powers of fives, right? Powers of fives. So what I did was I created a counter here, count as equal to zero and I start my count from equal to five, right? And every time through this loop, I'm gonna multiply by five, right? Because then I'll get like five to the first power, five to the second, five to the third, five to the fourth, five to the fifth, right? So on and so forth, right? And then what I'm doing is I'm just taking my number and dividing it by this number of, my counter of I, of I, right? So essentially it's I'm taking my current number and I just keep dividing it by powers of fives. That's what I'm doing here, okay? And then I'm just adding it up with my counter. So as long as we keep adding up, keep dividing it by powers of fives and adding it up, that'll get our answer. And I do this while n divided by I is greater than equal to one. So while it's not zero, essentially, like while it's greater than equal to one, yeah. So while my number is like repeatedly greater than or equal to one, I'm just gonna keep dividing it by powers of fives and then keep adding it up to my counter and I just print it out. So yeah, that's pretty much just this problem. I hope you guys understand what's going on. Here we have main, which is reading in the number n and then it's called solve of n and then it just keeps doing it like powers of fives, adding those things up while I divide by my number of n of powers of fives, right here. Multiply by five. Yeah, this is a way to do it. There's other ways to do it. You could probably figure, there are other ways to do it. But yeah, essentially it's powers of fives and figuring that out, yeah. But I hope you guys enjoyed this video. Don't forget to like, comment, and subscribe. I'll check you guys later. Peace.


Both immigration and the NHS are proving to be hot topics in the run-up to this year's this December's general election and that's not really a surprise. They usually are big topics and they are of course issues that millions of people in the country care a lot about. So let me have a look at the two big parties Labour and the Conservatives and their approach to both of these issues which of course are linked. So let's start with the Labour Party and unsurprisingly the Labour Party is pro-open borders. We all know this especially Corbyn's Labour Party but then again it was Blair's Labour that opened the floodgates to begin with. To be fair to the Labour Party they're at least a little bit more honest about this than the Tories are but I'll get on to that in a minute. They have produced a video which I'll link to below which was tweeted by Diane Abbott and I'm sorry but I had to laugh at this. Essentially Diane Abbott is holding herself up as an example of fantastic immigration to the UK. Incredible. The woman hates this country, she hates white people, she can't wait to dismantle it and she can't wait until the ordinary Brit is in a minority so that she and the Labour Party no longer have to pretend to care about ordinary Brits come election time. I think it's quite funny that she's putting herself up as an example and I think really unfair actually because a lot of immigrants come here because they love the country and want to be a part of it so comparing them to Diane Abbott really really unfair but in this infantile video they are saying that if you have any concern whatsoever if you're one of around 70% of the British public in other words who is concerned about immigration what you are doing is blaming immigrants for all society's problems that's their angle that's what they're going for it is as I say infantile we are not this is not about blaming immigrants it is absurd to suggest this it's the same thing it's exactly the same thing in fact as standing there and pointing ray and shouting racist at anyone who has mild objections even to opening up the country to the whole world it's not about blaming immigrants it's about numbers and mathematics and basic common sense approximately 300,000 extra people a year in a country means you need to find resources for approximately 300,000 people extra a year that's an issue we do not have endless resources there's also the issue which no party apart from for Britain will talk about when it comes to immigration of culture and preservation of way of life the British people have a fundamental right to preserve and protect their way of life big parties don't talk about this at all the Labour's childish approach is you're all racists and and and you hate immigrants and on the Tory side it's all about economics it's all about bringing in money and and and lowering wages and conditions for working-class people by opening the borders to an over supply of people so they don't talk about this it's not important to them it is important it's I would absolutely guess I'd put a few quid on the 70 odd percent of people in this country who care and are concerned about immigration I think their way of life and their culture is a huge reason why we are not driven primarily by economics other things matter too so Labour's approach is what you'd expect but the Tories are just sneaky I mean to be fair to Labour at least a bit more honest about this we know what we're getting with Labour but the Tories are trying to sound like they will reduce immigration but they're not saying by how much and they're not saying when or how one thing they are proposing and sounding a lot like Nigel Farage is an Australian style points system now the first thing to say about that is have you seen Australia lately it's not going well mass immigration into Australia is not going well they have huge problems and the established Australian way of life and culture is under threat their society is divided they have a lot of the same problems that we have here in Europe so Australia I'm sorry to say not exactly the best example of immigration to hold up and a points based system is fine it's a way it's a common sense way of determining who to allow into the country and who not to allow into the country but here's the thing if you're going to allow 300 thousand people in under a points based system then what's the difference and the Tories are not actually saying that they're going to reduce numbers with this points based system they just want you to think that they are and there's a clue in the approach of the Tories in regards to immigration in their approach to the NHS there is a shortfall currently of 40,000 nurses and 10,000 doctors in the NHS and the Tories response to this is to issue NHS visas which are much cheaper and much easier to come by than other working visas to this country so in other words the Tories answer to a 40,000 nurse shortfall in the NHS is immigration and only immigration that's it that's their answer now let's be clear about this 40,000 extra nurses means 40,000 families of extra nurses means a 40,000 more families to be treated by the NHS which is already creaking at the seams but here's the thing since 2010 since the Tories have been in government let's not forget that immigration has remained at hundreds of thousands per year since the Tories have been in government since 2010 also since 2010 200,000 nurses have left the NHS we're bringing in 40,000 new families to cover the shortfall but not addressing the fact that 200,000 nurses have left the NHS under the Tory government why because they're overworked and underpaid now the NHS pays out thousands and thousands and thousands millions in fact per year on ridiculous procurement and on management consultancy why aren't they paying that money to the nurses why aren't they making it so that 200,000 nurses don't leave the NHS and then we won't have this shortfall this isn't being addressed the answer 40,000 nurses immigration that's it nothing let's not address the absolute shambles inside the NHS that's making 200,000 nurses leave it there's also a shortfall in the NHS of 10,000 doctors all of which the Tories want to replace or to fill those places with immigration last year 12,000 young British medical students were denied medical school places despite having the grades to do the course so we have 12,000 students with the grades to do medicine being denied places while we're importing 10,000 doctors does anyone see a problem with this that's not being discussed either and something else that isn't being discussed is the qualifications of the 10,000 doctors who are coming here from Africa from Asia how look this is going to be controversial to say but how do we know how qualified these people actually are how do we know whether they are suitable to be doctors in a British hospital I've worked in hospitals and you know I don't mean to be rude or mean or cruel but some of the doctors yes they speak English but you can hardly understand what they're saying because the accents are so strong there may be massive cultural differences so that people who go to see the doctor don't feel they can open up and frankly don't understand a lot of what this doctor is saying to them that's the harsh truth and that's not addressed either so we have a 10,000 doctor shortfall we import 10,000 doctors without addressing the fact that young British brilliant young students who want to go to medical school are not getting those places it's the same old stuff from the Tories they'll just throw just throw open the doors we have a problem throw open the doors let's not deal with the internal issues that are causing that shortfall in the first place and as for the approach to the NHS will labour on the Tories exactly the same let's throw more money at it they're wasting money at obscene levels at the moment so why are you giving them more money and it's unconditional money as well it's handing over billions of your pounds to NHS managers who have already shown themselves to be completely inept at spending it throw money at it bring in more people that's the answer no it is not the answer is to start training young Britons to be doctors the answer is to make it so that NHS nurses overworked underpaid are not overworked and underpaid let us this is a scandal that 200,000 nurses have left the NHS in nine years a scandal let's start treating the nurses a little bit better let's start paying them some of the ridiculous amounts we are paying out to managers and consultants and I don't mean medical consultants I mean the money that NHS managers pay to bring in management consultants to tell them how to do their job that's the problem let us stop wasting public sector money let us start investing in our own young people let us start making life a little bit easier for NHS nurses and we wouldn't have these problems in the first place and that we wouldn't need to open the border to all and sundry to fix problems that we can easily fix in other ways once again for Britain is the only party addressing these issues with the only one saying that immigration crisis can only be solved by training our own people you do not leave you throw your own people on the rubbish tip and replace them with immigrants that is not the way a country which cares about its country its people actually works we are the only ones talking about the cultural aspects of this we are the only ones talking about the basic common sense numeracy of this we are the only ones providing answers for the long-term health of this country it's the same old same old out of both Labour and the Tories and we need to really really change this this two-party state cannot go on forever common sense and pro-britain policies will change it and only common sense and pro-britain policies will change it we have that party join it