old-www/LDP/intro-linux/html/sect_03_05.html

893 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>Summary</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Introduction to Linux"
HREF="index.html"><LINK
REL="UP"
TITLE="About files and the file system"
HREF="chap_03.html"><LINK
REL="PREVIOUS"
TITLE="File security"
HREF="sect_03_04.html"><LINK
REL="NEXT"
TITLE="Exercises"
HREF="sect_03_06.html"></HEAD
><BODY
CLASS="sect1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>Introduction to Linux: </TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="sect_03_04.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 3. About files and the file system</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sect_03_06.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="sect1"
><H1
CLASS="sect1"
><A
NAME="sect_03_05"
></A
>3.5. Summary</H1
><P
>On UNIX, as on Linux, all entities are in some way or another presented to the system as files with the appropriate file properties. Use of (predefined) paths allows the users and the system admin to find, read and manipulate files.</P
><P
>We've made our first steps toward becoming an expert: we discussed the real and the fake structure of the file system, and we know about the Linux file security model, as well as several other security precautions that are taken on every system by default.</P
><P
>The shell is the most important tool for interaction with the system. We learned several shell commands in this chapter, which are listed in the table below.</P
><DIV
CLASS="table"
><A
NAME="AEN4247"
></A
><P
><B
>Table 3-10. New commands in chapter 3: Files and the file system</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>Command</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>Meaning</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>bash</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>GNU shell program.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>cat <TT
CLASS="filename"
>file(s)</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Send content of file(s) to standard output.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>cd <TT
CLASS="filename"
>directory</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Enter <TT
CLASS="filename"
>directory</TT
>. <B
CLASS="command"
>cd</B
> is a <B
CLASS="command"
>bash</B
> built-in command.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>chgrp <TT
CLASS="parameter"
><I
>newgroup</I
></TT
> <TT
CLASS="filename"
>file(s)</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Change the group ownership of <TT
CLASS="filename"
>file(s)</TT
> to <EM
>newgroup</EM
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>chmod <TT
CLASS="parameter"
><I
>mode</I
></TT
> <TT
CLASS="filename"
>file(s)</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Change access permissions on <TT
CLASS="filename"
>file(s)</TT
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>chown <TT
CLASS="parameter"
><I
>newowner</I
></TT
>[<SPAN
CLASS="optional"
>:[<SPAN
CLASS="optional"
>newgroup</SPAN
>]</SPAN
>] <TT
CLASS="filename"
>file(s)</TT
> </B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Change file owner and group ownership.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>cp <TT
CLASS="filename"
>sourcefile</TT
> <TT
CLASS="filename"
>targetfile</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Copy <TT
CLASS="filename"
>sourcefile</TT
> to <TT
CLASS="filename"
>targetfile</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>df <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Reports on used disk space on the partition containing <TT
CLASS="filename"
>file</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>echo <TT
CLASS="parameter"
><I
>string</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Display a line of text</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>export</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Part of <B
CLASS="command"
>bash</B
> that announces variables and their values to the system.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>file <TT
CLASS="filename"
>filename</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Determine file type of <TT
CLASS="filename"
>filename</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>find <TT
CLASS="parameter"
><I
>path</I
></TT
> <TT
CLASS="parameter"
><I
>expression</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Find files in the file system hierarchy</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>grep <TT
CLASS="parameter"
><I
>PATTERN</I
></TT
> <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Print lines in <TT
CLASS="filename"
>file</TT
> containing the search pattern.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>head <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Send the first part of <TT
CLASS="filename"
>file</TT
> to standard output</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>id</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Prints real and effective user name and groups.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>info <TT
CLASS="parameter"
><I
>command</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Read documentation about <B
CLASS="command"
>command</B
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>less <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>View <TT
CLASS="filename"
>file</TT
> with a powerful viewer.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>ln <TT
CLASS="filename"
>targetfile</TT
> <TT
CLASS="filename"
>linkname</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Make a link with name <TT
CLASS="filename"
>linkname</TT
> to <TT
CLASS="filename"
>targetfile</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>locate <TT
CLASS="parameter"
><I
>searchstring</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Print all accessible files matching the search pattern.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>ls <TT
CLASS="filename"
>file(s)</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Prints directory content.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>man <TT
CLASS="parameter"
><I
>command</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Format and display online (system) manual pages for <B
CLASS="command"
>command</B
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>mkdir <TT
CLASS="filename"
>newdir</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Make a new empty directory.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>mv <TT
CLASS="filename"
>oldfile</TT
> <TT
CLASS="filename"
>newfile</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Rename or move <TT
CLASS="filename"
>oldfile</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>newgrp <TT
CLASS="parameter"
><I
>groupname</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Log in to a new group.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>pwd</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Print the present or current working directory.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>quota</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Show disk usage and limits.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>rm <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Removes files and directories.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>rmdir <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Removes directories.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>tail <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Print the last part of <TT
CLASS="filename"
>file</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>umask [<SPAN
CLASS="optional"
><TT
CLASS="parameter"
><I
>value</I
></TT
></SPAN
>]</B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Show or change new file creation mode.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>wc <TT
CLASS="filename"
>file</TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Counts lines, words and characters in <TT
CLASS="filename"
>file</TT
>.</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
><B
CLASS="command"
>which <TT
CLASS="parameter"
><I
>command</I
></TT
></B
></TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>Shows the full path to <B
CLASS="command"
>command</B
>.</TD
></TR
></TBODY
></TABLE
></DIV
><P
>We also stressed the fact that you should READ THE MAN PAGES. This documentation is your first-aid kit and contains the answers to many questions. The above list contains the basic commands that you will use on a daily basis, but they can do much more than the tasks we've discussed here. Reading the documentation will give you the control you need.</P
><P
>Last but not least, a handy overview of file permissions:</P
><DIV
CLASS="table"
><A
NAME="AEN4445"
></A
><P
><B
>Table 3-11. File permissions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><THEAD
><TR
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>Who\What</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>r(ead)</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>w(rite)</TH
><TH
ALIGN="LEFT"
VALIGN="MIDDLE"
>(e)x(ecute)</TH
></TR
></THEAD
><TBODY
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>u(ser)</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>4</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>2</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>1</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>g(roup)</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>4</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>2</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>1</TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>o(ther)</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>4</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>2</TD
><TD
ALIGN="LEFT"
VALIGN="MIDDLE"
>1</TD
></TR
></TBODY
></TABLE
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="sect_03_04.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="sect_03_06.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>File security</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chap_03.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Exercises</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>