Pass LPI 010-160 Exam in First Attempt Guaranteed!
Get 100% Latest Exam Questions, Accurate & Verified Answers to Pass the Actual Exam!
30 Days Free Updates, Instant Download!
010-160 Premium Bundle
- Premium File 80 Questions & Answers. Last update: Nov 20, 2022
- Training Course 78 Lectures
- Study Guide 364 Pages
Last Week Results!
|Download Free 010-160 Exam Questions|
Size: 64.4 KB
Size: 37.48 KB
Size: 31.88 KB
Size: 40.92 KB
Size: 16.63 KB
LPI 010-160 Practice Test Questions and Answers, LPI 010-160 Exam Dumps - Killexams
All LPI 010-160 certification exam dumps, study guide, training courses are Prepared by industry experts. PrepAway's ETE files povide the 010-160 Linux Essentials Certificate Exam, version 1.6 practice test questions and answers & exam dumps, study guide and training courses help you study and pass hassle-free!
The Command Line
1. Basic Shell
The Linux command line, which is also known more properly as the shell, Now, the shell can be launched or started in a GUI window called a terminal program. Now, if you didn't have a GUI setup because you wanted to save on some resources, you can also login to the system locally using a text-based console. In addition to this, there's a shell that starts when you remotely log into a computer or a server if you're using a text-mode login protocol, something like Telnet or SSH. Now, the default shell in most Linux distributions is what's known as Bash, the "born again" shell. This is based on an older shell that was called the Born shell. Other shells are also available, but for the purposes of our time together in the lessons we're going to do, I'm going to be using the Bash shell.
Most of the other shells are very similar to the Bash shell in functionality, but there are some subtle differences that do exist. Now, each Linux user account can specify their own default shell, so individual users can change their shells if they like a different one better. Now, this can be done with an account management tool such as the user mod, which we're going to describe in a future lesson. Most Linux distributions allow users to install various GUI terminal programmes as well. Typically, a desktop environment is going to come with its own terminal. So the terminal programme choices can depend on the desktop environment installed, whether that's KDE, Nome, Xfce, or something else. Now, many terminal programmes are going to include the word "terminal" in their name, although some don't. For example, in the KDE desktop environment, it's called Console or the generic X term. Now, the details of how to launch a terminal programme are going to differ from one desktop environment to another. So it's up to you to figure out how to do it in your particular environment.
Normally, there's going to be an entry for the terminal in the desktop user menu or an icon on your desktop. Many desktop environments are also going to provide a search method where you can find the terminal program. For example, in Ubuntu's Unity desktop, you can click on the dash icon. This will show the Ubuntu symbol, and it's going to be located at the top of the application launcher, showing you a search box. If you type in the word "term," you're going to see the available terminal applications in the search results.
Now, a much quicker way to launch a terminal is by using your keyboard shortcut. If you type Control-Alt, that will launch the terminal too. Most terminal programmes are going to support tabs, which are similar to the tabs you use in a web browser. Having multiple tabs open is really handy because it's going to allow you to run multiple programmes simultaneously, work easily in multiple directories, or run programmes both as a normal user and as an administrative root user. Now, root is the administrator account in Linux, and it gives the user elevated privileges not available to normal users. We're going to focus much more on the root account later on in the course, when we get to the section on users and groups.
2. Command Line Syntax
A computer's operation, no matter which operating system it's running, can be loosely described in just three steps. First, the computer waits for user input. Second, that user is going to select a command and enter it via the mouse or the keyboard. And third, the computer is going to execute that command command. Now, in Linux, the shell displays a prompt where commands can be entered using the keyboard. This prompt usually consists of a user and the host, which is your computer name, the current directory, and a final character.
For Bash, that character is the dollar sign. A command is essentially a sequence of characters in a line, and you're going to end that line by pressing the enter key. Once you do that, that command is going to be evaluated by your shell. Now, many commands are vaguely inspired by the English language, and they form part of dedicated command syntax. Language commands in this language must follow certain rules known as "syntax" for the shell you're using. Now, if you use the wrong syntax, your computer is not going to be able to interpret them. To interpret the command line, the shell first tries to divide the line into individual words. Just like in real life, words are separated by spaces.
Now, the first word on a command line is usually the actual command name. All of the other words on the line are parameters that will explain what you want to do in more detail. A command's parameters can be roughly divided into two types. We have parameters starting with a dash; these are known as options. Figuratively speaking, we call these switches, and they allow certain aspects of a command to be switched on or off. to pass several options to a command. They are frequently combined behind a single dash or typed out separately, as in "dash A," "space C." If you wanted to put them both together, you could do AC. Now, many programmes have more options than can be conveniently mapped to a single character. So they'll support long options for readability. And these long options most often start with two dashes, and they cannot be bundled together or accumulated. Now, the second thing we have are parameters without leading dashes, and these are known as arguments.
These are often the names of files that the command should process. The general command structure can be seen as this: what do you want it to do? The option: how are you going to do it? And the arguments—what do I do with them? Usually, these options follow the command and proceed with the arguments. However, not all commands insist on this format. With some arguments and options, they can be mixed around arbitrarily, and they behave as if all the options came immediately after the command.
With other commands, options are taken into account only when they are encountered while that command line is being processed in sequence, going from left to right. Now, just like in real life, Not properly using the correct syntax will lead to the system not understanding what you want done. It could either stop and do nothing, or it could cause severe consequences when the incorrect arguments or options are used. Now, later on, I'm going to show you a demonstration of how these commands are used with their corresponding syntax, and we'll break this down in more detail.
There are thousands of commands available for the command line user, and it's a monumental task to remember all of them. Now the real power of the computer is its ability to simplify repetitive and huge tasks for you, the user. To get it to do that, though, we have to create some power within the shell, and the shell allows us to automate things through the writing of shell scripts. Now, in the simplest terms, a shell script is a file containing a series of commands. The shell is going to read this file and carry out all the commands as if you'd been entering them directly on the command line itself. Now, a more in-depth discussion about shell scripting will be covered in our next videos coming up.
But for now, let's talk about an essential feature of using the command-line interface. This feature gives you the ability to use a name or a label to refer to some other quantity, such as a value or a command. You may remember this from algebra class. It's known as a variable. Variables are used, at the very least, to make the machine code more readable. For users, however, variables can also come into use in more advanced programming or scripting. When the user is in a situation where you don't actually know the value before you execute the program, a variable is going to act as a placeholder that gets resolved at the actual execution time of your script.
Variables are areas of memory that can be used to store information and are referred to by a name. Whenever the shell sees something that's written with a dollar sign and then a name, it assumes it's a variable, and it tries to find out what was assigned to that variable and substitute in the proper values. Now, to create a variable, a line is placed in a script that contains the name of the variable, followed immediately by an equal sign. No spaces are allowed here. After that equal sign, the information that needs to be stored is then going to be assigned. So, for example, if I wanted to set the age variable, I would put "dollar sign age equals 40" if I was saying that the age was set to 40 years old.
Now, there are a few rules you need to know when naming your variables. First, variable names must start with a letter. Second, a name must not contain any embedded spaces. You can use underscores, though. So if I wanted to say the year of birth, I could put "year underscore of underscore birth," but I couldn't use spaces. Third, you cannot use any punctuation marks. That's it. Three simple rules: it starts with a letter, it can't have any spaces, and it can't have any punctuation. Now, when a user starts a shell session, some variables are already set by the startup file. To see all the variables that are in the user's environment, you're going to use the print env command, which stands for print environment. This will display all those environmental variables right on your screen, as you can see here. Now, I want you to remember that any time you see an uppercase variable where all the letters are uppercase, that is an environmental variable, just like you see here on the screen.
In a previous lesson, we talked about how the shell interprets commands. The shell is going to read the input and find and run each command, passing the line arguments into the command to be executed. Now, the shell is going to treat a number of characters in a special way on the command line, and these characters are known as metaphorical characters.
The most common shell meta character is the blank or space character, and this tells the shell to use separate arguments between those things. The shell does not pass any blanks or spaces to any command. Instead, the shell is going to use those blanks and spaces to separate and identify the individual arguments for that particular command. One blank separates arguments the same way ten or 100 blanks do, so any spaces are treated the same. Other shell meta characters include things like the dollar sign, the star, the semicolon, the greater-than symbol, the question mark, the ampersand, and the pipe.
Now, "quoting" is the generic name given to the action of protecting shell metacaracters from being treated specially by the shell. A quoted blank does not separate arguments will.A will that is unquoted. A quoted semicolon doesn't separate commands the way that an unquoted semicolon does. Quoting is used to prevent the shell from acting on and expanding these meta characters. The quoting causes the shell to ignore that special meaning of the character, and instead, the character gets treated like plain text. This way, it can be used as part of an argument if it needs to be. Quoting is also done either with double quotes, single quotes, or backslash characters. While technically quoting is only used to protect individual shell metacaracters from the shell and not to the entire command line, it would look better to surround the entire argument with matching quote marks.
Backslashes may also be used to quote or turn off that special character's ability, following each character one at a time. Quotes and backslashes tell the shell which parts of the input to treat as ordinary plain text characters and which to treat as special characters. The quoting delimits or identifies this string of characters, and the quoting mechanism is removed and is not part of the string that's passed to the command.
Only the characters being quoted are going to be passed into that command. This allows the shell to remove the quoting mechanism before passing that delimited text as an argument back into the command and allowing it to be understood. So let's take a quick look at an example. Let's look at the phrase "hello, world." There's a command called echo, and when you type it, whatever comes after it on that line will be printed to the screen as a new line. So if I wanted to put "echo," "hello," and "semicolon world," I would have to type it out as "echo," "hello," and "semicolon world."
Now, why did I need that backslash? Because if I didn't have it, what's going to happen is that the shell is going to think that a semicolon is used to execute two different commands: echo "hello" as one command and another called "world." But there is no command called "World." So it'll give you a syntax error. by using that backslash. It's going to treat that semicolon as plaintext, and it's going to put hello, semicolonworld, on the screen just like this. Let's take a look at one more example. Let's pretend you wanted to put $200 on the screen.
Well, that's a pretty big phrase with a lot of spaces. So I'm going to type "echo" followed by a colon. I've moved the dollar sign back to 1200, quote. That way, I can put everything inside those quotes on the screen. And instead of that dollar sign being treated as a variable character because I have that backslash there, it's just going to print to the screen as normal plain text, as you can see here. Now, these are just two brief examples, but in the demonstration, we'll spend more time in the command line going over how we can quote and use backslashes to remove the special meaning from some of these characters and treat them as plain text.
5. Proper Command Usage
In this lesson, we're going to go through and learn a little bit more about the shell. I've talked about it in the last couple of videos, but now I want to show you how to use it hands on. There are a couple of ways to access your shell. The first way is to simply right-click on your desktop and click on "Open Terminal." If you do that, your shell will appear. Another way to do it is to go down to the application bar on your bottom left side, start typing in the word "term" or "terminal," and you'll get a lot of different options. One is already installed in my system, known as Terminal, but there are 15 more that I can get from the online Ubuntu store. You'll notice that things like Terminator, Terminator X, Docker, Copay, and many others are all in some way related to the term "term" or "terminal." And so if I continue to type, you'll see that I can get some different options, like Terminus, showing up here as well. Okay. But for me, the easiest way is to simply right-click and go to Open Terminal. This will bring up your default terminal that comes built into Ubuntu.
From here, I'm going to go ahead and maximise my screen, and I'm going to go ahead and zoom in by hitting the CTRL, Shift, and plus signs two times to make it a little bit bigger and easier for you to see. Now, from here inside our shell, we're going to be able to go forward and start issuing commands. Now, as we talked about, we have to do this using the proper syntax. So let's pick a particular command to start playing with. I'm going to use the LS command, which stands for list. It's very similar to the Windows directory listing, or Dir command. Now to do this, I'm simply going to type in LS and hit Enter. If I do that, I get a list of the folders and files that are in the directory I'm sitting in. And I'm currently in the home directory.
How do I know this? Well, because right before that dollar sign, you see the squiggly line or tilde. That tilde represents the home directory. Now if I wanted to go into one of these directories, for example, the Documents directory, I would type CD for change directory space and then the word Documents. If I hit Enter, you'll now see that I am in the home Documents directory. You can keep track of where you are based on that path that's showing up in light blue. Now, some distributions and some shells don't show you your current path. If you're in one of those distributions, you can always find out where you are by typing PWD and hitting Enter. That's PWD for "present working directory." Once you hit Enter, it will tell you the full path from the root all the way down to the folder you're in. In my case, my username, Home Dion Training, contains documents.
Now, if I want to see what's inside the Documents folder, I can again type LS and hit Enter. By doing that, I got nothing back. Why is that? Well, let's take a look at the Documents folder. If we go into our files, we go into our documents. You'll see that it's an empty folder. That's why. because there's nothing there. Now, if we wanted to put some things there, we could use a couple of different commands. One of them is the command "Touch to UC." Touch will actually create an empty file with whatever file name you give it. So going back to our command Lexon, we talked about the fact that we have commands, options, and arguments. So the command is, "What do I want to do?" I want to touch a file and create it. Now, the option is: how do I want to do it? And the argument is, what do I do it with? Well, with the Touch command, I actually don't need an option.
So I'm just going to go right into the argument. And what I want to do it with is going to be the name of the file. In my case, I'm going to call it Test One TXT. If I hit Enter and now I hit LS, I can then see if it's in the directory. And you can see we now have that file inside the directory. One of the things you're going to want to do as we move forward is create some folders and files that we can play with as we go through and do things like copying, moving, renaming, and deleting files and folders in our next series of lessons. As we get deeper into the shell, let me go ahead and switch back to the GUI, because you can also do this by right-clicking and selecting "New Folder." And so I can call this folder One, and then I'll create another one called Folder Two.
Now if we go back to our terminal, we can go ahead and create Touch Test Two TXT as well. And if I hit LS, I should see four things listed. I now have Test One dot TXT folder one. and TXT two dots test Now, we talked about the fact that there are options as well. What do you want to do with the list command besides just listing out the names? Well, maybe you want to be able to see additional details and additional information about these files and folders. For example, maybe you want to know how big they are, what they contain, and other things like that. Well, if we do LS-DA, that will actually list it out with additional details. So here you can see on the left side that we have the permissions, we see the username of who owns it, in this case, Dion Training, and we can see the file size.
If you look at tests one and two, they are each zero bytes big. Now, why are they zero bytes? because all we did was create an empty file. We didn't put anything in that file. And so if I want to change that, let me go back over here to my file system, and I'm going to open up a test one. And I'm just going to add something like this as a test, and then I'm going to go ahead and save it and close it. Now, if we go back and type LS la, we should see that test one is no longer zero bytes.
And in fact, you can see it now has 16 bytes of data, which is still a very small file. But we can see that information has been saved in there, and there is now a file size associated with it. So at this point, we've seen how to use some basic commands like touch and LS. When we use things like Touch, we use it with an argument that says, "Touch this file, test one, and test two." When we used LS, we used it with some options, and we turned them on and off using that dash command. So in this case, I wanted to see the big picture with all of the attributes. So it's LSLA. Don't worry too much about the commands I'm using in this particular lesson yet. We're going to dive into each of these commands in much more detail later on. Now, another thing we talked aboutwas variables and variable names.
And I had mentioned that we can use the print env command to print out our environmental variables. Well, let's go ahead and do that and see what we have. Here we go. And you can see that at the bottom, the last thing there is "old PWD," which is the old present working directory. It's set to home demon training, as you can see. Now why is that? Well, if you remember from earlier, we started out in the home deauctraining directory, and then I changed directories into documents. And when I did that, there was an environmental variable that stored the last directory you were in. That's known as "old TWD."
And so again, if I want to go back up and say, "CD space dot dot," that will take me up one directory. Now I am back in the home DEON training directory. That's what the tilde stands for. Now, if I print my environmental variables again, what do you think that old PWD is going to say? It should read home-based training materials. Let's see if it does. And there it is. So you can see how it keeps track of the last directory you were in by using this environmental variable. That's just one of many different variables that we have as far as our environmental variables, shown here on the screen. The last thing I wanted to discuss here while we're in the terminal is the concept of quoting. And we talked about the fact that we need to use quoting if we want to turn off some kind of special meaning for a character.
For example, we have the character "semicolon." Now on the command line, the semicolon will allow you to enter two commands on one line. So, for example, we have the command "echo," which will print something to the screen like "hello." And so if I just hit enter, you'll see "Hello" show up. Now, if I wanted to do echo, have hello show up, and then show a directory listing like LS, I wanted to do them both at the same time. I can do that by typing echo, hello, a semicolon, and then LS; that semicolon has a special meaning of doing both of these commands and then displaying them on the screen.
And so there we go. We now have "hello," and then we have the list of folders inside this directory. Now, what would I do if I wanted to put something on the screen, like, "My name is Jason, and I live in DC"? Now, because I have a semicolon there and I want to print that to the screen, I need to escape that character. And so what I'm going to do here is echo this to the screen because that's the command I want. I'll put it all inside quotes. And so you'll see here, because I have quotes around everything, that the semicolon is treated as a regular character and not a special character. Now, let's do that again, but let's take away the quotes. Now, what do you think is going to happen? Well, it should treat this as an echo; my name is Jason. End that command and then start the new command, which it thinks is called I for "I live in DC." As a result, we'll probably get an error saying that "I" isn't a valid command. Let's go ahead and hit enter.
And that's exactly what happened. Now, what if I don't want to use those quote marks around everything? Well, I can still use that semicolon, but I have to escape its meaning. And if you remember from the lesson, we can do that by using the backslash. So now it's going to be treated as one long command. Echoing the phrase, my name is Jason Semicolon. I live in Washington, DC. If I hit enter, you'll see that that gives me the same thing as using those quote marks. Again, there are lots of different ways to do quoting. You can use quote marks. You can use the backslash. It really is up to you and which one you're more comfortable with. Personally, I tend to use the quote marks a whole lot more than the backslashes, but the backslash is a valid way to do it as well.
LPI 010-160 practice test questions and answers, training course, study guide are uploaded in ETE Files format by real users. Study and Pass 010-160 Linux Essentials Certificate Exam, version 1.6 certification exam dumps & practice test questions and answers are to help students.