(This page has no text content)
Linux for Beginners The Ultimate Guide To The Linux Operating System & Linux Commands 1st Edition Adam Vardy
(This page has no text content)
Contents Introduction Chapter 1: What is Linux? Distributions Open Source The Linux Shell Root Capitalization Server vs. Desktop Why Use Linux? Chapter 2: Installing Linux Server Edition Chapter 3: Installing Linux Desktop Version Chapter 4: Basic Linux Tasks/Commands Sudo Man Pages Tasksel Apt-get Services Top Chapter 5: Basic Linux Navigation Chapter 6: Editing Linux Files with Vim Starting Vim Changing File Ownership Editing and Navigating Exiting and Saving Chapter 7: Advanced Linux Navigation Changing Directories and Finding Files Listing/Displaying Files Making, Deleting, Moving, Copying, Renaming Mounting Drives Conclusion
(This page has no text content)
Copyright 2016 - All rights reserved. This document is geared towards providing exact and reliable information in regards to the topic and issue covered. The publication is sold with the idea that the publisher is not required to render accounting, officially permitted, or otherwise, qualified services. If advice is necessary, legal or professional, a practiced individual in the profession should be ordered. - From a Declaration of Principles which was accepted and approved equally by a Committee of the American Bar Association and a Committee of Publishers and Associations. In no way is it legal to reproduce, duplicate, or transmit any part of this document in either electronic means or in printed format. Recording of this publication is strictly prohibited and any storage of this document is not allowed unless with written permission from the publisher. All rights reserved. The information provided herein is stated to be truthful and consistent, in that any liability, in terms of inattention or otherwise, by any usage or abuse of any policies, processes, or directions contained within is the solitary and utter responsibility of the recipient reader. Under no circumstances will any legal responsibility or blame be held against the publisher for any reparation, damages, or monetary loss due to the information herein, either directly or indirectly. Respective authors own all copyrights not held by the publisher. The information herein is offered for informational purposes solely, and is universal as so. The presentation of the information is without contract or any type of guarantee assurance. The trademarks that are used are without any consent, and the publication of the trademark is without permission or backing by the trademark owner. All trademarks and brands within this book are for clarifying purposes only and are the owned by the owners themselves, not affiliated with this document.
Introduction Thank you for buying Linux for Beginners. Linux In this book, we are going to give you an overview of the concepts that you have to understand before you actually start using Linux. We will explain to you the different elements of it that you ought to know about before you go and delve into the Linux world. Linux has many benefits. However, it also has numerous little aspects that can leave you perplexed. Not being able to understand these aspects can definitely cause you problems in the future. In this book, we’re going to talk about what those elements are. We are also going to talk about what Linux is, where it came from, and all of the fundamental concepts that you have to understand before you actually start building your own Linux servers and maintaining your own Linux systems. In addition, we’ll also teach you basic terminal commands that will get you up and running about within the Linux operating system. We hope you enjoy this book!
(This page has no text content)
Chapter 1: What is Linux? The first thing that we need to talk about in this book is about the origins of the Linux. In a nutshell, Linux is an operating system. For those of you who do not know what an operating system is, and for all of you who think you do but may have forgotten what an operating system is, it is actually the software layer that is between your hardware and the software that allows you to get something productive done on a computer. The operating system is what allows the software to talk to the hardware. It is the one that lets you store information on hard drives, send out print jobs to printers, etc. If you are in a normal Windows environment—a Microsoft Windows Operating system—you have your hardware at the bottom, you have the Windows operating system on top of that, and then you have Microsoft Office, for example, that sits on top of the operating system. Linux is an operating system that acts as an intermediary—i.e. a bridge—between the physical device and the instructional code of a program. The main thing that you just need to realize is that in the Linux world, the software that you will be running is of a completely different type, compared to the ones that you would run in the Windows operating system. Desktop applications like Microsoft Office and Adobe Photoshop are not usually run on a Linux environment. Linux normally runs servers—Apache web servers, database servers, web virtualization servers, etc. However, there are various Linux distributions out there that are specifically made for personal desktop computers. These Linux distributions are, in a way, similar to Windows and Mac OS, in a sense that they run the same types of programs like Word Processing programs, photo and video editing programs, web browsing applications, program development applications, games, etc. These Linux distributions are more targeted to home users who just want a free operating system alternative. Linux did not begin as an operating system, however. Linux was a kernel created by Linus Torvalds while he was a student at the University of Helsinki. The Kernel is essential, but by itself, it is useless. It can only function in the context of a complete operating system. The Linux Kernel was used in combination with the GNU operating system. Imagine GNU as a big complex puzzle with a big piece in the middle missing—the big piece being the Linux Kernel. The complete puzzle equates to a functional operating system. It is important to understand what a Kernel is as this is the defining component of Linux. A Kernel is the central part of an operating system that is responsible for interfacing all you applications down to the physical hardware. There are two major types of Kernels competing in today’s market—Windows and Unix-like Kernels. The Linux Kernel falls under the latter as does BSD, Mac OS,
and Solaris. The term “Unix-like” refers to the fact that they operate similar to, or are based on the original Bell Labs UNIX operating system. Kernels tend to fall under three categories: Micro Kernel – A Micro Kernel only manages what it has to: CPU, Memory, and IPC or inter-process communications. If it is not an IPC, Memory, or CPU, it is automatically regarded as an accessory and can be handled in user mode. Monolithic – Monolithic Kernels like Linux are the opposite of Micro Kernels. They encompass not only the CPU, Memory, and inter-process communications, but other things such as device drivers, file system management, and system server calls. Hybrid – The Windows Kernel falls under Hybrid because it has the ability to pick and choose what to run in both user and supervisor mode. And so, between 1991 and 1994, Linus Torvalds created the Linux operating system by combining the GNU OS with the Linux Kernel. Basically, Linus Torvalds wanted an operating system that is not only free, but also something that he can customize to fit according to his programming needs. Linux was his creative little pet project that he did on the side. The big thing with Linux is, because it has an “ux” suffix, and because most of the commands that you use look a lot like UNIX commands, people think that Linux is a type of UNIX operating system. This is totally not the case. UNIX is its own type of operating system. Linux is its own type of operating system. Linus Torvalds created the entire Linux operating system from the ground up. The reason he created Linux was that he wanted to create an open source operating system for people to use. Back in the day, UNIX was not open source. If you wanted to use UNIX, you had to pay somebody in order to use UNIX. Microsoft Windows, of course, is Microsoft Windows. You always have to pay in order to use Microsoft Windows. So Linus Torvalds, being the computer engineer that he is, wanted an operating system that was completely free. He and his friends at the Massachusetts Institute of Technology, or M.I.T., wanted an operating system that they do not have to pay for to use and will also help them create the computer programs that they wanted to make in a more efficient and easy way. In other words, they wanted an operating system that they can customize to fit their needs as well as completely free to use. The big thing to remember with Linux is that, even though it is an operating system, it looks totally different than Microsoft Windows or Mac OS.
Distributions After Linus Torvalds created Linux back in the 1990s, he wanted to stop working for a little bit. So, what he did was he made the source code for his new operating system completely available to the public. This allowed everybody in the world, especially computer geeks, scientists, etc., to start playing with and changing the Linux operating system as they saw fit. Major companies and educational institutions decided they liked Linux. And since Linux is open source, they are able to see the source code. This gave them the ability to start creating their own versions. People from University of California, Berkeley, decided to start creating their own version of Linux. People from China also started creating their own version of Linux. People from all over the world—from all walks of life—started making their own versions of Linux that fit their own personal needs. Today, you have Red Hat Linux, Ubuntu Linux, Google Android, and many more. Making Linux’s source code available to the public facilitated the creation of something called distributions or “distros.” Distributions are the various versions of Linux that people have created over time. There are many different versions of Linux that are out there. Different distributions have different capabilities. Now, when you need to decide which Linux distribution you want to use, you are going to have to think about what you want your computer to do first with Linux. It is much more important that you understand what you want your computer to do, before you install the Linux operating system. With Microsoft Windows, you just install it first and then worry about what you want to do with your server later. With Linux, every distribution is built to do things in a certain way. For example, there is a version of Linux called Trustix. Trustix Linux is considered to be the most secure Linux operating system out there. It is just a brick. You set Trustix Linux up and as long as you do not do anything completely stupid, nobody can hack it and no viruses can get to it. It is just one solid, secure server. But, you have to decide that you want a solid and secure server first, before you go and get that particular distribution to install on the server. So, if you want a computer that you can use some office applications or you are going to surf the web with, then you may want Ubuntu Linux’s desktop version. If you want a super secure computer, then you might want Trustix Linux. If you want something with enterprise level support, let’s say you want to use a Linux distribution that has a tech support center out there to help you if necessary, you may decide to use Red Hat Linux. But again, you have to decide what you need your computer to do in order to determine the exact Linux distribution to install on your computer. If you install Ubuntu Linux distribution on all your computers, and then you decide you need enterprise support and you call Red Hat Linux, they will not be able to help you. Red Hat Linux does not support Ubuntu Linux. Every
distribution does things their own way and is created by different entities. So you must familiarize yourself first with what a particular distribution does, and whether it fits your computing requirements exactly.
Open Source Now that we have talked basically about where Linux came from, the next thing that we need to talk about is Open source licensing. Of course, at this point in time, you have probably heard of open source software. You are also probably under the wrong idea that open source software is free software. This is not the case. Open source software is not free software. And if you treat all open source software as if it is free, you are jeopardizing not only your career, but also your company. It is just bad legally. Therefore, it is important that we discuss open source software and the different ways that open source software vendors get paid. So what does open source exactly mean? What open source software means is that whenever a programmer sits down and begin writing the code for a software, they provide you with the code only so that you can see how the program was written. It doesn’t necessarily mean it is free. So how do these programmers earn with an open source license? There are four different ways that these open source vendors or programmers get paid. The first one is through the open source model where they give the software free of charge, but when you require training or support for the software, that is where you have to pay them a certain amount. Let us say for example you downloaded the mySQL software for your Linux server. You download the mySQL program, tinkered around with it for a little bit, and then you find out that it is extremely useful and powerful. Even though you already figured out most of the intricacies of the mySQL program, there are still certain aspects of it that you need to learn, or need support with. So, you go approach the software developer and ask for support and training. This is the point where you have to pay them a certain amount. This is one of the ways these developers or programmers get paid for their development efforts. The second way developers and vendors get paid through an open source license is through a non-commercial, personal-use-only open source license. This is where most people, including veteran system administrators, get into a lot of trouble. It is true that some open source licensed software will allow you to obtain a program completely free. You can use them in a computer lab or any kind of experimental environment without having to worry about the legal implications. Why? Because it is for personal or non-commercial use only. The problem, or the part that usually gets an administrator in hot water, is as soon as they take that server from the test lab and screw it into a server rack in the production environment, the commercial use starts to kick in. If you are a geek at home and you want to play around with the software, there is no problem at all. Once you use it to power up a business server, or maybe host a home business website for example, you now own a licensing fee for that software.
The gruesome thing about it is that these licensing fees can be anywhere between $5,000 and $ 10,000. It is that expensive. Therefore, it is only prudent that you be conscious on how you use the software, whether it is for personal, non- commercial, or commercial use. The third way open source software programmers or vendors get paid is through a paid open source license. Some of you might be asking, how can a software be on an open source license if it is a paid software right off the bat? Well, a paid software will always be considered as open source if they let you see the code. The idea basically is, if you want the product, you pay the vendor or developer the licensing fee and you buy it just like if you are dealing with Microsoft, Adobe, etc. The difference with open source software in this model is, even though you bought the software and can see the code, you may not have the legal right to modify that code. If you are the type of user who likes modify code to tailor-fit a particular software according to your specific needs, you should lookout and avoid software that has this type of open source model. The fourth way these open source vendors get paid is through a recurring open source license fee. Again, this is like most open source licenses out there. They let you download and test the software free of charge. They would even let you see the code, just so you know how the software actually works. However, in order for you to have the legal right to actually use the software, they would have to charge you a yearly fee. This is usually cheaper than a one-time licensing fee, but is expensive nonetheless. Here is an example: Let us say you downloaded Foxit PDF reader for free. You can use the software, test out its most promising features, and even see the code to figure out how it does what it does. But in order use the software legally, fully unlock its most useful features, and also have technical support for it, you have to pay the developers a yearly recurring fee. So, as you can see, knowing how open source licensing works is far more important to your business than simply being able to set up a server. This is the kind of thing that can cause massive amounts of damage to you and your company. If you install multiple servers with open source licensed software and you do not know the licensing requirements, that may be a catastrophic problem. Remember, open source does not mean it is free. It has nothing to do with free. A huge amount of open source only happens to be free. However, that doesn’t mean open source software is completely free. What open source means is that you are allowed to see the source code that created the program. This doesn’t mean you’re allowed to modify the source code. You may not even be able to do a single thing to the source code. But at least you’re allowed to see the source code so that you understand what is happening. If there are flaws, or if there are security holes, you can actually see that in the code.
As you can see, Linux can go from being really affordable to being stupidly expensive in an instant. And these maintenance contracts are one of the things that can make it extremely expensive. Open source licensing, as we mentioned, can make or break your career. So make sure you take it seriously.
The Linux Shell Now that we have the legalities out of the way, let us now talk about the shell of the Linux operating system. So what is a shell? The shell of an operating system is the screen that you use to interact with the operating system. If you’re thinking about Microsoft Windows, the Windows shell is that graphical user interface where we have the little mouse pointer which we use to go around and click on the various elements of the desktop, such as folders, icons, etc. The shell is of two types. The first one is the graphical user interface, or GUI. The second one is called the line user interface, or LUI. The LUI basically looks like DOS prompts. So, if you ever played with the Microsoft Windows DOS prompt, the line user interface is exactly that. It is that black and white screen where you type in different commands to get a particular output from the computer. In Linux, since this is a much more technical operating system preferred by programmers, geeks, engineers, or what have you, they prefer to use the line user interface. So when you go and install Linux, you can either have a graphical component where you can click things in the desktop much like a normal operating system, or you just have that little line user interface. The main thing that you have to remember about the shell is that the line user interface (LUI) is much more powerful than the graphical user interface (GUI). However, when you install Linux with just a line user interface for the shell, all you are going to get is a prompt. If you don’t know what you need to do with the command prompt, like the various shell commands for that operating system, you will be stuck. There are many cases where people install Linux with an LUI, but doesn’t know any Linux shell commands for the LUI. So basically, that’s the thing with the Linux line user interface. You are going to have to understand the commands in order to get the computer to do anything that you need it to do.
Root The next big concept that you have to understand when you are going to be using Linux is the concept of Root. In Linux, root pertains to the highest level of anything. When you hear about the root user, it is referring to the administrator of the computer. The root user is the highest level user that you can be on the computer. So, if you can log in as root, you can do anything in the world you want to with the computer. Root can also mean the root of the operating system. It is where the operating system installed in the computer hard drive. If you think about this in terms of the Windows operating system, C:/ is the root of the Windows operating system because that is where it is installed. Root can also mean the highest level that a user can get into. What does this mean? In Linux, users have home folders. The home folder holds all of the user’s data, such as documents, settings, programs, etc. So the root of the user would be their home directory. The home directory is the highest level for a particular user. The main thing to understand whenever you are talking about root in Linux is that root is the highest level of anything. There’s actually a user account in Linux called root, and that user account is the absolute highest level user that you can begin the operating system in. Root can absolutely do anything. They have total access to everything in the operating system. Once we go into actually starting to type commands and making Linux do certain tasks, this concept of root is going to be crucial.
Capitalization Let us now talk about something that just messes with every Windows user’s head when making the switch to Linux: Capitalization. So basically, you have uppercase and lowercase letters. In the Windows operating system, it doesn’t care whether you put in an uppercase or a lowercase letter. If you have a folder named “Home” in Windows, that is going to be the same as “HOME,” “home,” or “homE.” Windows, except when it comes to passwords, does not care about capitalization. In the Linux world, keep in mind that Linux was created by computer professionals. These computer professionals coded the characters of letters, numbers, punctuations, etc. using ASCII text. In ASCII text, an uppercase “H,” for example, is actually a different character from a lowercase “h.” What this means is that in the Linux world, “Home,” “HOME,” “home,” or “homE” would be considered different folders. Let us say you have a folder named “USER,” but for some reason your typed in “user” when you tried to access it. Linux will not be able to find that folder because the “user” folder does not exist. Only the “USER” folder, with the uppercase letters, does exist. So remember, capitalization matters in Linux. One of the places this can cause you big problems, and you have probably already seen this with some websites that you use, is when you are typing your username logins. In Linux, all username and passwords are case sensitive. So when you type in your username or password in Linux, make sure that you don’t have your caps lock key turned on or you are not accidentally holding down shift when you type in your username and password. This is actually not complicated. It is just that people are used to using Windows that they totally bring the mannerisms of using Windows over to Linux, where capitalization matters greatly.
Server vs. Desktop There are generally two versions of Linux that everybody is going to provide. Whether you get Red Hat Linux, Ubuntu Linux, Fedora Linux, or whatever distribution that may be, they will normally have two versions of the distribution. One is going to be the server version while the other is going to be the desktop version. The main difference between the server versions and the desktop versions of any of these Linux operating systems is that, the server version is a stripped down version if Linux. Why? Because they figured that if you are going to be installing a server, you know specifically what you want installed on the server. What this means is that there will be no graphical user interface in the operating system, and a lot of the tools that you use to administer Linux will not be installed automatically. They figured that if you want the tool and you are installing a server, then you know how to install the tool to the server yourself. If you are just beginning to learn Linux, you are probably better off at this point in time to download the desktop version. The desktop versions of these distributions give you the graphical user interface right off the bat. When you install the desktop version, you’ll immediately be able to navigate the operating system using the graphical user interface, much like Microsoft Windows or Mac OS. You will have desktop icons, folders that you can click on, etc. It’s going to function differently compared to Windows or Mac, so you still have to learn how to use Linux. But it’s going to be an environment that you are probably going to be able to understand as soon as you boot into it. After installing the desktop version, you are going to boot straight into a graphical environment. It is already going to have management tools installed, and you can play around and figure out how to use that graphical environment. That’s the main advantage of the desktop version over the server version of Linux.
Why Use Linux? The reason that you should learn Linux and start deploying Linux is for server functionality. Linux is incredibly rock-solid. Once you install Linux, and once you get through all the quirks and you set up all the configurations, a Linux server will run until the CPU overheats and dies. It would just run non-stop. A Linux server, once installed correctly, can run for a hundred and fifty days continuously without having any problems. Linux is totally unlike Windows where you have to reboot it weekly to avoid memory leaks or crashes. Linux, as long as you configure it properly, would just run and do its job day in and day out. The reason that you should look at deploying Linux is for server functionality, whether it is for Apache web servers, mySQL database servers, virtualization servers, email servers, etc. When you setup a Linux server, that thing is going to be rock-solid. You are not going to have the same problems that you have with Windows, where you install Windows in a computer today and works really great, but then you keep getting many updates. And two years from now, the computers are working slower because all the updates that Microsoft has delivered actually decreased the performance of the computer itself. This is not the case with Linux. Once you install Linux, it is going to do its job with the same efficiency as when you first installed it on your computer—as long as you configure it properly, of course. Linux is a really robust and efficient operating system. At this point, it is important that you have a good foundation and understanding of where exactly Linux came from, and what are some of its basic but important concepts.
Comments 0
Loading comments...
Reply to Comment
Edit Comment