Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > by-pkgid > 965e33040dd61030a94f0eb89877aee8 > files > 3218

howto-html-en-20080722-2mdv2010.1.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML
><HEAD
><TITLE
>How to access the /proc-filesystem</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="Linux IPv6 HOWTO (en)"
HREF="index.html"><LINK
REL="UP"
TITLE="Kernel settings in /proc-filesystem"
HREF="chapter-kernel-settings.html"><LINK
REL="PREVIOUS"
TITLE="Kernel settings in /proc-filesystem"
HREF="chapter-kernel-settings.html"><LINK
REL="NEXT"
TITLE="Entries in /proc/sys/net/ipv6/"
HREF="proc-sys-net-ipv6..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"
>Linux IPv6 HOWTO (en)</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="chapter-kernel-settings.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 11. Kernel settings in /proc-filesystem</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="proc-sys-net-ipv6..html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="AEN1371"
></A
>11.1. How to access the /proc-filesystem</H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1373"
></A
>11.1.1. Using &#8220;cat&#8221; and &#8220;echo&#8221;</H2
><P
>Using &#8220;cat&#8221; and &#8220;echo&#8221; is the simplest way to access the /proc filesystem, but some requirements are needed for that</P
><P
></P
><UL
><LI
><P
>The /proc-filesystem had to be enabled in kernel, means on compiling following switch has to be set</P
></LI
></UL
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>CONFIG_PROC_FS=y</PRE
></FONT
></TD
></TR
></TABLE
><P
></P
><UL
><LI
><P
>The /proc-filesystem was mounted before, which can be tested using</P
></LI
></UL
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># mount | grep "type proc"
none on /proc type proc (rw)</PRE
></FONT
></TD
></TR
></TABLE
><P
></P
><UL
><LI
><P
>You need read and sometimes also write access (normally root only) to the /proc-filesystem</P
></LI
></UL
><P
>Normally, only entries in /proc/sys/* are writable, the others are readonly and for information retrieving only.</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN1388"
></A
>11.1.1.1. Retrieving a value</H3
><P
>The value of an entry can be retrieved using &#8220;cat&#8221;:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># cat /proc/sys/net/ipv6/conf/all/forwarding
0</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN1392"
></A
>11.1.1.2. Setting a value</H3
><P
>A new value can be set (if entry is writable) using &#8220;echo&#8221;:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># echo "1" &#62;/proc/sys/net/ipv6/conf/all/forwarding</PRE
></FONT
></TD
></TR
></TABLE
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1396"
></A
>11.1.2. Using &#8220;sysctl&#8221;</H2
><P
>Using the &#8220;sysctl&#8221; program to access the kernel switches is a modern method today. You can use it also, if the /proc-filesystem isn't mounted. But you have only access to /proc/sys/*!</P
><P
>The program &#8220;sysctl&#8221; is included in package &#8220;procps&#8221; (on Red Hat Linux systems).</P
><P
></P
><UL
><LI
><P
>The sysctl-interface had to be enabled in kernel, means on compiling following switch has to be set</P
></LI
></UL
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>CONFIG_SYSCTL=y</PRE
></FONT
></TD
></TR
></TABLE
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN1404"
></A
>11.1.2.1. Retrieving a value</H3
><P
>The value of an entry can be retrieved now:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># sysctl net.ipv6.conf.all.forwarding
net.ipv6.conf.all.forwarding = 0</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN1408"
></A
>11.1.2.2. Setting a value</H3
><P
>A new value can be set (if entry is writable):</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># sysctl -w net.ipv6.conf.all.forwarding=1
net.ipv6.conf.all.forwarding = 1</PRE
></FONT
></TD
></TR
></TABLE
><P
>Note: Don't use spaces around the &#8220;=&#8221; on setting values. Also on multiple values per line, quote them like e.g.</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="100%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
># sysctl -w net.ipv4.ip_local_port_range="32768 61000"
net.ipv4.ip_local_port_range = 32768 61000</PRE
></FONT
></TD
></TR
></TABLE
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN1414"
></A
>11.1.2.3. Additionals</H3
><P
>Note: There are sysctl versions in the wild which displaying &#8220;/&#8221; instead of the &#8220;.&#8221;</P
><P
>For more details take a look into sysctl's manpage.</P
><P
>Hint: for digging fast into the settings, use the option &#8220;-a&#8221; (display all entries) in conjunction with &#8220;grep&#8221;.</P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN1419"
></A
>11.1.3. Values found in /proc-filesystems</H2
><P
>There are several formats seen in /proc-filesystem:</P
><P
></P
><UL
><LI
><P
>BOOLEAN: simple a &#8220;0&#8221; (false) or a &#8220;1&#8221; (true)</P
></LI
><LI
><P
>INTEGER: an integer value, can be unsigned, too</P
></LI
><LI
><P
>more sophisticated lines with several values: sometimes a header line is displayed also, if not, have a look into the kernel source to retrieve information about the meaning of each value...</P
></LI
></UL
></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="chapter-kernel-settings.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="proc-sys-net-ipv6..html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Kernel settings in /proc-filesystem</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="chapter-kernel-settings.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Entries in /proc/sys/net/ipv6/</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>