590 lines
		
	
	
	
		
			24 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
			
		
		
	
	
			590 lines
		
	
	
	
		
			24 KiB
		
	
	
	
		
			Text
		
	
	
	
	
	
| <!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook V4.1-Based Extension//EN" [
 | |
| <!ENTITY % articles.ent PUBLIC "-//FreeBSD//ENTITIES DocBook FreeBSD Articles Entity Set//EN">
 | |
| %articles.ent;
 | |
| ]>
 | |
| 
 | |
| <article>
 | |
|   <articleinfo>
 | |
|     <title>FreeBSD Quickstart Guide for &linux; Users</title>
 | |
| 
 | |
|     <authorgroup>
 | |
|       <author>
 | |
| 	<firstname>John</firstname>
 | |
| 	<surname>Ferrell</surname>
 | |
|       </author>
 | |
|     </authorgroup>
 | |
| 
 | |
|     <copyright>
 | |
|       <year>2008</year>
 | |
|       <holder>The FreeBSD Documentation Project</holder>
 | |
|     </copyright>
 | |
| 
 | |
|     <releaseinfo>$FreeBSD$</releaseinfo>
 | |
| 
 | |
|     <legalnotice id="trademarks" role="trademarks">
 | |
|       &tm-attrib.freebsd;
 | |
|       &tm-attrib.linux;
 | |
|       &tm-attrib.intel;
 | |
|       &tm-attrib.redhat;
 | |
|       &tm-attrib.unix;
 | |
|       &tm-attrib.general;
 | |
|     </legalnotice>
 | |
| 
 | |
|     <abstract>
 | |
|       <para>This document is intended to quickly familiarize intermediate to
 | |
| 	advanced &linux; users with the basics of FreeBSD.</para>
 | |
|     </abstract>
 | |
|   </articleinfo>
 | |
| 
 | |
|   <sect1 id="intro">
 | |
|     <title>Introduction</title>
 | |
| 
 | |
|     <para>This document will highlight the differences between &os; and
 | |
|       &linux; so that intermediate to advanced &linux; users can quickly
 | |
|       familiarize themselves with the basics of &os;.  This is just a
 | |
|       technical quickstart, it does not attempt to design
 | |
|       <quote>philosophical</quote> differences between the two
 | |
|       operating systems.</para>
 | |
| 
 | |
|     <para>This document assumes that you have already installed &os;.
 | |
|       If you have not installed &os; or need help with the installation
 | |
|       process please refer to the
 | |
|       <ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/install.html">
 | |
|       Installing FreeBSD</ulink> chapter of the &os; Handbook.</para>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="shells">
 | |
|     <title>Shells: No Bash?</title>
 | |
| 
 | |
|     <para>Those coming from &linux; are often surprised to find that
 | |
|       <application>Bash</application> is not the default shell in &os;.
 | |
|       In fact, <application>Bash</application> is not even in the default
 | |
|       installation.  Instead, &os; uses &man.tcsh.1; as the default shell.
 | |
|       Although, <application>Bash</application> and your other favorite
 | |
|       shells are available in &os;'s <ulink
 | |
| 	url="article.html#SOFTWARE">Packages and Ports Collection</ulink>.</para>
 | |
| 
 | |
|     <para>If you do install other shells you can use &man.chsh.1; to set
 | |
|       a user's default shell.  It is, however, recommended that the
 | |
|       <username>root</username>'s default shell remain unchanged.  The
 | |
|       reason for this is that shells not included in the base distribution
 | |
|       are normally installed in <filename>/usr/local/bin</filename> or
 | |
|       <filename>/usr/bin</filename>.  In the event of a problem the file
 | |
|       systems where <filename>/usr/local/bin</filename> and
 | |
|       <filename>/usr/bin</filename> are located may not be mounted.  In this
 | |
|       case <username>root</username> would not have access to its default
 | |
|       shell, preventing <username>root</username> from logging in.  For this
 | |
|       reason a second <username>root</username> account, the
 | |
|       <username>toor</username> account, was created for use with non-default
 | |
|       shells.  See the security FAQ for information regarding the <ulink
 | |
| 	url="&url.base;/doc/en_US.ISO8859-1/books/faq/security.html#TOOR-ACCOUNT">toor account</ulink>.</para>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="software">
 | |
|     <title>Packages and Ports: Adding software in &os;</title>
 | |
| 
 | |
|     <para>In addition to the traditional &unix; method of installing software
 | |
|       (download source, extract, edit source code, and compile), &os; offers
 | |
|       two other methods for installing applications: packages and ports.  A
 | |
|       complete list of of all available ports and packages can be found <ulink
 | |
| 	url="http://www.freebsd.org/ports/master-index.html">here</ulink>.</para>
 | |
| 
 | |
|     <sect2 id="packages">
 | |
|       <title>Packages</title>
 | |
| 
 | |
|       <para>Packages are pre-compiled applications, the &os; equivalents
 | |
| 	of <filename>.deb</filename> files on Debian/Ubuntu based systems
 | |
| 	and <filename>.rpm</filename> files on Red Hat/Fedora based
 | |
| 	systems.  Packages are installed using &man.pkg.add.1;.  For example,
 | |
| 	the following command installs
 | |
| 	<application>Apache 2.2</application>:</para>
 | |
| 
 | |
|       <screen>&prompt.root; <userinput>pkg_add <replaceable>/tmp/apache-2.2.6_2.tbz</replaceable></userinput></screen>
 | |
| 
 | |
|       <para>Using the <option>-r</option> switch will tell &man.pkg.add.1;
 | |
| 	to automatically fetch a package and install it, as well as any
 | |
| 	dependencies:</para>
 | |
| 
 | |
|       <screen>&prompt.root; <userinput>pkg_add -r <replaceable>apache22</replaceable></userinput>
 | |
| Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/Latest/apache22.tbz... Done.
 | |
| Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/All/expat-2.0.0_1.tbz... Done.
 | |
| Fetching ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6.2-release/All/perl-5.8.8_1.tbz... Done.
 | |
| [snip]
 | |
| 
 | |
| To run apache www server from startup, add apache22_enable="YES"
 | |
| in your /etc/rc.conf. Extra options can be found in startup script.</screen>
 | |
| 
 | |
|       <note>
 | |
| 	<para>If you are running a release version of &os; (6.2, 6.3, 7.0,
 | |
| 	  etc., generally installed from CD-ROM) <command>pkg_add -r</command>
 | |
| 	  will download packages built for that specific release.  These
 | |
| 	  packages <emphasis>may not</emphasis> be the most up-to-date
 | |
| 	  version of the application.  You can use the
 | |
| 	  <envar>PACKAGESITE</envar> variable to override this default
 | |
| 	  behavior.  For example, set <envar>PACKAGESITE</envar> to
 | |
|           <ulink url="ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/Latest/"></ulink>
 | |
|           to download the most recent packages built for the
 | |
| 	  6.X series.</para>
 | |
| 
 | |
|         <para>You can read more about the &os; versions in the article
 | |
| 	  <ulink url="&url.base;/doc/en_US.ISO8859-1/articles/version-guide/">
 | |
| 	    Choosing the &os; Version That Is Right For You</ulink>.</para>
 | |
|       </note>
 | |
| 
 | |
|       <para>For more information on packages please refer to section 4.4 of
 | |
| 	the &os; Handbook: <ulink
 | |
| 	  url="&url.base;/doc/en_US.ISO8859-1/books/handbook/packages-using.html">Using the Packages System</ulink>.</para>
 | |
|     </sect2>
 | |
| 
 | |
|     <sect2 id="ports">
 | |
|       <title>Ports</title>
 | |
| 
 | |
|       <para>&os;'s second method for installing applications is the
 | |
| 	Ports Collection.  The Ports Collection is a framework of
 | |
| 	<filename>Makefiles</filename> and patches specifically customized
 | |
| 	for installing various software applications from source on &os;.
 | |
| 	When installing a port the system will fetch the source code, apply
 | |
| 	any required patches, compile the code, and install the application
 | |
| 	(and do the same for any dependencies).</para>
 | |
| 
 | |
|       <para>The Ports Collection, sometimes referred to as the ports tree,
 | |
| 	can be found in <filename>/usr/ports</filename>.  That is assuming
 | |
| 	the Ports Collection was installed during the &os; installation
 | |
| 	process.  If the Ports Collection has not been installed it can be
 | |
| 	added from the installation discs using &man.sysinstall.8;, or pulled
 | |
| 	from the &os; servers using &man.csup.1; or &man.portsnap.8;.
 | |
| 	Detailed instructions for installing the Ports Collection can be
 | |
| 	found in <ulink
 | |
| 	  url="&url.base;/doc/en_US.ISO8859-1/books/handbook/ports-using.html">section 4.5.1</ulink>
 | |
| 	of the handbook.</para>
 | |
| 
 | |
|       <para>Installing a port is as simple (generally) as changing in to the
 | |
| 	port's directory and starting the build process.  The following example
 | |
| 	installs <application>Apache 2.2</application> from the
 | |
| 	Ports Collection:</para>
 | |
| 
 | |
|       <screen>&prompt.root; <userinput>cd /usr/ports/www/apache22</userinput>
 | |
| &prompt.root; <userinput>make install clean</userinput></screen>
 | |
| 
 | |
|       <para>A major benefit of using ports to install software is the
 | |
| 	ability to customize the installation options.  For example, when
 | |
| 	installing <application>Apache 2.2</application> from ports you can
 | |
| 	enable <application>mod_ldap</application> by setting the
 | |
| 	<makevar>WITH_LDAP</makevar> &man.make.1; variable:</para>
 | |
| 
 | |
|       <screen>&prompt.root; <userinput>cd /usr/ports/www/apache22</userinput>
 | |
| &prompt.root; <userinput>make WITH_LDAP="YES" install clean</userinput></screen>
 | |
| 
 | |
|       <para>Please see section 4.5 of the &os; Handbook, <ulink
 | |
| 	 url="&url.base;/doc/en_US.ISO8859-1/books/handbook/ports-using.html">Using
 | |
| 	 the Ports Collection</ulink>, for more information about the
 | |
| 	Ports Collection.</para>
 | |
|     </sect2>
 | |
| 
 | |
|     <sect2 id="which">
 | |
|       <title>Ports or packages, which one should I use?</title>
 | |
| 
 | |
|       <para>Packages are just pre-compiled ports, so it is really a matter
 | |
| 	of installing from source (ports) versus installing from binary
 | |
| 	packages.  Each method has its own benefits:</para>
 | |
| 
 | |
|       <itemizedlist>
 | |
| 	<title>Packages (binary)</title>
 | |
| 
 | |
| 	<listitem><simpara>Faster installation (compiling large applications
 | |
| 	  can take quite a while).</simpara></listitem>
 | |
| 
 | |
| 	<listitem><simpara>You do not need to understand how to compile
 | |
| 	  software.</simpara></listitem>
 | |
| 
 | |
| 	<listitem><simpara>No need to install compilers on your
 | |
| 	  system.</simpara></listitem>
 | |
|       </itemizedlist>
 | |
| 
 | |
|       <itemizedlist>
 | |
| 	<title>Ports (source)</title>
 | |
| 
 | |
| 	<listitem><simpara>Ability to customize installation options.
 | |
| 	  (Packages are normally built with standard options.  With ports
 | |
| 	  you can customize various options, such as building additional
 | |
| 	  modules or changing the default path.)</simpara></listitem>
 | |
| 
 | |
| 	<listitem><simpara>You can apply your own patches if you are so
 | |
| 	  inclined.</simpara></listitem>
 | |
|       </itemizedlist>
 | |
| 
 | |
|       <para>If you do not have any special requirements, packages will
 | |
| 	probably suit your situation just fine.  If you may ever need to
 | |
| 	customize, ports are the way to go.  (And remember, if you
 | |
| 	need to customize but prefer packages, you can build a custom
 | |
| 	package from ports using <command>make</command>
 | |
| 	<maketarget>package</maketarget> and then copy the package to
 | |
| 	other servers.)</para>
 | |
|     </sect2>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="startup">
 | |
|     <title>System Startup: Where are the run-levels?</title>
 | |
| 
 | |
|     <para>&linux; uses the SysV init system, whereas &os; uses the
 | |
|       traditional BSD-style &man.init.8;.  Under the BSD-style &man.init.8;
 | |
|       there are no run-levels and no <filename>/etc/inittab</filename>,
 | |
|       instead startup is controlled by the &man.rc.8; utility.  The
 | |
|       <filename>/etc/rc</filename> script reads
 | |
|       <filename>/etc/defaults/rc.conf</filename> and
 | |
|       <filename>/etc/rc.conf</filename> to determine which services are to be
 | |
|       started.  The specified services are then started by running the
 | |
|       corresponding service initialization scripts located in
 | |
|       <filename>/etc/rc.d/</filename> and
 | |
|       <filename>/usr/local/etc/rc.d/</filename>.  These scripts are similar to
 | |
|       the scripts located in <filename>/etc/init.d/</filename> on &linux;
 | |
|       systems.</para>
 | |
| 
 | |
|     <sidebar>
 | |
|       <para><emphasis>Why are there two locations for service initialization
 | |
| 	scripts?</emphasis>  The scripts found in
 | |
| 	<filename>/etc/rc.d/</filename> are for applications that are part of
 | |
| 	the <quote>base</quote> system.  (&man.cron.8;, &man.sshd.8;,
 | |
| 	&man.syslog.3;, and others.)  The scripts in
 | |
| 	<filename>/usr/local/etc/rc.d/</filename> are for user-installed
 | |
| 	applications such as <application>Apache</application>,
 | |
| 	<application>Squid</application>, etc.</para>
 | |
| 
 | |
|       <para><emphasis>What is the difference between the <quote>base</quote>
 | |
| 	system and user-installed applications?</emphasis>  FreeBSD is
 | |
| 	developed as a complete operating system.  In other words, the
 | |
| 	kernel, system libraries, and userland utilities (such as &man.ls.1;,
 | |
| 	&man.cat.1;, &man.cp.1;, etc.) are developed and released together as
 | |
| 	one.  This is what is referred to as the <quote>base</quote> system.
 | |
| 	The user-installed applications are applications that are not part of
 | |
| 	the <quote>base</quote> system, such as
 | |
| 	<application>Apache</application>, <application>X11</application>,
 | |
| 	<application>Mozilla Firefox</application>, etc.  These
 | |
| 	user-installed applications are generally installed using &os;'s <ulink
 | |
| 	  url="article.html#SOFTWARE">Packages and Ports Collection</ulink>.
 | |
| 	In order to keep them separate from the <quote>base</quote> system,
 | |
| 	user-installed applications are normally installed under
 | |
| 	<filename>/usr/local/</filename>.  Therefore the user-installed
 | |
| 	binaries reside in <filename>/usr/local/bin/</filename>,
 | |
| 	configuration files are in <filename>/usr/local/etc/</filename>,
 | |
| 	and so on.</para>
 | |
|     </sidebar>
 | |
| 
 | |
|     <para>Services are enabled by specifying
 | |
|       <literal><replaceable>ServiceName</replaceable>_enable="YES"</literal> in
 | |
|       <filename>/etc/rc.conf</filename> (&man.rc.conf.5;).  Take a look at
 | |
|       <filename>/etc/defaults/rc.conf</filename> for the system defaults,
 | |
|       these default settings are overridden by settings in
 | |
|       <filename>/etc/rc.conf</filename>.  Also, when installing additional
 | |
|       applications be sure to review the documentation to determine how to
 | |
|       enable any associated services.</para>
 | |
| 
 | |
|     <para>The following snippet from <filename>/etc/rc.conf</filename> enables
 | |
|       &man.sshd.8; and <application>Apache 2.2</application>.  It also
 | |
|       specifies that <application>Apache</application> should be started
 | |
|       with SSL.</para>
 | |
| 
 | |
|     <programlisting># enable SSHD
 | |
| sshd_enable="YES"
 | |
| # enable Apache with SSL
 | |
| apache22_enable="YES"
 | |
| apache22_flags="-DSSL"</programlisting>
 | |
| 
 | |
|     <para>Once a service has been enabled in <filename>/etc/rc.conf</filename>,
 | |
|       the service can be started from the command line (without rebooting the
 | |
|       system):</para>
 | |
| 
 | |
|     <screen>&prompt.root; <userinput><replaceable>/etc/rc.d/sshd</replaceable> start</userinput></screen>
 | |
| 
 | |
|     <para>If a service has not been enabled it can be started from the
 | |
|       command line using <option>forcestart</option>:</para>
 | |
| 
 | |
|     <screen>&prompt.root; <userinput><replaceable>/etc/rc.d/sshd</replaceable> forcestart</userinput></screen>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="network">
 | |
|     <title>Network configuration</title>
 | |
| 
 | |
|     <sect2 id="interfaces">
 | |
|       <title>Network Interfaces</title>
 | |
| 
 | |
|       <para>Instead of a generic <emphasis>ethX</emphasis> identifier that
 | |
| 	&linux; uses to identify a network interface, &os; uses the driver
 | |
| 	name followed by a number as the identifier.  The following output
 | |
| 	from &man.ifconfig.8; shows two &intel Pro 1000 network
 | |
| 	interfaces (em0 and em1):</para>
 | |
| 
 | |
|       <screen>&prompt.user; <userinput>ifconfig</userinput>
 | |
| em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 | |
|         options=b<RXCSUM,TXCSUM,VLAN_MTU>
 | |
|         inet 10.10.10.100 netmask 0xffffff00 broadcast 10.10.10.255
 | |
|         ether 00:50:56:a7:70:b2
 | |
|         media: Ethernet autoselect (1000baseTX <full-duplex>)
 | |
|         status: active
 | |
| em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
 | |
|         options=b<RXCSUM,TXCSUM,VLAN_MTU>
 | |
|         inet 192.168.10.222 netmask 0xffffff00 broadcast 192.168.10.255
 | |
|         ether 00:50:56:a7:03:2b
 | |
|         media: Ethernet autoselect (1000baseTX <full-duplex>)
 | |
|         status: active</screen>
 | |
|     </sect2>
 | |
| 
 | |
|     <sect2 id="ipaddress">
 | |
|       <title>IP Configuration</title>
 | |
| 
 | |
|       <para>An IP address can be assigned to an interface using
 | |
| 	&man.ifconfig.8;.  However, to remain persistent across reboots the
 | |
| 	IP configuration must be included in
 | |
| 	<filename>/etc/rc.conf</filename>.  The following example
 | |
| 	specifies the hostname, IP address, and default gateway:</para>
 | |
| 
 | |
|       <programlisting>hostname="server1.example.com"
 | |
| ifconfig_em0="inet 10.10.10.100  netmask 255.255.255.0"
 | |
| defaultrouter="10.10.10.1"</programlisting>
 | |
| 
 | |
|       <para>Use the following to configure an interface for DHCP:</para>
 | |
| 
 | |
|       <programlisting>hostname="server1.example.com"
 | |
| ifconfig_em0="DHCP"</programlisting>
 | |
| 
 | |
|     </sect2>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="firewall">
 | |
|     <title>Firewall</title>
 | |
| 
 | |
|     <para>Like <application>IPTABLES</application> in &linux;, &os; also offers
 | |
|       a kernel level firewall; actually &os; offers three firewalls:</para>
 | |
| 
 | |
|     <itemizedlist>
 | |
|       <listitem><simpara><ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/firewalls-ipfw.html">IPFIREWALL</ulink></simpara></listitem>
 | |
|       <listitem><simpara><ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/firewalls-ipf.html">IPFILTER</ulink></simpara></listitem>
 | |
|       <listitem><simpara><ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/firewalls-pf.html">PF</ulink></simpara></listitem>
 | |
|     </itemizedlist>
 | |
| 
 | |
|     <para><application>IPFIREWALL</application> or
 | |
|       <application>IPFW</application> (the command to manage an
 | |
|       <application>IPFW</application> ruleset is &man.ipfw.8;) is the
 | |
|       firewall developed and maintained by the &os; developers.
 | |
|       <application>IPFW</application> can be paired with &man.dummynet.4; to
 | |
|       provide traffic shaping capabilities and simulate different types of
 | |
|       network connections.</para>
 | |
| 
 | |
|     <para>Sample <application>IPFW</application> rule to allow
 | |
|       <application>SSH</application> in:</para>
 | |
| 
 | |
|     <programlisting>ipfw add allow tcp from any to me 22 in via $ext_if</programlisting>
 | |
| 
 | |
|     <para><application>IPFILTER</application> is the firewall application
 | |
|       developed by Darren Reed.  It is not specific to &os;, and has been
 | |
|       ported to several operating systems including NetBSD, OpenBSD, SunOS,
 | |
|       HP/UX, and Solaris.</para>
 | |
| 
 | |
|     <para>Sample <application>IPFILTER</application> command to allow
 | |
|       <application>SSH</application> in:</para>
 | |
| 
 | |
|     <programlisting>pass in on $ext_if proto tcp from any to any port = 22</programlisting>
 | |
| 
 | |
|     <para>The last firewall application, <application>PF</application>, is
 | |
|       developed by the OpenBSD project.  <application>PF</application> was
 | |
|       created as a replacement for <application>IPFILTER</application>.  As
 | |
|       such, the <application>PF</application> syntax is very similar to that of
 | |
|       <application>IPFILTER</application>.  <application>PF</application> can
 | |
|       be paired with &man.altq.4; to provide QoS features.</para>
 | |
| 
 | |
|      <para>Sample <application>PF</application> command to allow
 | |
|        <application>SSH</application> in:</para>
 | |
| 
 | |
|      <programlisting>pass in on $ext_if inet proto tcp from any to ($ext_if) port 22</programlisting>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="updates">
 | |
|     <title>Updating &os;</title>
 | |
| 
 | |
|     <para>There are three methods for updating a &os; system: from source,
 | |
|       binary updates, and the installation discs.</para>
 | |
| 
 | |
|     <para>Updating from source is the most involved update method, but offers
 | |
|       the greatest amount of flexibility.  The process involves synchronizing a
 | |
|       local copy of the FreeBSD source code with the &os;
 | |
|       <application>CVS</application> (Concurrent Versioning System) servers.
 | |
|       Once the local source code is up to date you can build new versions of
 | |
|       the kernel and userland.  For more information on source updates see
 | |
|       <ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/updating-upgrading.html">the chapter on updating</ulink>
 | |
|       in the &os; Handbook.</para>
 | |
| 
 | |
|     <para>Binary updates are similar to using <command>yum</command> or
 | |
|      <command>apt-get</command> to update a &linux; system.  The command
 | |
|      &man.freebsd-update.8; will fetch new updates and install them.  The
 | |
|      updates can be scheduled using &man.cron.8;.</para>
 | |
| 
 | |
|     <note>
 | |
|       <para>If you do use &man.cron.8; to schedule the updates, please be sure
 | |
| 	to use <command>freebsd-update cron</command> in your &man.crontab.1;
 | |
| 	to reduce the possibility of a large number of machines all pulling
 | |
| 	updates at the same time.</para>
 | |
| 
 | |
|       <programlisting>0 3 * * * root /usr/sbin/freebsd-update cron</programlisting>
 | |
|     </note>
 | |
| 
 | |
|     <para>The last update method, updating from the installation discs, is a
 | |
|       straight-forward process.  Boot from the installation discs and select
 | |
|       the option to upgrade.</para>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="procfs">
 | |
|     <title>procfs: Gone But Not Forgotten</title>
 | |
| 
 | |
|     <para>In &linux;, you may have looked at
 | |
|       <filename>/proc/sys/net/ipv4/ip_forward</filename> to determine if
 | |
|       IP forwarding was enabled.  Under &os; you should use &man.sysctl.8; to
 | |
|       view this and other system settings, as &man.procfs.5; has been
 | |
|       deprecated in current versions of &os;.  (Although
 | |
|       <command>sysctl</command> is available in &linux; as well.)</para>
 | |
| 
 | |
|     <para>In the IP forwarding example, you would use the following to
 | |
|       determine if IP forwarding is enabled on your FreeBSD system:</para>
 | |
| 
 | |
|     <screen>&prompt.user; <userinput>sysctl net.inet.ip.forwarding</userinput>
 | |
| net.inet.ip.forwarding: 0</screen>
 | |
| 
 | |
|     <para>The <option>-a</option> flag is used to list all the system
 | |
|       settings:</para>
 | |
| 
 | |
|     <screen>&prompt.user; <userinput>sysctl -a</userinput>
 | |
| kern.ostype: FreeBSD
 | |
| kern.osrelease: 6.2-RELEASE-p9
 | |
| kern.osrevision: 199506
 | |
| kern.version: FreeBSD 6.2-RELEASE-p9 #0: Thu Nov 29 04:07:33 UTC 2007
 | |
|     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC
 | |
| 
 | |
| kern.maxvnodes: 17517
 | |
| kern.maxproc: 1988
 | |
| kern.maxfiles: 3976
 | |
| kern.argmax: 262144
 | |
| kern.securelevel: -1
 | |
| kern.hostname: server1
 | |
| kern.hostid: 0
 | |
| kern.clockrate: { hz = 1000, tick = 1000, profhz = 666, stathz = 133 }
 | |
| kern.posix1version: 200112
 | |
| ...</screen>
 | |
| 
 | |
|     <note>
 | |
|       <para>Some of these <command>sysctl</command> values are
 | |
| 	read-only.</para></note>
 | |
| 
 | |
|     <para>There are occasions where procfs is required, such as running
 | |
|       older software, using &man.truss.1; to trace system calls, and
 | |
|       <ulink url="&url.base;/doc/en_US.ISO8859-1/books/handbook/linuxemu.html">&linux; Binary Compatibility</ulink>.
 | |
|       (Although, &linux; Binary Compatibility uses its own procfs, &man.linprocfs.5;.)
 | |
|       If you need to mount procfs you can add the following to
 | |
|       <filename>/etc/fstab</filename>:</para>
 | |
| 
 | |
|     <screen>proc                /proc           procfs  rw,noauto       0       0</screen>
 | |
| 
 | |
|     <note>
 | |
|       <para><option>noauto</option> will prevent
 | |
| 	<filename>/proc</filename> from being automatically mounted at
 | |
| 	boot.</para></note>
 | |
| 
 | |
|     <para>And then mount procfs with:</para>
 | |
| 
 | |
|     <screen>&prompt.root; <userinput>mount /proc</userinput></screen>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="commands">
 | |
|     <title>Common Commands</title>
 | |
| 
 | |
|     <sect2 id="packageCommands">
 | |
|       <title>Package Management</title>
 | |
| 
 | |
|       <para>
 | |
| 	<informaltable frame="none" pgwide="1">
 | |
| 	  <tgroup cols="3">
 | |
| 	    <thead>
 | |
| 	      <row>
 | |
| 		<entry>&linux; command (Red Hat/Debian)</entry>
 | |
| 		<entry>&os; equivalent</entry>
 | |
| 		<entry>Purpose</entry>
 | |
| 	      </row>
 | |
| 	    </thead>
 | |
| 
 | |
| 	    <tbody>
 | |
| 	      <row>
 | |
| 		<entry><command>yum install <replaceable>package</replaceable></command> / <command>apt-get install <replaceable>package</replaceable></command></entry>
 | |
| 		<entry><command>pkg_add -r <replaceable>package</replaceable></command></entry>
 | |
| 		<entry>Install <replaceable>package</replaceable> from remote repository</entry>
 | |
| 	      </row>
 | |
| 
 | |
| 	      <row>
 | |
| 		<entry><command>rpm -ivh <replaceable>package</replaceable></command> / <command>dpkg -i <replaceable>package</replaceable></command></entry>
 | |
| 		<entry><command>pkg_add -v <replaceable>package</replaceable></command></entry>
 | |
| 		<entry>Install package</entry>
 | |
| 	      </row>
 | |
| 
 | |
| 	      <row>
 | |
| 		<entry><command>rpm -qa</command> / <command>dpkg -l</command></entry>
 | |
| 		<entry><command>pkg_info</command></entry>
 | |
| 		<entry>List installed packages</entry>
 | |
| 	      </row>
 | |
| 	    </tbody>
 | |
| 	  </tgroup>
 | |
| 	</informaltable>
 | |
|       </para>
 | |
|     </sect2>
 | |
| 
 | |
|     <sect2 id="systemCommands">
 | |
|       <title>System Management</title>
 | |
| 
 | |
|       <para>
 | |
| 	<informaltable frame="none" pgwide="1">
 | |
| 	  <tgroup cols="3">
 | |
| 	    <thead>
 | |
| 	      <row>
 | |
| 		<entry>&linux; command</entry>
 | |
| 		<entry>&os; equivalent</entry>
 | |
| 		<entry>Purpose</entry>
 | |
| 	      </row>
 | |
| 	    </thead>
 | |
| 
 | |
| 	    <tbody>
 | |
| 	      <row>
 | |
| 		<entry><command>lspci</command></entry>
 | |
| 		<entry><command>pciconf</command></entry>
 | |
| 		<entry>List PCI devices</entry>
 | |
| 	      </row>
 | |
| 
 | |
| 	      <row>
 | |
| 		<entry><command>lsmod</command></entry>
 | |
| 		<entry><command>kldstat</command></entry>
 | |
| 		<entry>List loaded kernel modules</entry>
 | |
| 	      </row>
 | |
| 
 | |
| 	      <row>
 | |
| 		<entry><command>modprobe</command></entry>
 | |
| 		<entry><command>kldload</command> / <command>kldunload</command></entry>
 | |
| 		<entry>Load/Unload kernel modules</entry>
 | |
| 	      </row>
 | |
| 
 | |
| 	      <row>
 | |
| 		<entry><command>strace</command></entry>
 | |
| 		<entry><command>truss</command></entry>
 | |
| 		<entry>Trace system calls</entry>
 | |
| 	      </row>
 | |
| 	    </tbody>
 | |
| 	  </tgroup>
 | |
| 	</informaltable>
 | |
|       </para>
 | |
|     </sect2>
 | |
|   </sect1>
 | |
| 
 | |
|   <sect1 id="conclusion">
 | |
|     <title>Conclusion</title>
 | |
| 
 | |
|     <para>Hopefully this document has provided you with enough to get
 | |
|       started with &os;.   Be sure to take a look at the <ulink
 | |
| 	url="&url.base;/doc/en_US.ISO8859-1/books/handbook/index.html">&os; Handbook</ulink>
 | |
|       for more in depth coverage of the topics touched on as well as
 | |
|       the many topics not covered in this document.</para>
 | |
|   </sect1>
 | |
| </article>
 |