0% found this document useful (2 votes)
2K views890 pages

Command Line Pocket Administrator PDF

Pocket consultant

Uploaded by

srivatsan_ece
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (2 votes)
2K views890 pages

Command Line Pocket Administrator PDF

Pocket consultant

Uploaded by

srivatsan_ece
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 890
Windows William R. Stanek Author and Series Editor Administrator's ~ Pocket Consultant Acknowledgments Wanting to do something fundamentally different from how it's been done before turned out to be much harder than I ever thought—and, I hope, completely rewarding for you. You see, there are plenty of books for Windows administrators—and plenty of books for people who want to script Windows—but no one had sat down before and written an entire book on Windows administration from the command line that was truly focused on administration and not on the commands themselves. I hope that the result of all the hard work is that the book you hold in your hands is something unique. This isn't the kind of command-line book that says, "Here's the Edit command. You use this command to do this and this, and here are its parameters." Sure, some of that is included—as in any book for administrators—but this book focuses on using the command line in the context of everyday administration. It teaches you how to perform the daily administrative procedures and details how those procedures are implemented from the command line. So whether you want to learn how to manage daily operations, track Windows performance, view the event logs, partition disks, configure TCP/IP, or perform hundreds of others tasks, this book has the answers as they relate to the command line. As I've stated in Windows Server 2008 Administrator's Pocket Consultant (Microsoft Press 2008) and in Internet Information Services (IIS) 7.0 Administrator's Pocket Consultant (Microsoft Press, 2008), the team at Microsoft Press is top-notch. On this project, I worked with Karen Szall, Devon Musgrave, Maria Gargiulo, and others at Microsoft. They were all very helpful throughout the writing process. Thanks also to Martin DelRe for believing in my work and shepherding it through production. Unfortunately for the writer (but fortunately for readers), writing is only one part of the publishing process. Next came editing and author review. I must say, Microsoft Press has the most thorough editorial and technical review process I've seen anywhere—and I've written a lot of books for many different publishers. John Pierce was the project editor for the book and helped work the book through the editorial process. This was our first time working together, and it was a good experience. Jim Johnson was the technical editor for the book. Jim was also the technical editor for the first edition of the book, and it was good to work with him again. Becka McKay was the book's copy editor. I would also like to extend a personal thanks to Lucinda Rowley, Anne Hamilton, and Chris Nelson. They've helped out at many points of my writing career and been there when I needed them the most. Thank you! Thope I haven't forgotten anyone, but if I have, it was an oversight. Honest. ;-) Introduction Windows Command-Line Administrator's Pocket Consultant, Second Edition, is designed to be a concise and compulsively usable resource for Windows administrators. This is the readable resource guide that you'll want on your desk or in your pocket at all times. The book discusses everything you need to perform core administrative tasks using the Windows command line. Because the focus is directed toward providing you with maximum value in a pocket-sized guide, you don't have to wade through hundreds of pages of extraneous information to find what you're looking for. Instead, you'll find exactly what you need to get the job done. In short, the book is designed to be the one resource you consult whenever you have questions regarding Windows command-line administration. To this end, the book concentrates on daily administration procedures, frequently used tasks, documented examples, and options that are representative but not necessarily inclusive. The goal is to keep the content so concise that the book remains compact and easy to navigate, while ensuring that the book is packed with as much information as possible—making it a valuable resource. Thus, instead of a hefty 1,000-page tome or a lightweight 100-page quick reference, you get a valuable resource guide that can help you quickly and easily perform common tasks, solve problems, and implement such advanced administration areas as automated monitoring, memory leak analysis, disk partitioning, Active Directory management, and network troubleshooting. Find Additional Content Online As new or updated material becomes available that complements your book, it will be posted online on the Microsoft Press Online Windows Server and Client Web site. Based on the final build of Windows Server 2008, the type of material you might find includes updates to book content, articles, links to companion content, errata, sample chapters, and more. This Web site will be available soon at www.microsoft.com learning/books/online/serverclient, and will be updated periodically. Who Is This Book For? Windows Command-Line Administrator's Pocket Consultant, Second Edition, covers Windows Server 2008 and Windows Vista. The book is designed for: * Current Windows Server 2008 administrators * Support staff who maintain Windows Vista systems * Accomplished users who have some administrator responsibilities * Administrators upgrading to Windows Server from previous versions * Administrators transferring from other platforms To pack in as much information as possible, I had to assume that you have basic networking skills and a basic understanding of Windows, and that Windows is already installed on your systems. With this in mind, I don't devote entire chapters to understanding Windows architecture, installing Windows, or Windows startup and shutdown. I do, however, cover scheduling tasks, monitoring Windows systems, managing accounts, administering network services, and much more. Talso assume that you are fairly familiar with Windows commands and procedures as well as the Windows user interface. If you need help learning Windows basics, you should read the Windows documentation. How Is This Book Organized? Windows Command-Line Administrator's Pocket Consultant, Second Edition, is designed to be used in the daily administration of Windows systems, and as such the book is organized by job-related tasks rather than by Windows features. Speed and ease of reference is an essential part of this hands-on guide. The book has an expanded table of contents and an extensive index for finding answers to problems quickly. Many other quick reference features have been added as well. These features include quick step-by-step instructions, lists, tables with fast facts, and extensive cross-references. The book is organized into both parts and chapters. Part I reviews the fundamental tasks you need for command-line administration. Chapter | provides an overview of command-line administration tools, techniques, and concepts. Chapter 2 is designed to help you get the most out of the command shell. It details techniques for starting up the command shell using parameters, how to control command path settings, what redirection techniques are available, and how to use multiple commands in sequences. Chapter 3 discusses the essentials for creating command-line scripts. You'll learn how to set variables, work with conditional controls, and create procedures. Windows provides many command-line tools to help in the management of daily operations. Part II discusses the core tools and techniques you'll use to manage Windows systems. Chapter 4 explores techniques for configuring roles, role services, and features on Windows servers. Chapter 5 discusses many of the key administration tools, including those that help you gather system information, work with the Windows registry, configure Windows services, and shut down systems remotely Chapter 6 examines the logging tools available for Windows systems that can help you identify and track system problems, monitor applications and services, and maintain system security. You'll also learn how to write events to the system and application logs. In Chapter 7, you'll learn about tools and techniques for monitoring applications, examining processes, and maintaining performance. Chapter 8 provides techniques you can use to manage the way logging is performed, centralize event logging across the enterprise, and collect and generate reports on performance data. Chapter 9 discusses ways you can automate tasks to reduce the daily workload. The book continues with Part III. Users depend on hard disk drives to store their word-processing documents, spreadsheets, and other types of data. If you've worked with Windows Vista or Windows Server 2008 for any length of time, you've probably used the Disk Management tool. The command-line counterpart of Disk Management is the disk partition utility (DiskPart). You can use DiskPart to handle most disk management tasks as well as to perform some additional tasks that cannot be performed in the graphical user interface. Chapter 10 provides an introduction to DiskPart and also discusses FSUtil, ChkDsk, and CHKNTES. Chapter 11 discusses partitioning basic disks. Chapter 12 examines dynamic disks and how they are used. The chapter also examines implementing, managing, and troubleshooting RAID. Part IV concentrates on the core commands you'll use for configuring, managing, and troubleshooting Active Directory. Chapter 13 discusses many of the key directory services administration tools, including tools that help you gather directory information. Chapter 14 examines tools that help you create and manage computer accounts in Active Directory. You'll also learn how to configure domain controllers as global catalogs and operations masters. Chapter 15 discusses creating and managing accounts for users and groups in Active Directory. The final part, Part V examines network printing, TCP/IP networking, and related issues. Chapter 16 examines network printing and print services. Chapter 17 discusses configuring, maintaining, and troubleshooting TCP/IP networking from the command line. Appendix A provides a quick reference for command-line utilities discussed in the book. In Appendix B, you'll find a quick reference for the contexts and commands available when you are working with the network services shell (Netsh). You can use Netsh to manage the configuration of various network services on local and remote computers. Conventions Used in This Book I've used a variety of elements to help keep the text clear and easy to follow. You'll find code terms and listings in monospace type, except when I tell you to actually type a command. In that case, the command appears in bold type. When I introduce and define a new term, I put it in italics. Other conventions include: * Notes To provide details on a point that needs emphasis * Best Practices To examine the best technique to use when working with advanced configuration and administration concepts * Cautions To warn you when there are potential problems you should look out for * More Info To provide more information on the subject * Real World To provide real-world advice when discussing advanced topics * Security Alerts To point out important security issues * Tips To offer helpful hints or additional information I truly hope you find that Windows Command-Line Administrator's Pocket Consultant, Second Edition, provides everything that you need to perform essential administrative tasks as quickly and efficiently as possible. You're welcome to send your thoughts to me at [email protected]. Thank you. Support Every effort has been made to ensure the accuracy of this book. Microsoft Press provides corrections for books through the World Wide Web at the following address: http:/www.microsoft.com/mspress/support If you have comments, questions, or ideas about this book, please send them to Microsoft Press using either of the following methods: Postal Mail: Microsoft Press Attn: Editor, Windows Command-Line Administrator's Pocket Consultant, Second Edition One Microsoft Way Redmond, WA 98052-6399 E-mail: [email protected] Please note that product support isn't offered through these mail addresses. For support information, visit Microsoft's Web site at http://support.microsoft.com/. Part |. Windows Command-Line Fundamentals Chapter 1 Chapter 2 Chapter 3 Chapter 1. Overview of the Windows Command Line The command line is built into the Microsoft Windows operating system and is accessed through the command-shell window. Every version of Windows has had a built-in command line, used to run built-in commands, utilities, and scripts. Although the command line is powerful and versatile, some Windows administrators never use it. If you are happy using the graphical administration tools, you may be able to use them forever without ever having to do anything more than point and click, However, for proficient Windows administrators, skilled support staff, and committed power users, the Windows command line is inescapable. Knowing how to use the command line properly—including which command-line tools to use when and how to work with the tools effectively—can mean the difference between smooth-running operations and frequent problems. And if you're responsible for multiple domains or networks, learning the time-saving strategies that the command line offers is not just important—it's essential for sustaining day-to-day operations. In this chapter, I'll explain command line essentials, how to use built-in commands, how to run command-line utilities, and how to work with other support tools. Right up front I should tell you that Windows Vista and Windows Server 2008 have many more command-line tools available by default than their predecessors. In fact, many of the tools that were previously available only when you installed the Windows Support Tools and the Windows Server Resource Kit tools are now available by default. REAL WORLD As you read this chapter, and the rest of the book, keep in mind that this book is written for Windows Server 2008 and Windows Vista. Techniques that you learn in this book can be used on both operating systems unless otherwise noted. In some cases, you might be able to use the techniques discussed with other Windows operating systems, although the options or functions may vary. In any case, you should always test commands, options, and scripts before using them. The best way to do this is in a development or test environment where the systems with which you are working are isolated from the rest of the network Command Line Essentials Each new version of Windows has extended and enhanced the command ine. The changes have been dramatic, and they've not only improved the performance capabilities of the command line but its versatility as well Today you can do things with the Windows command line that you simply could not do in previous versions of Windows. To help you put the available options to use in the fastest, most productive manner, the discussion that follows explores command-shell options and configuration, in addition to providing tips for using the command history. Understanding the Windows Command Shell The most commonly used command line is the Windows command shell. The Windows command shell (Cmd.exe) is a 32-bit or 64-bit environment for working with the command line. On 32-bit versions of Windows, you'll find the 32-bit executable in the %SystemRoot%\System32 directory. On 64-bit versions of Windows, you'll find the 32-bit executable in the %SystemRoot%\SysWow64 directory and the 64-bit executable in the %SystemRoot”\System32 directory. Other command lines are available, such as the MS-DOS command shell (Command.com) and Windows PowerShell (powershell.exe) discussed later in this chapter. NOTE “oSystemRoot% refers to the SystemRoor environment variable. The Windows operating system has many environment variables, which are used to refer to user-specific and system-specific values. Often, I'll refer to environment variables using the standard Windows syntax %VariableName. You can start the command shell by using the Search box on the Start menu. Click Start, enter emd in the Search box, and then press Enter. Or you can click Start, point to All Programs, point to Accessories, and then choose Command Prompt. You can initialize the environment for the Windows command shell in several ways, including bypassing startup parameters to Cmd.exe or by using a custom startup file, which is placed in the %SystemRoot%\System32 directory. Figure 1-1 shows a command-shell window. By default, the command line is 80 characters wide and the command shell displays 25 lines of text. When additional text is to be displayed in the command-shell window or you enter commands and the command shell's window is full, the current text is displayed in the window and prior text is scrolled up. If you want to pause the display temporarily when a command is writing output, press Ctrl+S. Afterward, press Ctrl+S to resume or Ctrl+C to terminate execution. NOTE Custom startup files are used for MS-DOS programs that require special configurations. These files are named Autoexec.nt and Config.nt, and they are stored in the %SystemRoot%\System32 directory In this figure from Windows Server 2008, the display text is Microsoft Windows [Version 6.0.6001] (C) Copyright 2006 Microsoft Corporation. All rights reserved. c:\Users\williams> Figure 1-1. The command shell is the primary command-line window you'll use. Here, the command prompt for the command line shows the current working directory, which by default is %UserProfile%, meaning the user profile directory for the current user. A blinking cursor following the command prompt indicates the command line is in interactive mode. In interactive mode, you can type commands directly after the prompt and press Enter to execute them. For example, type dir and then press Enter to get a listing of the current directory. The command prompt also has a batch mode, which is used when executing a series of commands. In batch mode, the command prompt reads and executes commands one by one. Typically, batch commands are read from a script file, but batch commands can also be entered at the command prompt, such as when you use the FOR command to process each file in a set of files. (You'll learn more about batch scripts, loops, and command controls in Chapter 3.)

You might also like