953 lines
38 KiB
HTML
953 lines
38 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
|
|
|
<title>Debian Tutorial (Obsolete Documentation) - More on files</title>
|
|
|
|
<link href="index.html" rel="start">
|
|
<link href="ch-shell.html" rel="prev">
|
|
<link href="ch-editor.html" rel="next">
|
|
<link href="index.html#contents" rel="contents">
|
|
<link href="index.html#copyright" rel="copyright">
|
|
<link href="ch-about.html" rel="chapter" title="1 About this manual">
|
|
<link href="ch-introduction.html" rel="chapter" title="2 Introduction">
|
|
<link href="ch-start.html" rel="chapter" title="3 Getting started">
|
|
<link href="ch-basics.html" rel="chapter" title="4 The Basics">
|
|
<link href="ch-docs.html" rel="chapter" title="5 Reading documentation and getting help">
|
|
<link href="ch-shell.html" rel="chapter" title="6 Using the shell">
|
|
<link href="ch-files.html" rel="chapter" title="7 More on files">
|
|
<link href="ch-editor.html" rel="chapter" title="8 Creating and editing text files">
|
|
<link href="ch-custom_shell.html" rel="chapter" title="9 Customizing the shell">
|
|
<link href="ch-X.html" rel="chapter" title="10 The X Window System">
|
|
<link href="ch-text_tools.html" rel="chapter" title="11 Text tools">
|
|
<link href="ch-file_tools.html" rel="chapter" title="12 File tools">
|
|
<link href="ch-disks.html" rel="chapter" title="13 Using disks">
|
|
<link href="ch-dpkg.html" rel="chapter" title="14 Removing and installing software">
|
|
<link href="ch-troubleshooting.html" rel="chapter" title="15 Troubleshooting">
|
|
<link href="ch-advanced.html" rel="chapter" title="16 Advanced topics">
|
|
<link href="ch-next.html" rel="chapter" title="17 Where to from here?">
|
|
<link href="ch-helping.html" rel="chapter" title="18 Contributing to Debian: How can I help?">
|
|
<link href="ap-apps_appendix.html" rel="appendix" title="A A brief survey of available applications">
|
|
<link href="ap-components_appendix.html" rel="appendix" title="B Summary of GNU/Linux system components">
|
|
<link href="ap-booting_appendix.html" rel="appendix" title="C Appendix C: Booting the system">
|
|
<link href="ap-misc_appendix.html" rel="appendix" title="D Miscellaneous">
|
|
<link href="ch-about.html#s-acknowldgements" rel="section" title="1.1 Acknowledgements">
|
|
<link href="ch-introduction.html#s-introduction-debian" rel="section" title="2.1 What is Debian?">
|
|
<link href="ch-introduction.html#s-introduction-DFSG" rel="section" title="2.2 What's free software?">
|
|
<link href="ch-introduction.html#s-introduction-how" rel="section" title="2.3 How to Read This Book">
|
|
<link href="ch-introduction.html#s-introduction-ldp" rel="section" title="2.4 The Linux Documentation Project">
|
|
<link href="ch-start.html#s-start-multi" rel="section" title="3.1 A multiuser, multitasking operating system">
|
|
<link href="ch-start.html#s-start-login" rel="section" title="3.2 Logging in">
|
|
<link href="ch-start.html#s-start-keys" rel="section" title="3.3 Keys">
|
|
<link href="ch-start.html#s-start-commandline" rel="section" title="3.4 Command history and editing the command line">
|
|
<link href="ch-start.html#s-start-root" rel="section" title="3.5 Logging in as root">
|
|
<link href="ch-start.html#s-start-VC" rel="section" title="3.6 Virtual consoles">
|
|
<link href="ch-start.html#s-start-shutdown" rel="section" title="3.7 Shutting down">
|
|
<link href="ch-basics.html#s-basics-commandline" rel="section" title="4.1 The command line and <samp>man</samp> pages">
|
|
<link href="ch-basics.html#s-basics-files" rel="section" title="4.2 Files and Directories">
|
|
<link href="ch-basics.html#s-basics-processes" rel="section" title="4.3 Processes">
|
|
<link href="ch-basics.html#s-basics-shell" rel="section" title="4.4 The shell">
|
|
<link href="ch-basics.html#s-basics-jobs" rel="section" title="4.5 Managing processes with Bash">
|
|
<link href="ch-basics.html#s-basics-bash" rel="section" title="4.6 A few Bash features">
|
|
<link href="ch-basics.html#s-basics-identity" rel="section" title="4.7 Managing your identity">
|
|
<link href="ch-docs.html#s-docs-sources" rel="section" title="5.1 Kinds of documentation">
|
|
<link href="ch-docs.html#s-docs-info" rel="section" title="5.2 Using info">
|
|
<link href="ch-docs.html#s-docs-textfiles" rel="section" title="5.3 Viewing text files with more and less">
|
|
<link href="ch-docs.html#s-docs-howtos" rel="section" title="5.4 HOWTOs">
|
|
<link href="ch-docs.html#s-docs-support" rel="section" title="5.5 Getting help from a person">
|
|
<link href="ch-docs.html#s-docs-sysinfo" rel="section" title="5.6 Getting information from the system">
|
|
<link href="ch-shell.html#s-shell-variables" rel="section" title="6.1 Environment variables">
|
|
<link href="ch-shell.html#s-shell-path" rel="section" title="6.2 Where commands live: the <samp>PATH</samp> variable">
|
|
<link href="ch-shell.html#s-custom_shell-aliases" rel="section" title="6.3 Aliases and shell functions">
|
|
<link href="ch-shell.html#s-shell-io" rel="section" title="6.4 Controlling input and output">
|
|
<link href="ch-shell.html#s-shell-modifiers" rel="section" title="6.5 Specifying how and when to run commands">
|
|
<link href="ch-shell.html#s-shell-wildcards" rel="section" title="6.6 Filename expansion ("Wildcards")">
|
|
<link href="ch-shell.html#s6.7" rel="section" title="6.7 Interactive/non-interactive">
|
|
<link href="ch-files.html#s-files-permissions" rel="section" title="7.1 Permissions">
|
|
<link href="ch-files.html#s-files-tour" rel="section" title="7.2 What files are on my system? Where can I put my own files?">
|
|
<link href="ch-files.html#s-file-manager" rel="section" title="7.3 Using a filemanager">
|
|
<link href="ch-editor.html#s-editor-textfile" rel="section" title="8.1 What's a text file?">
|
|
<link href="ch-editor.html#s-editor-editor" rel="section" title="8.2 Text editors">
|
|
<link href="ch-editor.html#s-editor-vi" rel="section" title="8.3 Creating and editing a text file with <code>vi</code>">
|
|
<link href="ch-custom_shell.html#s-custom_shell-dotfiles" rel="section" title="9.1 .rc files and <samp>ls -a</samp>">
|
|
<link href="ch-custom_shell.html#s-custom_shell-etc" rel="section" title="9.2 System-wide vs. user-specific configuration">
|
|
<link href="ch-X.html#s-X-starting" rel="section" title="10.1 Starting the X environment">
|
|
<link href="ch-X.html#s-X-intro" rel="section" title="10.2 Intro: What is X">
|
|
<link href="ch-X.html#s-X-basics" rel="section" title="10.3 Basic X operations">
|
|
<link href="ch-X.html#s-X-startup" rel="section" title="10.4 Customizing your X startup">
|
|
<link href="ch-text_tools.html#s-text_tools-regexps" rel="section" title="11.1 Regular expressions">
|
|
<link href="ch-file_tools.html#s-file_tools-backup" rel="section" title="12.1 Backup tools">
|
|
<link href="ch-file_tools.html#s-file_tools-compression" rel="section" title="12.2 File compression with <samp>gzip</samp>">
|
|
<link href="ch-file_tools.html#s-file_tools-split" rel="section" title="12.3 Splitting files into smaller pieces">
|
|
<link href="ch-file_tools.html#s-file_tools-find" rel="section" title="12.4 Finding files">
|
|
<link href="ch-file_tools.html#s-file_tools-file" rel="section" title="12.5 Determining a file's contents">
|
|
<link href="ch-disks.html#s-disks-concepts" rel="section" title="13.1 Concepts">
|
|
<link href="ch-disks.html#s-disks-mount" rel="section" title="13.2 <samp>mount</samp> and <samp>/etc/fstab</samp>">
|
|
<link href="ch-disks.html#s-network-ppp" rel="section" title="13.3 PPP">
|
|
<link href="ch-dpkg.html#s-dpkg-dpkg" rel="section" title="14.1 The <code>dpkg</code> package utility">
|
|
<link href="ch-dpkg.html#s-dpkg-what" rel="section" title="14.2 What a package maintenance utility does">
|
|
<link href="ch-dpkg.html#s-dpkg-apt" rel="section" title="14.3 Apt">
|
|
<link href="ch-dpkg.html#s-dpkg-dselect" rel="section" title="14.4 Using dselect.">
|
|
<link href="ch-dpkg.html#s-dpkg-commandline" rel="section" title="14.5 Using dpkg manually">
|
|
<link href="ch-dpkg.html#s-dpkg-compiling" rel="section" title="14.6 Compiling software yourself">
|
|
<link href="ch-dpkg.html#s-dpkg-proprietary" rel="section" title="14.7 Proprietary software not in .deb format">
|
|
<link href="ch-troubleshooting.html#s-troubleshooting-frozen" rel="section" title="15.1 Debian is frozen or crashed!">
|
|
<link href="ch-troubleshooting.html#s-troubleshooting-termgarbage" rel="section" title="15.2 My terminal isn't behaving properly">
|
|
<link href="ch-troubleshooting.html#s-troubleshooting-vi" rel="section" title="15.3 The computer beeps when I press a key, and my screen shows a text file and/or a lot of <samp>~</samp> symbols.">
|
|
<link href="ch-advanced.html#s-advanced-scripting" rel="section" title="16.1 Introduction to shell scripting">
|
|
<link href="ch-advanced.html#s-advanced-files" rel="section" title="16.2 Advanced files">
|
|
<link href="ch-advanced.html#s-advanced-kernel" rel="section" title="16.3 Compiling the kernel">
|
|
<link href="ch-advanced.html#s-advanced-security" rel="section" title="16.4 A few words on security">
|
|
<link href="ch-advanced.html#s-advanced-programming" rel="section" title="16.5 Programming on Linux">
|
|
<link href="ch-next.html#s-next-manuals" rel="section" title="17.1 Other Debian manuals to read">
|
|
<link href="ch-next.html#s-next-resources" rel="section" title="17.2 Other resources">
|
|
<link href="ch-helping.html#s-helping-bugs" rel="section" title="18.1 Submit bug reports">
|
|
<link href="ch-helping.html#s-helping-other" rel="section" title="18.2 Other things">
|
|
<link href="ap-apps_appendix.html#s-A_apps-whatever" rel="section" title="A.1 (Subheadings could copy the structure of the menu system)">
|
|
<link href="ap-misc_appendix.html#s-unix-history" rel="section" title="D.1 Unix History">
|
|
<link href="ap-misc_appendix.html#sD.2" rel="section" title="D.2 GNU/Linux History">
|
|
<link href="ap-misc_appendix.html#sD.3" rel="section" title="D.3 The Linux kernel's version numbering">
|
|
<link href="ch-introduction.html#s-introduction-debian-os" rel="subsection" title="2.1.1 What's an operating system, and what sort of operating system is Debian?">
|
|
<link href="ch-introduction.html#s-introduction-debian-how" rel="subsection" title="2.1.2 Who creates Debian?">
|
|
<link href="ch-basics.html#s-basics-commandline-description" rel="subsection" title="4.1.1 Describing the command line">
|
|
<link href="ch-basics.html#s-basics-files-intro" rel="subsection" title="4.2.1 Introduction to files">
|
|
<link href="ch-basics.html#s-basics-files-using" rel="subsection" title="4.2.2 Using files: a tutorial">
|
|
<link href="ch-basics.html#s-basics-bash-completion" rel="subsection" title="4.6.1 Tab Completion">
|
|
<link href="ch-docs.html#s-docs-support-posting" rel="subsection" title="5.5.1 Dos and Don'ts of asking a question">
|
|
<link href="ch-shell.html#s-shell-variables-parents" rel="subsection" title="6.1.1 Parent and child processes">
|
|
<link href="ch-shell.html#s-interactive-shells" rel="subsection" title="6.7.1 Interactive shells">
|
|
<link href="ch-files.html#s-files-permissions-groups" rel="subsection" title="7.1.1 File Ownership">
|
|
<link href="ch-files.html#s-files-permissions-mode" rel="subsection" title="7.1.2 Mode">
|
|
<link href="ch-files.html#s-files-permissions-tutorial" rel="subsection" title="7.1.3 Permissions in practice">
|
|
<link href="ch-editor.html#s-editor-vi-creating" rel="subsection" title="8.3.1 Creating a file">
|
|
<link href="ch-editor.html#s-editor-vi-editing" rel="subsection" title="8.3.2 Editing an existing file">
|
|
<link href="ch-editor.html#s-editor-vi-editing-movement" rel="subsection" title="8.3.2.1 Moving around in a file">
|
|
<link href="ch-editor.html#s-editor-vi-editing-deletion" rel="subsection" title="8.3.2.2 Deleting text">
|
|
<link href="ch-editor.html#s-editor-vi-editing-moremoving" rel="subsection" title="8.3.2.3 Sophisticated movement">
|
|
<link href="ch-editor.html#s-editor-vi-editing-numbers" rel="subsection" title="8.3.2.4 Repeating commands">
|
|
<link href="ch-editor.html#s-editor-vi-editing-advanced" rel="subsection" title="8.3.2.5 Advanced reference">
|
|
<link href="ch-X.html#s-X-basics-mouse" rel="subsection" title="10.3.1 The mouse">
|
|
<link href="ch-X.html#s-X-basics-clients" rel="subsection" title="10.3.2 X clients">
|
|
<link href="ch-X.html#s-X-basics-trouble" rel="subsection" title="10.3.3 Troubleshooting">
|
|
<link href="ch-X.html#s-X-basics-leaving" rel="subsection" title="10.3.4 Leaving the X environment">
|
|
<link href="ch-disks.html#s-disks-mount-mounting" rel="subsection" title="13.2.1 Mounting a filesystem">
|
|
<link href="ch-disks.html#s-disks-mount-cdromexample" rel="subsection" title="13.2.2 Example: Mounting a CD-ROM">
|
|
<link href="ch-disks.html#s-disks-mount-fstab" rel="subsection" title="13.2.3 <samp>/etc/fstab</samp>: Automating the mount process">
|
|
<link href="ch-disks.html#s-disks-mount-removable" rel="subsection" title="13.2.4 Removable disks (floppies, Zip disks, etc.)">
|
|
<link href="ch-disks.html#s-network-ppp-introduction" rel="subsection" title="13.3.1 Introduction">
|
|
<link href="ch-disks.html#s-network-ppp-preparation" rel="subsection" title="13.3.2 Preparation">
|
|
<link href="ch-disks.html#s-network-ppp-wvdial" rel="subsection" title="13.3.3 The Easy Way: <samp>wvdial</samp>">
|
|
<link href="ch-disks.html#s-network-ppp-pppd" rel="subsection" title="13.3.4 Doing It Manually">
|
|
<link href="ch-dpkg.html#s-apt-config" rel="subsection" title="14.3.1 Configuring Apt">
|
|
<link href="ch-dpkg.html#s-apt-usage" rel="subsection" title="14.3.2 Using apt-get.">
|
|
<link href="ch-advanced.html#s-advanced-scripting-why" rel="subsection" title="16.1.1 What and why">
|
|
<link href="ch-advanced.html#s-advanced-scripting-example" rel="subsection" title="16.1.2 A simple example">
|
|
<link href="ch-advanced.html#s-advanced-files-hardlinks" rel="subsection" title="16.2.1 The real nature of files: hard links and inodes">
|
|
<link href="ch-advanced.html#s-advanced-files-types" rel="subsection" title="16.2.2 Types of files">
|
|
<link href="ch-advanced.html#s-advanced-files-types-symlinks" rel="subsection" title="16.2.2.1 Symbolic links">
|
|
<link href="ch-advanced.html#s-files-misc-types-devices" rel="subsection" title="16.2.2.2 Device files">
|
|
<link href="ch-advanced.html#s-advanced-files-types-devices-null" rel="subsection" title="16.2.2.2.1 <samp>/dev/null</samp>">
|
|
<link href="ch-advanced.html#s-advanced-files-types-pipes" rel="subsection" title="16.2.2.3 Named pipes (FIFOs)">
|
|
<link href="ch-advanced.html#s-advanced-files-types-sockets" rel="subsection" title="16.2.2.4 Sockets">
|
|
<link href="ch-advanced.html#s-advanced-files-proc" rel="subsection" title="16.2.3 The <samp>proc</samp> filesystem">
|
|
<link href="ch-advanced.html#s-advanced-files-permissions" rel="subsection" title="16.2.4 Advanced aspects of file permissions">
|
|
<link href="ch-advanced.html#s-advanced-files-permissions-absolute" rel="subsection" title="16.2.4.1 Using numeric arguments with <samp>chmod</samp>">
|
|
<link href="ch-advanced.html#s-advanced-files-chattr" rel="subsection" title="16.2.5 chattr">
|
|
<link href="ch-advanced.html#s-advanced-files-copying" rel="subsection" title="16.2.6 Large-scale copying">
|
|
<link href="ch-advanced.html#s-advanced-files-undocumented" rel="subsection" title="16.2.7 Other concepts not yet covered, but should be">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p><a name="ch-files"></a></p>
|
|
<hr>
|
|
|
|
<p>
|
|
[ <a href="ch-shell.html">previous</a> ]
|
|
[ <a href="index.html#contents">Contents</a> ]
|
|
[ <a href="ch-about.html">1</a> ]
|
|
[ <a href="ch-introduction.html">2</a> ]
|
|
[ <a href="ch-start.html">3</a> ]
|
|
[ <a href="ch-basics.html">4</a> ]
|
|
[ <a href="ch-docs.html">5</a> ]
|
|
[ <a href="ch-shell.html">6</a> ]
|
|
[ 7 ]
|
|
[ <a href="ch-editor.html">8</a> ]
|
|
[ <a href="ch-custom_shell.html">9</a> ]
|
|
[ <a href="ch-X.html">10</a> ]
|
|
[ <a href="ch-text_tools.html">11</a> ]
|
|
[ <a href="ch-file_tools.html">12</a> ]
|
|
[ <a href="ch-disks.html">13</a> ]
|
|
[ <a href="ch-dpkg.html">14</a> ]
|
|
[ <a href="ch-troubleshooting.html">15</a> ]
|
|
[ <a href="ch-advanced.html">16</a> ]
|
|
[ <a href="ch-next.html">17</a> ]
|
|
[ <a href="ch-helping.html">18</a> ]
|
|
[ <a href="ap-apps_appendix.html">A</a> ]
|
|
[ <a href="ap-components_appendix.html">B</a> ]
|
|
[ <a href="ap-booting_appendix.html">C</a> ]
|
|
[ <a href="ap-misc_appendix.html">D</a> ]
|
|
[ <a href="ch-editor.html">next</a> ]
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h1>
|
|
Debian Tutorial (Obsolete Documentation)
|
|
<br>Chapter 7 - More on files
|
|
</h1>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
In <a href="ch-basics.html#s-basics-files">Files and Directories, Section
|
|
4.2</a> we covered moving/renaming files with <samp>mv</samp>, copying them
|
|
with <samp>cp</samp>, removing them with <samp>rm</samp>, removing directories
|
|
with <samp>rmdir</samp>, and creating directories with <samp>mkdir</samp>.
|
|
This chapter will cover some more aspects of files.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-files-permissions"></a>7.1 Permissions</h2>
|
|
|
|
<p>
|
|
GNU and Unix systems are set up to allow many people to use the same computer,
|
|
while keeping certain files private or keeping certain people from modifying
|
|
certain files. You can verify this for yourself:
|
|
</p>
|
|
<ol type="1" start="1" >
|
|
<li>
|
|
<p>
|
|
Log in as yourself, i.e. <em>NOT</em> as root.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="2" >
|
|
<li>
|
|
<p>
|
|
<samp>whoami</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Verifies that you are not root.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="3" >
|
|
<li>
|
|
<p>
|
|
<samp>rm /etc/resolv.conf</samp>
|
|
</p>
|
|
|
|
<p>
|
|
You should be told "Permission denied." <samp>/etc/resolv.conf</samp>
|
|
is an essential system configuration file --- you aren't allowed to change or
|
|
remove it unless you're root. This keeps you from accidentally messing up the
|
|
system, and if the computer is a public one such as at an office or school, it
|
|
keeps users from messing up the system on purpose.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
Now type <samp>ls -l /etc/resolv.conf</samp>
|
|
</p>
|
|
|
|
<p>
|
|
This will give you output that looks something like this:
|
|
</p>
|
|
|
|
<pre>
|
|
-rw-r--r-- 1 root root 119 Feb 23 1997 /etc/resolv.conf
|
|
</pre>
|
|
|
|
<p>
|
|
The <samp>-l</samp> option to <samp>ls</samp> requests all that additional
|
|
information. The info on the right is easy - the size of the file is
|
|
<samp>119</samp> bytes, the date the file was last changed is <samp>Feb 23
|
|
1997</samp>, the file's name is <samp>/etc/resolv.conf</samp>. On the left
|
|
side of the screen, things get a little more complicated.
|
|
</p>
|
|
|
|
<p>
|
|
First, the brief, technical explanation: the <samp>-rw-r--r--</samp> is the
|
|
<em>mode</em> of the file, the <samp>1</samp> is the number of hard links to
|
|
this file (or the number of files in a directory), and the two
|
|
<samp>root</samp> are the user and group owning the file.
|
|
</p>
|
|
|
|
<p>
|
|
So that was cryptic. Let's go through it slowly (except the hard links part
|
|
--- for that see <a href="ch-advanced.html#s-advanced-files-hardlinks">The real
|
|
nature of files: hard links and inodes, Section 16.2.1</a>).
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s-files-permissions-groups"></a>7.1.1 File Ownership</h3>
|
|
|
|
<p>
|
|
Every file has two owners --- a user, and a group. The above case is a little
|
|
confusing, since there's a group called <samp>root</samp> in addition to the
|
|
<samp>root</samp> user. Groups are just collections of users who are
|
|
collectively permitted access to some part of the system. A good example is a
|
|
<samp>games</samp> group. Just to be mean, you might set up your system so
|
|
that only people in a <samp>games</samp> group are allowed to play games.
|
|
</p>
|
|
|
|
<p>
|
|
A more practical example: say you're setting up a computer for a school. You
|
|
might want certain files to be accessible only to teachers, not students, so
|
|
you put all the teachers in a single group. Then you can tell the system that
|
|
certain files belong to members of the group <samp>teachers</samp>, and that no
|
|
one else can access those files.
|
|
</p>
|
|
|
|
<p>
|
|
Here are some things you can do to explore groups on your system:
|
|
</p>
|
|
<ol type="1" start="1" >
|
|
<li>
|
|
<p>
|
|
<samp>groups</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Typing this at the shell prompt will tell you what groups you're a member of.
|
|
It's likely that you're a member of only one group, which is identical to your
|
|
username.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="2" >
|
|
<li>
|
|
<p>
|
|
<samp>more /etc/group</samp>
|
|
</p>
|
|
|
|
<p>
|
|
This file lists the groups that exist on your system. Notice the
|
|
<samp>root</samp> group (the only member of this group is the root user), and
|
|
the group which corresponds to your username. There are also groups like
|
|
<samp>dialout</samp> (users who are allowed to dial out on the modem), and
|
|
<samp>floppy</samp> (users who can use the floppy drive). However, your system
|
|
is probably not configured to make use of these groups --- it's likely that
|
|
only root can use the floppy or the modem right now. For details about this
|
|
file, try reading <samp>man group</samp>.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="3" >
|
|
<li>
|
|
<p>
|
|
<samp>ls -l /home</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Observe how every user's directory is owned by that user and that user's
|
|
personal group. (If you just installed Debian, you may be the only user.)
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s-files-permissions-mode"></a>7.1.2 Mode</h3>
|
|
|
|
<p>
|
|
In addition to being owned by one user and one group, every file and directory
|
|
also has a mode, which determines who's allowed to read, write, and execute the
|
|
file. There are a few other things also determined by the mode, but they're
|
|
advanced topics so we'll skip them for now.
|
|
</p>
|
|
|
|
<p>
|
|
The mode looks like this in the <samp>ls</samp> output:
|
|
<samp>-rw-r--r--</samp>. There are ten "elements" here, and the mode
|
|
actually consists of twelve bits (think of bits as switches which can be on or
|
|
off). But for now, we'll consider only nine of these bits: those that control
|
|
<em>read</em>, <em>write</em>, and <em>execute</em> permissions for the
|
|
<em>user</em> owning the file, the <em>group</em> owning the file, and
|
|
<em>others</em> (everyone on the system, sometimes called <em>world</em>).
|
|
</p>
|
|
|
|
<p>
|
|
Notice that three kinds of permission (read, write, execute) times three sets
|
|
of people who can have permission (user, group, others) makes a total of nine
|
|
elements.
|
|
</p>
|
|
|
|
<p>
|
|
In the mode line, the first "element" gives the type of the file.
|
|
The <samp>-</samp> in this case means it's a regular file. If it was
|
|
<samp>d</samp>, we'd be looking at a directory. There are other possibilities
|
|
too complex to go into now (see <a
|
|
href="ch-advanced.html#s-advanced-files-permissions">Advanced aspects of file
|
|
permissions, Section 16.2.4</a>).
|
|
</p>
|
|
|
|
<p>
|
|
The remaining nine "elements" are used to display the 12 bits that
|
|
make up the file's mode. The basic 9 bits (read, write, and execute for user,
|
|
group, and other) are displayed as three blocks of <samp>rwx</samp>.
|
|
</p>
|
|
|
|
<p>
|
|
So if all permissions are turned on and this is a regular file, the mode will
|
|
look like this: <samp>-rwxrwxrwx</samp>. If it was a directory with all
|
|
permissions turned off for others and full permissions for user and group, it
|
|
would be <samp>drwxrwx---</samp>. (The remaining three bits are displayed by
|
|
changing the <samp>x</samp> to <samp>s</samp>, <samp>t</samp>, <samp>S</samp>,
|
|
or <samp>T</samp>, but this is a complex topic we're saving for <a
|
|
href="ch-advanced.html#s-advanced-files-permissions">Advanced aspects of file
|
|
permissions, Section 16.2.4</a>.)
|
|
</p>
|
|
|
|
<p>
|
|
For regular files, "read", "write", and "execute"
|
|
have the following meanings:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
Read permission, indicated by <samp>r</samp>, gives permission to examine the
|
|
contents of a file. For directories, it gives permission to list the contents
|
|
of the directory.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
Write permission, indicated by <samp>w</samp>, gives permission to make changes
|
|
to a file. For directories, it gives permission to create and remove files in
|
|
the directory.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
Execute permission, indicated by <samp>x</samp>, gives permission to run the
|
|
file as a command. Clearly it only makes sense to set execute permission if
|
|
the file actually is a command.
|
|
</p>
|
|
|
|
<p>
|
|
Since directories can never be executed, the execute bit has a different
|
|
meaning. For directories, execute permission means permission to access files
|
|
in the directory. Note that this interacts with write permissions: execute
|
|
permissions must be set to be able to access files in a directory <em>at
|
|
all</em>, so without execute permission on a directory, write permission is
|
|
useless. Execute permission for directories is often called "search"
|
|
permission, since it really has nothing to do with execution. "File
|
|
access" permission would probably be a still better name.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>
|
|
Directory modes are a little confusing, so here are some examples of the
|
|
effects of various combinations:
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
<samp>r--</samp>
|
|
</p>
|
|
|
|
<p>
|
|
The user, group, or other with these permissions may list the contents of the
|
|
directory, but nothing else. The files in the directory can't be read,
|
|
changed, deleted, or manipulated in any way. The only permitted action is
|
|
reading the directory itself, that is, seeing what files it contains.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
<samp>rw-</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Write permission has no effect in the absence of execute permission, so this
|
|
mode behaves just like the above mode.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
<samp>r-x</samp>
|
|
</p>
|
|
|
|
<p>
|
|
This mode permits the files in a directory to be listed, and permits access to
|
|
those files. However, files can't be created or deleted. <em>Access</em>
|
|
means that you can view, change, or execute the files as permitted by the
|
|
files' own permissions.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
<samp>--x</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Files in this directory can be accessed, but the contents of the directory
|
|
can't be listed, so you have to know what filename you're looking for in
|
|
advance (unless you're a good guesser). Files can't be created or deleted.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
<ul>
|
|
<li>
|
|
<p>
|
|
<samp>rwx</samp>
|
|
</p>
|
|
|
|
<p>
|
|
You can do anything you want with the files in this directory, as long as it's
|
|
permitted by the permissions on the files themselves.
|
|
</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>
|
|
Directory write permission determines whether you can delete files in a
|
|
directory --- a read-only file can be deleted, if you have permission to write
|
|
to the directory containing it. You can't delete a file from a read-only
|
|
directory, even if you're allowed to make changes to the file. File
|
|
permissions have nothing to do with deleting files.
|
|
</p>
|
|
|
|
<p>
|
|
This also means that if you own a directory you can always delete files from
|
|
it, even if those files belong to root.
|
|
</p>
|
|
|
|
<p>
|
|
Directory execute permission determines whether you have access to files ---
|
|
and thus whether file permissions come into play. <em>If</em> you have execute
|
|
permissions to a directory, file permissions for that directory become
|
|
relevant. Otherwise file permissions just don't matter; you can't access the
|
|
files anyway.
|
|
</p>
|
|
|
|
<p>
|
|
If you have execute permission for the directory, file permissions determine
|
|
whether you can read the contents of the file, change the file, and/or execute
|
|
the file as a command.
|
|
</p>
|
|
|
|
<p>
|
|
Finally, permission to change permissions on a file or directory is not
|
|
affected by the permissions of that file or directory. Rather, you can always
|
|
change the permissions on files or directories that you own, but not on files
|
|
owned by someone else, as long as you are permitted access to the file. So if
|
|
you can access a file you own at all (that is, you have execute permission for
|
|
the directory containing it) then you can change its permissions.
|
|
</p>
|
|
|
|
<p>
|
|
This means that you can't permanently remove permissions from yourself because
|
|
you can always give them back. Say you remove user write permission from a
|
|
file you own, then try to change the file. It won't be permitted, but you can
|
|
always give yourself write permission again and <em>then</em> change the file.
|
|
The only way to lose the ability to change permissions back is to lose access
|
|
to the file entirely.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s-files-permissions-tutorial"></a>7.1.3 Permissions in practice</h3>
|
|
|
|
<p>
|
|
This section goes through a short example session to demonstrate how
|
|
permissions are used.
|
|
</p>
|
|
|
|
<p>
|
|
To change permissions, we'll use the <samp>chmod</samp> command.
|
|
</p>
|
|
<ol type="1" start="1" >
|
|
<li>
|
|
<p>
|
|
<samp>cd; touch myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
There are a couple of new tricks here. First, you can use <samp>;</samp> to
|
|
put two commands on one line. You can type the above as:
|
|
</p>
|
|
|
|
<pre>
|
|
$ cd
|
|
$ touch myfile
|
|
</pre>
|
|
|
|
<p>
|
|
or as:
|
|
</p>
|
|
|
|
<pre>
|
|
$ cd; touch myfile
|
|
</pre>
|
|
|
|
<p>
|
|
and the same thing will end up happening.
|
|
</p>
|
|
|
|
<p>
|
|
Recall that <samp>cd</samp> by itself returns you to your home directory.
|
|
<samp>touch</samp> is normally used to change the modification time of the file
|
|
to the current time, but it has another interesting feature: if the file
|
|
doesn't exist, <samp>touch</samp> creates the file. So we're using it to
|
|
create a file to practice with. Use <samp>ls -l</samp> to confirm that the
|
|
file has been created, and notice the permissions mode:
|
|
</p>
|
|
|
|
<pre>
|
|
$ ls -l
|
|
-rw-r--r-- 1 havoc havoc 0 Nov 18 22:04 myfile
|
|
</pre>
|
|
|
|
<p>
|
|
Obviously the time and user/group names will be different when you try it. The
|
|
size of the file is 0, since <samp>touch</samp> creates an empty file.
|
|
<samp>-rw-r--r--</samp> is the default permissions mode on Debian .
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="2" >
|
|
<li>
|
|
<p>
|
|
<samp>chmod u+x myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
This command means to add (<samp>+</samp>) execute (<samp>x</samp>) permissions
|
|
for the user (<samp>u</samp>) who owns the file. Use <samp>ls -l</samp> to see
|
|
the effects.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="3" >
|
|
<li>
|
|
<p>
|
|
<samp>chmod go-r myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Here we've subtracted (<samp>-</samp>) read permission (<samp>r</samp>) from
|
|
the group (<samp>g</samp>) owning the file, and from everyone else (others,
|
|
<samp>o</samp>). Again, use <samp>ls -l</samp> to verify the effects.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="4" >
|
|
<li>
|
|
<p>
|
|
<samp>chmod ugo=rx myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
Here we've set (<samp>=</samp>) user, group, and other permissions to read and
|
|
execute. This sets permissions to <em>exactly</em> what you've specified, and
|
|
unsets any other permissions. So all <samp>rx</samp> should be set, and all
|
|
<samp>w</samp> should be unset. Now, no one can write to the file.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="5" >
|
|
<li>
|
|
<p>
|
|
<samp>chmod a-x myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
<samp>a</samp> is a shortcut for <samp>ugo</samp>, or "all". So all
|
|
the <samp>x</samp> permissions should now be unset.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="6" >
|
|
<li>
|
|
<p>
|
|
<samp>rm myfile</samp>
|
|
</p>
|
|
|
|
<p>
|
|
We're removing the file, but without write permissions. <samp>rm</samp> will
|
|
ask if you're sure:
|
|
</p>
|
|
|
|
<pre>
|
|
rm: remove `myfile', overriding mode 0444?
|
|
</pre>
|
|
|
|
<p>
|
|
You should respond by typing <samp>y</samp> and pressing enter. This is a
|
|
feature of <samp>rm</samp>, not a fact of permissions - permission to delete a
|
|
file comes from the directory permissions, and you have write permission in the
|
|
directory. However, <samp>rm</samp> tries to be helpful, figuring that if you
|
|
didn't want to change the file (and thus removed write permission), you don't
|
|
want to delete it either, so it asks you.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
What was that <samp>0444</samp> business in the question from <samp>rm</samp>?
|
|
The permissions mode is a twelve-digit binary number, like this:
|
|
<samp>000100100100</samp>. <samp>0444</samp> is this binary number represented
|
|
as an octal (base 8) number, which is the conventional way to write a mode. So
|
|
you can type <samp>chmod 444 myfile</samp> instead of <samp>chmod ugo=r
|
|
myfile</samp>. This is fully explained in <a
|
|
href="ch-advanced.html#s-advanced-files-permissions">Advanced aspects of file
|
|
permissions, Section 16.2.4</a>.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-files-tour"></a>7.2 What files are on my system? Where can I put my own files?</h2>
|
|
|
|
<p>
|
|
Now that you can navigate the directory tree, let's take a guided tour of the
|
|
files and directories you created when you installed Debian. If you're
|
|
curious, <samp>cd</samp> to each directory and type <samp>ls</samp> to see its
|
|
contents. If the listing doesn't fit on the screen, try <samp>ls |
|
|
more</samp>, where <samp>|</samp> is the "pipe" character, generally
|
|
found on the same key with backslash.
|
|
</p>
|
|
<dl>
|
|
<dt><samp>/</samp></dt>
|
|
<dd>
|
|
<p>
|
|
As already mentioned, this is the root directory, which contains every other
|
|
directory.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/root</samp></dt>
|
|
<dd>
|
|
<p>
|
|
But don't get <samp>/</samp> confused with <samp>/root</samp>!
|
|
<samp>/root</samp> is the home directory of the root user, or superuser. It's
|
|
a directory called <samp>/root</samp>, but it isn't <em>the</em> root directory
|
|
<samp>/</samp>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/home</samp></dt>
|
|
<dd>
|
|
<p>
|
|
This is where all normal users --- that is, all users except root --- have
|
|
their home directories. Home directories are named after the user who owns
|
|
them, for example, <samp>/home/jane</samp>. If you're using a large system at
|
|
a school or business, your system administrator may create additional
|
|
directories to contain home directories: <samp>/home1</samp> and
|
|
<samp>/home2</samp> for example. On some other systems, you'll see an
|
|
additional level of subdirectories:
|
|
<samp>/home/students/<var>username</var></samp>,
|
|
<samp>/home/staff/<var>username</var></samp>, etc...
|
|
</p>
|
|
|
|
<p>
|
|
Your home directory is where you put all your personal work, email and other
|
|
documents, and personal configuration preferences. It's your home on the
|
|
system.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/bin</samp></dt>
|
|
<dd>
|
|
<p>
|
|
This directory contains "binaries," executable files which are
|
|
essential to the operation of the system. Examples are the shell
|
|
(<samp>bash</samp>), and file commands such as <samp>cp</samp>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/sbin</samp></dt>
|
|
<dd>
|
|
<p>
|
|
This directory contains "system binaries", utilities that the root
|
|
user or system administrator might want to use, but probably you won't want to
|
|
use in your day-to-day activities.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/usr</samp></dt>
|
|
<dd>
|
|
<p>
|
|
<samp>/usr</samp> contains most of the files you'll be interested in. It has
|
|
many subdirectories: <samp>/usr/bin</samp> and <samp>/usr/sbin</samp> are
|
|
pretty much like <samp>/bin</samp> and <samp>/sbin</samp>, except that the
|
|
directories in <samp>/usr</samp> are not considered "essential to the
|
|
operation of the system".
|
|
</p>
|
|
|
|
<p>
|
|
While not essential to get the computer working,<samp>/usr</samp> does contain
|
|
the applications you'll use to get real work done. Also in <samp>/usr</samp>
|
|
you'll find the <samp>/usr/man</samp>, <samp>/usr/info</samp>, and
|
|
<samp>/usr/doc</samp> directories --- these contain manual pages, info pages,
|
|
and other documentation, respectively. And don't forget
|
|
<samp>/usr/games</samp>!
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/usr/local</samp></dt>
|
|
<dd>
|
|
<p>
|
|
The Debian system doesn't install anything in this directory. You should use
|
|
it if you want to install software that you compile yourself, or any software
|
|
not contained in a Debian package. You can also install software in your home
|
|
directory, if you'll be the only one using it.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/etc</samp></dt>
|
|
<dd>
|
|
<p>
|
|
<samp>/etc</samp> contains all the system-wide configuration files. Whenever
|
|
you want to change something that affects all users of your computer --- such
|
|
as how you connect to the internet, or what kind of video card you have ---
|
|
you'll probably have to log on as root and change a file in <samp>/etc</samp>.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/tmp</samp></dt>
|
|
<dd>
|
|
<p>
|
|
Here you'll find temporary files, most of them created by the system. This
|
|
directory is generally erased on a regular basis, or every time you reboot the
|
|
system. You can create files here if you want, just be aware they might get
|
|
deleted automatically.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
<dl>
|
|
<dt><samp>/var</samp></dt>
|
|
<dd>
|
|
<p>
|
|
<samp>/var</samp> contains "variable" files, that the system changes
|
|
automatically. For example, incoming mail is stored here. The system keeps a
|
|
log of its actions here. There are a number of other automatically generated
|
|
files here as well. You'll mostly be interested in the contents of
|
|
<samp>/var/log</samp>, where you can find error messages and try to figure out
|
|
what you're system's up to if something goes wrong.
|
|
</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<p>
|
|
Clearly there are many more directories on the system, too many to describe
|
|
every one.
|
|
</p>
|
|
|
|
<p>
|
|
For changing things, you'll usually want to confine yourself to your home
|
|
directory and <samp>/etc</samp>. On a Debian system, there's rarely an
|
|
occasion to change anything else, because everything else is automatically
|
|
installed for you.
|
|
</p>
|
|
|
|
<p>
|
|
<samp>/etc</samp> is used to configure the <em>system</em> as a whole. You'll
|
|
use your own home directory, a subdirectory of <samp>/home</samp>, for
|
|
configuring your own preferences, and storing your personal data. The idea is
|
|
that on a day-to-day basis you confine yourself to <samp>/home/yourname</samp>,
|
|
so there's no way you can break anything. Occasionally you log in as root to
|
|
change something in a system-wide directory, but only when absolutely
|
|
necessary. Of course, if you're using Debian at a school or business and
|
|
someone else is the system administrator, you won't have root access and will
|
|
only be able to change your home directory. This limits what you can do with
|
|
the system.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-file-manager"></a>7.3 Using a filemanager</h2>
|
|
|
|
<p>
|
|
Instead of moving files around by hand, you can use a <em>file manager</em>.
|
|
If you move a lot of files around a file manager can make your work more
|
|
efficient. There are text-based file managers, such as GNU Midnight Commander
|
|
(type <code>mc</code>), and a number of file managers for the X Window System
|
|
(for example <code>gmc</code> for the X Window version of GNU Midnight
|
|
Commander).
|
|
</p>
|
|
|
|
<p>
|
|
Describing each of these is outside the scope of this manual; but you may want
|
|
to try them out if the command line doesn't meet your needs.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
[ <a href="ch-shell.html">previous</a> ]
|
|
[ <a href="index.html#contents">Contents</a> ]
|
|
[ <a href="ch-about.html">1</a> ]
|
|
[ <a href="ch-introduction.html">2</a> ]
|
|
[ <a href="ch-start.html">3</a> ]
|
|
[ <a href="ch-basics.html">4</a> ]
|
|
[ <a href="ch-docs.html">5</a> ]
|
|
[ <a href="ch-shell.html">6</a> ]
|
|
[ 7 ]
|
|
[ <a href="ch-editor.html">8</a> ]
|
|
[ <a href="ch-custom_shell.html">9</a> ]
|
|
[ <a href="ch-X.html">10</a> ]
|
|
[ <a href="ch-text_tools.html">11</a> ]
|
|
[ <a href="ch-file_tools.html">12</a> ]
|
|
[ <a href="ch-disks.html">13</a> ]
|
|
[ <a href="ch-dpkg.html">14</a> ]
|
|
[ <a href="ch-troubleshooting.html">15</a> ]
|
|
[ <a href="ch-advanced.html">16</a> ]
|
|
[ <a href="ch-next.html">17</a> ]
|
|
[ <a href="ch-helping.html">18</a> ]
|
|
[ <a href="ap-apps_appendix.html">A</a> ]
|
|
[ <a href="ap-components_appendix.html">B</a> ]
|
|
[ <a href="ap-booting_appendix.html">C</a> ]
|
|
[ <a href="ap-misc_appendix.html">D</a> ]
|
|
[ <a href="ch-editor.html">next</a> ]
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
Debian Tutorial (Obsolete Documentation)
|
|
</p>
|
|
|
|
<address>
|
|
29 Dezember 2009<br>
|
|
<br>
|
|
Havoc Pennington <code><a href="mailto:hp@debian.org">hp@debian.org</a></code><br>
|
|
<br>
|
|
</address>
|
|
<hr>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|