FreeBSD Cheat Sheet: Difference between revisions

From Leo's Notes
This page was last edited on 15 June 2020, at 00:24.
No edit summary
mNo edit summary
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:


== Mounting ISO Image ==
== FreeBSD Ports ==
=== Linux ===
Mount:
mount -o loop -t iso9660 <isofile> <destination>


Unmount:
=== Recursively Configure Ports ===
  umount <destination>
  make config-recursive


=== Ports Update / Upgrade ===
portsnap fetch
portsnap update 


=== FreeBSD ===
or if you are doing this the first time, run:
Mount:
  portsnap fetch
mdconfig -a -f <isofile> md0
  portsnap extract
mount -t cd9660 /dev/md0 <destination>
 
Unmount:
  umount <destination>
mdconfig -d -u md0
 
 
== Adding IP Alias ==
=== FreeBSD ===
Add an alias IP of 10.1.1.2. Alias IPs all have a netmask of 255.255.255.255.
 
  ifconfig re0 10.1.1.2 netmask 255.255.255.255 alias


If you want the changes to be persistent, add the following to <code>/etc/rc.conf</code>
You may also get the ports from svn:
  ifconfig_re0_alias0="10.1.1.2 netmask 255.255.255.255 alias"
svn co svn://svn.freebsd.org/base/releng/9.1 /usr/src
  svn up /usr/src


== Set a Gateway (Traffic Forwarder) ==
=== Linux ===
route add -net 10.10.2.0/24 dev INSIDE
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth2 (outside) -j MASQUERADE
iptables -A FORWARD -i eth1 -j ACCEPT


=== Upgrade FreeBSD ===
# mv /usr/src /usr/src.old
# svn co svn://svn.freebsd.org/base/release/9.1.0 /usr/src


== Upgrading pkgconfig to pkg-config on FreeBSD ==
To build and install 9.1-RELEASE:
  upgrade from pkgconf
  # mergemaster -p
  portmaster -o devel/pkgconf devel/pkg-config
# cd /usr/src
# make buildworld
# make buildkernel
# make installkernel
  # reboot
# cd /usr/src
# make installworld
# mergemaster -iU
# reboot


== Restarting Services ==
== User Management ==
=== Linux ===
Use any one of:
/etc/init.d/<service> restart
/etc/init.d/<service> stop && /etc/init.d/<service> start
service <service> restart


=== FreeBSD ===
=== FreeBSD ===
Usually, the startup scripts are located in <code>/etc/rc.d</code>
/etc/rc.d/<service> restart
However, if it is 3rd party software, they are located in <code>/usr/local/etc/rc.d</code>
/usr/local/etc/rc.d/<service> restart
If you are trying to restart NFS, you may do either:
/etc/rc.d/nsfd restart
kill -HUP `cat /var/run/mountd.pid`


=== Solaris / SunOS ===
Create a new user with a home directory /home/username:
The startup scripts are located in <code>/lib/svc/method/<service></code>
/lib/svc/method/<service> restart
svcadm restart <service>


Example: To restart ssh, do any one of:
  pw useradd -n username -s /bin/sh -m
svcadm restart ssh
   
  svcadm restart svc:/network/ssh
  /lib/svc/method/sshd restart


Remove a user and their home directory:


== wget to console ==
pw userdel -n username -r


Use the <code>-O -</code> option to output contents to the console.


wget -O - http://google.ca
Create a new group


== sed ==
pw groupadd groupname
=== Simple search / replace ===


sed 's/<search>/<replace>/g'
Show group


=== remove HTML tags ===
pw groupshow groupname


sed -e 's/<[^>]*>//g' <file>
Set user to group


== FreeBSD Ports ==
pw groupmod groupname -M username,user2,user3


=== Recursively Configure Ports ===
Add user to group
  make config-recursive
   
pw groupmod groupname -m user4


=== Ports Update / Upgrade ===
{{Navbox FreeBSD}}[[Category:FreeBSD]]
?

Latest revision as of 00:24, 15 June 2020

FreeBSD Ports

Recursively Configure Ports

make config-recursive

Ports Update / Upgrade

portsnap fetch
portsnap update   

or if you are doing this the first time, run:

portsnap fetch
portsnap extract

You may also get the ports from svn:

svn co svn://svn.freebsd.org/base/releng/9.1 /usr/src
svn up /usr/src


Upgrade FreeBSD

# mv /usr/src /usr/src.old
# svn co svn://svn.freebsd.org/base/release/9.1.0 /usr/src

To build and install 9.1-RELEASE:

# mergemaster -p
# cd /usr/src
# make buildworld
# make buildkernel
# make installkernel
# reboot
# cd /usr/src
# make installworld
# mergemaster -iU
# reboot

User Management

FreeBSD

Create a new user with a home directory /home/username:

pw useradd -n username -s /bin/sh -m

Remove a user and their home directory:

pw userdel -n username -r


Create a new group

pw groupadd groupname

Show group

pw groupshow groupname

Set user to group

pw groupmod groupname -M username,user2,user3

Add user to group

pw groupmod groupname -m user4