Transcription of Linux Fundamentals
1 Linux FundamentalsA Training ManualPhilip Carinhas, of August 26, 2001 Copyright 2000-2001 Fortuitous Technologies, Technologies Hardy , Tx 78757 USAWWW: : training manual is a free book; you may reproduce and/or modify it under the termsof version 2 of the GNU General Public License as published by the Free Software Foun-dation whose website is located book is distributed in the hope it will be useful, but without any warranty; withouteven the implied warranty of merchantability or fitness for a particular author encourages wide distribution of this book for personal and commercial use,provided the above copyright notice remains intact and the method adheres to the provi-sions of the GNU General Public License located summary, you may copy and distribute this book free of charge or for a profit. No ex-plicit permission is required from the author for reproduction of this book in any medium,physical or , derivative works and translations of this document must be placed under the GNUG eneral Public License, and the original copyright notice must remain intact.
2 If you havecontributed new material to this book, you must make the source code ( , LATEX source) available for your Introduction to Linux Features .. Multi-User Operation .. Why Linux ? .. Conventions ..72 UNIXC ommand Line Logging In To Your Account .. Command Structure .. The Linux Manuals and themanUtility .. Create, List, Copy, and Move .. I/O, Redirection, and Pipes .. Command Line Editing ..183 The Linux TheUNIXS hell Game .. Bash .. Shell Variables .. Choosing the Right Path .. Groups and Newgrp ..274 Filesystem The Linux Virtual Filesystem (VFS) .. File Attributes .. Changing File Attributes withchmod.. Changing File Ownership withchownandchgrp.. Devices ..365 Process Creating Foreground and Background Processes.
3 Killing Processes Withkill.. Managing Process Priorities .. Cron ..45 Copyrightc 2001 Fortuitous Technologies, Text Editing Vi .. Editing WithPico.. Editing Withemacs.. Using Mail .. Regular Expressions ..547 Shell Shell Initialization Files .. Utility Shell Scripts .. General Scripting .. Script Automation ..658 Using Customizing the X Environment .. Window Managers ..699 TCP/IP Networking Network Communication .. Using X-Windows Over the Network .. Network Security for Users ..7910 NativeLinuxCompilers, Software, and Services81A Glossary85 Chapter 1 Introduction to LinuxLinuxis a computer operating system originally developed by Linus Torvalds as a researchproject. There is some interesting history about the rapidLinuxevolution, but suffice itto say,Linuxhas come a long way in a on Intel, Mac, Sun, Dec Alpha, and several other hardware Linux Features Linuxis a full-featured, 32-bit multi-user/multi-tasking OS.
4 Linuxadheres to the common (POSIX) standards forUNIX. Native TCP/IP support. A mature X Windows GUI interface. Complete development environment. C, C++, Java, editors, version control systems. Open Multi-User OperationInUNIXandLinux, all interactions with the OS are done through designated users ,who each have an identification ID (login name) and a differentusers to co-exist simultaneously and allows for different levels of most powerful user is called superuser or root , and has access to all files andprocesses. The superuser does many of the system management tasks like adding regularusers, file backups, system configuration users accounts, which perform non-system type tasks, have restricted accessto system-sensitive components to protectLinuxfrom being accidentally or purposelyCopyrightc 2001 Fortuitous Technologies, 1.
5 INTRODUCTION TO Linux damaged. In a moment you will enter a user account and start exploring Why Linux ? Linux can operate as a web, file, smb (WinNT), Novell, printer, ftp, mail, SQL, mas-querading, firewall, and POP server to name but a can act as a graphics, C, C++, Java, Perl, Python, SQL, audio, video, and documen-tation, development workstation ++/Java/Perl/DB Figure : Linux UsesLinux is a good solution for developers that need a stable and reliable platform that hasopen source code. Its not a good system for beginning developers that want a simple GUIinterface to a programming language, although Linux has many GUI software is ideal as a workstation also, and offers many customizable features not found inany other platform. It makes a good platform for dedicated workstaions that have limitedfunctions like in an educational or laboratory may not be ideal as a workstation for beginning users who want an instantly customiz-able universal WYSIWYG interface.
6 Other systems provide solutions for this need. Still, Linux becomes easier to use on a daily basis. It s only a matter of time until Linux isaccessible by 2001 Fortuitous Technologies, ConventionsIn order to take full advantage of this manual, students should execute every commandthat is listed in the text as well as do all the exercises. The following is a list of conventionssupported in this manual:<bash>:indicates a command entered in a terminal by the user. When you see this sign, youare expected to enter these commands exactly as indicated and check that the resultsare consistent with what is written. If you see a problem, please ask the instuctor toelaborate or clarify.<tcsh>:indicates commands in thetcshshell. Most of these commands are to be completedafter hours or at home. Since Linux advocates freedom of choice, we wish to makestudents aware of this option tobash.
7 <Super>:indicates a command entered by the System Administrator or Root. The student isalso expected to enter these commands in as a command entered at the prompts Bold TWis used to identify commands in the a file or a directory in the command TWindicates a screen text of command output or 2001 Fortuitous Technologies, 1. INTRODUCTION TO LINUX8 Copyrightc 2001 Fortuitous Technologies, 2 UNIXC ommand Line BasicsThe objective of this chapter is to configure the shell account so that printing, manuals,and editor functions are working normally. This will give us experience with the basiccommands, environment variables, and workhorse tools Logging In To Your AccountLog into your system with the login name and password given to you. You will seesomething like<bash>:Your system should always prompt you with the name of the shell (bash) and your loginname.
8 This is a customizable feature in thebashshell which you are now most basic command inLinuxis the directory listing ls can see the contents of your account by typing<bash>:ls -alYou should see files likedrwxr-xr-x 13 joe 1024 Nov 9 17:06 .dt-rwxr-xr-x 1 joe 5111 Sep 30 15:19 .dtprofiledrwxr--r-- 2 joe 96 Dec 1 12:25 .elm-rwxr--r-- 1 joe 1178 Nov 19 10:58 . Command StructureWe ve already seenlswhich give a directory listing the current working directory (cwd).Commands in Linux follow a general format:Command-optionsOther parametersCopyrightc 2001 Fortuitous Technologies, LINE BASICSfor example:<bash> comes the command name, followed by options. Options are normally precededby a dash or minus sign. There is always a space between the command and the commands use no options at all.
9 After the options comes any other parameters orinformations that command may s talk about some of the workhorse commands. Please note that these definitions arepurposely abbreviated and incomplete! Consult themanpages for each of the commandsbelow. In the commands below, parameters that are enclosed in square brackets [..] areoptional to that command. [-opts] refers to options in the style just Keys Strokes:qquits from many commands likemoreandlessCtrl+calso quits out of many commandsCtrl+Lclears the screenCtrl+aputs the cursor at the beginning of the command lineCtrl+eputs the cursor at the end of the command lineHelp, Search, Info Tools:env[-opts] [exp]Print environment or run a command with another [path] [exp]Find files inpathusingexpinfokeywordListinfohelp pages containingkeywordlocatekeywordLocate all files of namekeywordin a databaseman -kkeywordListmanpages withkeyword(same asaproposkeyword)mancommandDisplay the manual forcommandprintenvPrint environment variables (see set)set[vars]Print/Set environment vars and functionswhatiskeywordSearch thewhatisDB forkeywordwhereiscommandLocate source/binary and manuals forcommandwhichcommandDisplay path ofcommandText Manipulation Toolsawk|gawk[pgrm][file]Filterfilebypgr mcatfileDisplay contents offilewithout pagingclearClears the screen.
10 Same as Ctrl+Lgreppattern fileFindspatterninfileheadfileList the first few lines offilemorefileDisplay & page the textfile(Seeless)sed[script] fileStream edit/filterfileusingscripttail[-opts] fileList the trailing lines offiletrchars1 chars2 fileChange chars inchars1tochars2lessfileDisplay & page the textfile10 Copyrightc 2001 Fortuitous Technologies, THE Linux MANUALS AND THEMANUTILITYG eneral ToolscddirChange cwd to dir (home if dir omitted)chmodperms filesChange file permissions filesChange file owner and/or groupchshChange the default shellcp[-opts] f1 (f2|dir)Copy file f1 to f2 or directorydirdateDisplays the datekillpidKills process IDpidln[-opts] Old NewLinkOldtoNewlogin[username]Login to system with UIDusernamelprfilePrintfileon the default printerls[file]Listing forfile(cwdif file omitted)mkdirdirCreates directorydirmvfile1 file2 Rename file1 to file2passwd[-opt] usernameChange passwordps[-opts]Output a list of currently active processespwdList the current working directoryrmfilesRemovesfilesstartxStart the X-Windowing systemtar[-opt][arch][file]Manage tar archivestelnet[host [port]]Connect to the remotehostuname[-opts]Output name and version number of OSwhoList users logged into this systemxterm[-opts]Start a brand new X-terminal The Linux Manuals and themanUtilityVirtually every command that is worth knowing has an entry in themanpages, and isaccessed by doing aman command.