ebook img

Linux in Action (MEAP - Early Edition) PDF

358 Pages·2018·12.97 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Linux in Action (MEAP - Early Edition)

MEAP Edition  Manning Early Access Program  Linux in Action  Version 5            Copyright 2018 Manning Publications      For more information on this and other Manning titles go to  www.manning.com  ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> welcome No matter what you do or how long you’ve been doing it in the IT or programming world, if you’re not learning new stuff, you’re probably not doing it right. It’s not just that the platforms and paradigms are constantly changing. Nor is it just that new business demands require fresh thinking. Or that the bad guys are constantly coming up with new ways to attack your severs. It’s all of those things and more. You simply can’t afford to stop learning. The trick is finding a way to learn the high-priority skills without turning the experience into a major detour. It’s my intention and desire that you should be able to read even a single chapter from Linux in Action and walk away feeling confident enough to take on something challenging and productive. Something you wouldn’t previously have even considered. If you hang around 'till the end, you’ll learn to work with critical and current technologies powering virtualization, disaster recovery, infrastructure security, data backup, web servers, DevOps, and system troubleshooting. But why Linux? Because Linux powers most of the internet, most scientific research, most commerce…most of the world’s servers. Those servers need to be provisioned, launched, secured, and managed effectively by smart and well trained people. "Smart" is what you bring to the table, but I think I can help with "well trained." Not sure you know enough about Linux to embark on such an ambitious project? Chapter 1 will quickly fill in the holes. After that, fasten your seat belt and prepare for a serious learning curve. I’m learning new things as I write each new chapter. I hope you’ll join me. And be in touch…your feedback will make this a much better book. —David Clinton PS Chapter 1 covers Linux fundamentals for newbies. If you know the basics, feel free to skip to Chapter 2 and start your journey there. ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> brief contents 0 Front Matter 1 Welcome to Linux 2 Linux virtualization: building a safe and simple Linux working environment 3 Remote connectivity: safely access networked machines 4 Archive management: backup or copy entire filesystems 5 Automated administration: configure automated offsite backups 6 Emergency tools: build a system recovery device 7 Web servers - build a MediaWiki server 8 Networked file sharing - build a Nextcloud file sharing server 9 Securing your web server 10 Securing your network connections - create a VPN or DMZ 11 System monitoring - working with log files 12 Sharing data over a private network 13 Troubleshooting system performance issues 14 Troubleshooting network issues 15 Troubleshooting peripheral devices 16 DevOps tools: deploy a scripted server environment using Ansible ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 1 1 Welcome to Linux This chapter covers: • What makes Linux different • Basic survival skills • Getting help This is a book that turns technology training sideways. That is, while other books, courses, and online resources organize their content around skills, I’m going to use real-world projects as teaching tools. Each of the core skills and the functionality of Linux systems will be covered - and covered well - but only when needed for a project. When you’re done, you’ll have learned everything you would have from a traditional source, but you will also know how to perform more than a dozen vital and sophisticated administration tasks…and be comfortable tackling dozens more. The first two or three chapters will quickly guide you through your first anxious introduction to the world of Linux servers. After that, you’ll work through - and adapt - practical hands-on projects and nothing but practical hands-on projects. Through those projects, you will learn more than just commands and skills. Get ready to push deeper and eventually create solutions to your own business problems. No single book can anticipate all the challenges that readers will face through their careers. But by demonstrating how to approach real-world problems using real- world tools (including research tools), this book will make it a whole lot easier for you to leverage the vast resources available through both inline documentation and the internet. If your prior Linux experience is very limited, this first chapter will introduce you to some basic command line survival skills and point you to places you can go for ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 2 help when things don’t work. I should note that through this (and every) chapter, you are strongly encouraged to try everything out for yourself. There’s no better way to really get to the core of an IT skill than actually doing it, realizing that it’s not working the way you expected, and playing with it until it becomes yours forever. Good luck and have fun! 1.1 What makes Linux different from other operating systems Well it is free, which means it’s a lot easier to install it exactly where and when you need it for any use you can dream up. Not having to worry about purchasing site licenses and jumping through Digital Rights Management hoops certainly makes testing out all kinds of hardware combinations and server configurations a lot more straightforward. Linux makes it possible to do all kinds of really useful and creative things. For instance, you can load a Linux "live boot" image on a USB stick, boot a PC whose own hard disk has been corrupted, and troubleshoot and fix the problem. Or, because Linux is a true multi-user operating system, whole teams can concurrently do their work - locally or remotely - confident in the privacy and stability of the system. Linux also provides sophisticated software package management systems that reliably install and maintain any of the thousands of free software applications available through online curated repositories. But beyond free, Linux is open source, which means anyone can take the code base and reshape it into anything they want. Practically, this has spawned a vast ecosystem of specialty Linux distributions. A distribution (sometimes shortened to "distro") is a customized stack of software that’s packaged along with the Linux kernel and distributed with tools for installing a working version of Linux of user computers. Here’s a very incomplete distro list to illustrate the kinds of things that are available: Purpose Distribution Security/anti-hacking Kali Linux Parrot Consumer desktop Mint Elementary OS Lightweight (old hardware; diagnostics) Puppy Linux LXLE Internet of Things administration Snappy Ubuntu Core Enterprise server room CentOS (community version of Red Hat Enterprise ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 3 Linux) OpenSUSE (community version of SUSE) Cloud computing Amazon Linux (AWS AMI) Ubuntu Server (AWS AMI) All-purpose (except lightweight) Ubuntu Can’t find what you’re after? Create your own. Need help? There’s a very large and active community online where, if someone hasn’t already solved your problem, they’ll know where to go to get it done. More than anything else, I’d say it’s the community-based resources that really make Linux so powerful. 1.2 Basic survival skills Before we get started with the enterprise-ready projects that will make up the rest of the book, it’s worthwhile making sure that we’re all starting off at the same spot. So this chapter will cover the Linux basics; the Unix Filesystem Hierarchy Standard (including pseudo file systems), navigation (ls, pwd and cd), file management tools (cat, less, touch, mkdir, rmdir, rm, cp and mv), some tricks (like tab completion and file globbing), sudo, and where to turn for help (man, info, and journalctl). It’s very possible that you’ve got enough experience already that you won’t need any of that material, so feel free to skip the chapter altogether. Don’t worry about the rest of us. We’ll catch up. I’m not going to spend time talking about how to install Linux on your PC. It’s not because installation is so ridiculously simple that it’s too embarrassing to even discuss - it can sometimes actually get quite complicated. Rather, it’s because the approach you choose will depend on your specific circumstances. Describing one possibility - or even half a dozen - would do nothing more than annoy the 75% of you for whom those won’t work. Need some help getting started? Check out Manning’s own "Learn Linux in a Month of Lunches." Encountering a particular installation issue? Take a minute to write out a brief but detailed description and then use it to search the internet for help. Looking for a laptop or desktop with Linux pre-installed? Search the internet for "pc with Linux preinstalled". Have some unused hardware and a USB stick? Search for "install Linux from usb". Prefer to install Linux as a virtual machine? Smart move. Stick around for chapter 2. 1.2.1 The Linux file system Where should we begin? It’s often said that everything in Linux works through plain text files, so it will probably make the most sense to start by understanding the Linux file system. But just what, before we even get to Linux, is a file system? I guess you can think of it as an index that creates apparent connections between individual files and groups of files with identifiable locations on a disk. Figure 1.1 ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 4 can help you visualize how data spread across a disk partition can be exposed to system users within a directory structure. Figure 1.1. Raw data on storage devices can be visually represented as organized directory hierarchies. Why would you need an index? A digital storage device - like a hard drive or USB device - isn’t divided into physical divisions that can be used as organizing folders (or, directories, as they’re known in Linux circles). Not only may one particular file reside in a location on the actual media that’s a great distance away from another, nearly identical file created minutes or seconds later, but all the parts of a single file itself might not even be contiguous. Not only that, but its geographic location on the disk won’t necessarily remain static over time. So if you want your data to be reliably retrievable, you’ll need some kind of index that can consistently point you to the resources you’re after. A file system uses such an index to provide the appearance of an organized set of directories and files within a single disk division known as a partition. ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 5 Just in case you need to dig deeper on your own at sometime, it will be useful to know that, these days, the most commonly used Linux file system is ext4. But Linux can also work with storage drives that were formatted using file systems from other platforms like FAT32 and NTFS. The Unix Filesystem Hierarchy Standard All the files in a disk partition are kept in directories lying beneath the root directory, which is represented by the / character. The way these directories are arranged is largely governed by the Unix File system Hierarchy Standard (FHS), so you’re going to see pretty much the same basic layout whether you’re using a Linux distribution, Unix, or even macOS. Figure 1.2 shows some of the most-used, top-level directories. Figure 1.2. Common top-level directories as defined by the Unix Filesystem Hierarchy Standard Top-level directories - those directories located directly beneath the root - include /etc/, which contains configuration files that define the way individual programs and services function, and /var, where variable files belonging to the system or ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]> 6 individual applications whose content changes frequently through the course of normal system activities are kept. You’ll also want to know about the /home directory beneath which individual users are given directories for their private files. 1.2.2 Getting around: Linux navigation tools Here is where you’ll learn the five most basic, must-have Linux navigation commands (ls, pwd, cd, cat, and less). Since the command line is not a particularly visual environment, no matter what you’re trying to do, you’re going to rely a great deal on these five tools to orient yourself. I hope it’s obvious that you should be trying each of these tools out for yourself on your own computers. That’s the only way you’ll learn. Just to make sure we’re all on the same screen, the rest of the book will require a command line terminal of one sort or another. Unfortunately, there’s no single way to open a new terminal window that will work in all Linux distributions. The terminal’s location in the Ubuntu menu system won’t necessarily match that of Fedora or Mint. And Ubuntu itself? Well that kind of depends on which version you’re running. The CTRL-ALT-t keyboard combination should work in at least most environments, as will looking through the application menus searching for an item with "terminal" in the name. By default, once your terminal opens, your home directory (/home/yourname/) will be active. ls (list) No point hanging around the terminal if you can’t see what’s there. You can list the names of the files and subdirectories in your current directory using ls. ls with the l flag will list not only the object names, but their file permissions, owner, group, file size, and time stamp. Adding a directory designation - like the /var/ - will tell ls to display the contents of that directory. $ ls -l /var total 40 drwxr-xr-x 2 root root 4096 May 3 06:25 backups drwxr-xr-x 11 root root 4096 Jan 17 21:16 cache drwxr-xr-x 39 root root 4096 Jan 17 21:16 lib drwxrwsr-x 2 root staff 4096 Apr 12 2016 local lrwxrwxrwx 1 root root 9 Aug 12 2016 lock -> /run/lock drwxrwxr-x 7 root syslog 4096 May 3 06:25 log drwxrwsr-x 2 root mail 4096 Aug 12 2016 mail drwxr-xr-x 2 root root 4096 Aug 12 2016 opt lrwxrwxrwx 1 root root 4 Aug 12 2016 run -> /run drwxr-xr-x 5 root root 4096 Jan 17 21:16 spool drwxrwxrwt 2 root root 4096 Nov 7 2016 tmp drwxr-xr-x 3 root root 4096 Sep 11 2016 www On some systems, ll will be available to do the work of ls -l but with fewer keystrokes. ©Manning Publications Co. We welcome reader comments about anything in the manuscript - other than typos and other simple mistakes. These will be cleaned up during production of the book by copyeditors and proofreaders. https://forums.manning.com/forums/linux-in-action Licensed to Liam Paris <[email protected]>

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.