Book Image

The Software Developer's Guide to Linux

By : David Cohen, Christian Sturm
5 (2)
Book Image

The Software Developer's Guide to Linux

5 (2)
By: David Cohen, Christian Sturm

Overview of this book

Developers are always looking to raise their game to the next level, yet most are completely lost when it comes to the Linux command line. This book is the bridge that will take you to the next level in your software development career. Most of the skills in the book can be immediately put to work to make you a more efficient developer. It’s written specifically for software engineers, not Linux system administrators, so each chapter will equip you with just enough theory to understand what you’re doing before diving into practical commands that you can use in your day-to-day work as a software developer. As you work through the book, you’ll quickly absorb the basics of how Linux works while you get comfortable moving around the command line. Once you’ve got the core skills, you’ll see how to apply them in different contexts that you’ll come across as a software developer: building and working with Docker images, automating boring build tasks with shell scripts, and troubleshooting issues in production environments. By the end of the book, you’ll be able to use Linux and the command line comfortably and apply your newfound skills in your day-to-day work to save time, troubleshoot issues, and be the command-line wizard that your team turns to.
Table of Contents (20 chapters)
18
Other Books You May Enjoy
19
Index

What this book covers

Chapter 1, How the Command Line Works, explains how a command-line interface works, what a shell is, and then immediately gives you some basic Linux skills. You’ll get a bit of theory and then begin moving around on the command line, finding and working with files and learning where to look for help when you get stuck. This chapter caters to new developers by teaching the most important command-line skills. If you read nothing else, you’ll still be better off than when you started.

Chapter 2, Working with Processes, will take you on a guided tour of Linux processes. You’ll then dive into useful, practical command-line skills for working with processes. We’ll add detail to a few aspects that are a common source of process-related problems that you’ll encounter as a software developer, like permissions, and give you some heuristics for troubleshooting them. You’ll also get a quick tour of some advanced topics that will come up again later in the book.

Chapter 3, Service Management with systemd, builds on the knowledge about processes learned in the previous chapter by introducing an additional layer of abstraction, the systemd service. You’ll learn about what an init system does for an operating system, and why you should care. Then, we cover all the practical commands you’ll need for working with services on a Linux system.

Chapter 4, Using Shell History, is a short chapter covering some tricks that you can learn to improve your speed and efficiency on the command line. These tricks revolve around using shortcuts and leveraging shell history to avoid repeated keystrokes.

Chapter 5, Introducing Files, introduces files as the essential abstraction through which to understand Linux. You’ll be introduced to the Filesystem Hierarchy Standard (FHS), which is like a map that you can use to orient yourself on any Unix system. Then it’s time for practical commands for working with files and directories in Linux, including some special filetypes you probably haven’t heard of. You’ll also get a taste of searching for files and file content, which is one of the most powerful bits of knowledge to have at your fingertips as a developer.

Chapter 6, Editing Files on the Command Line, introduces two text editors – nano and vim. You will learn the basics of using these text editors for command-line editing while also becoming aware of common editing mistakes and how to avoid them.

Chapter 7, Users and Groups, will introduce you to how the concepts of users and groups form the basis for the Unix security model, controlling access for resources like files and processes. We’ll then teach you the practical commands you’ll need to create and modify users and groups.

Chapter 8, Ownership and Permissions, builds on the previous chapter’s explanation of users and groups to show you how access control works for resources in Linux. This chapter teaches you about ownership and permissions by walking you through file information from a long listing. From there, we’ll look at the common file and directory permissions that you’ll encounter on production Linux systems, before engaging with the Linux commands for modifying file ownership and permissions.

Chapter 9, Managing Installed Software, shows you how to install software on various Linux distributions (and even macOS). First, we introduce package managers, which are the preferred way of getting software onto a machine: you’ll learn the important theory and practical commands for the package management operations you’ll need as a software developer. Then we’ll introduce a few other methods, like downloading install scripts and the time-honored, artisanal Unix tradition of compiling your own software locally, from source (it’s not as scary as it sounds!).

Chapter 10, Configuring Software, piggybacks off the previous chapter’s focus on installing software by helping you with configuring software on a Linux system. You will learn about the places that most software will look for configuration (“the configuration hierarchy”). Not only will this knowledge come in handy during late-night troubleshooting sessions, but it can actually help you to write better software. We’ll cover command-line arguments, environment variables, configuration files, and how all of this works on non-standard Linux environments like Docker containers. There’s even a little bonus project: you’ll see how to take a custom program and turn it into its own systemd service.

Chapter 11, Pipes and Redirection, will give you an introduction to what is possibly the “killer feature” of Unix: the ability to connect existing programs into a custom solution using pipes. We’ll move through the prerequisite theory and practical skills you need to understand: file descriptors and input/output redirection. Then you’ll jump into creating complex commands using pipes. You’ll be introduced to some essential CLI tools and practical pipe patterns, which you’ll still find yourself using long after you finish this book.

Chapter 12, Automating Tasks with Shell Scripts, serves as a Bash scripting crash course, teaching you how to go from typing individual commands in an interactive shell to writing scripts. We assume you’re already a software developer, so this will be a quick introduction that shows you the core language features and doesn’t spend a lot of time re-explaining the basics of programming. You’ll learn about Bash syntax, best practices for script writing, and some important pitfalls to avoid.

Chapter 13, Secure Remote Access with SSH, explores the Secure Shell Protocol and the related command-line tools available to you. You’ll learn the basics of public-key cryptography (PKI), which is always useful for a developer to know, before diving into creating SSH keys and securely logging into remote systems over the network. You’ll build on this knowledge and get some experience copying files over the network, using SSH to create ad-hoc proxies or VPNs, and see examples of various other tasks that involve moving data over an encrypted SSH tunnel.

Chapter 14, Version Control with Git, shows you how to use a tool you probably already know well – git – from the command line, instead of through your IDE or a graphical client. We quickly go through the basic theory behind git and then jump into the commands you’ll need to use in a command-line environment. We’ll cover two powerful features that it pays to understand – bisecting and rebasing – and then give you our take on best practices and useful shell aliases. Finally, the Poor man’s GitHub section presents a small but legitimately useful project that you can do to practice and integrate the Linux skills you’ve learned up to this point.

Chapter 15, Containerizing Applications with Docker, gives you the basic theory and practical skills that will make it easy to work with Docker as a developer. We’ll explore the problems that Docker solves, explain the most important Docker concepts, and take you through the core workflow and commands you’ll use. You’ll also see how to build your own images by containerizing a real application. And because we’re approaching this from a software development and Linux perspective, you’ll also develop a good intuition for how containerization works under the hood, and how it’s different from virtual machines.

Chapter 16, Monitoring Application Logs, gives an overview of logging on Unix and Linux. We’ll show you how (and where) logs are collected on most modern Linux systems using systemd, and how more traditional approaches work (you’ll come across both in the real world). You’ll build practical command-line skills finding and viewing logs and learn a bit about how logging is being done in larger infrastructures.

Chapter 17, Load Balancing and HTTP, covers the basics of HTTP for developers, with a special focus on the complexities that you’ll come across when working with HTTP services in larger infrastructures. We’ll correct some common misunderstandings about HTTP statuses, HTTP headers, and HTTP versions and how applications should handle them. We’ll also introduce how load balancers and proxies work in the real world, and how they make the experience of troubleshooting a live application quite different from troubleshooting a development version on your laptop. Many of the Linux skills that you will have learned up to this point will come in handy here, and we’ll introduce a new tool – curl – to help you troubleshoot a wide variety of HTTP-related issues.