Personal Scripts
(Created page with " == Personal Scripts == FBSD is a command line driven operating system. It's very hard to remember where all the config files are and what they are called. You have to be co...")
Latest revision as of 19:39, 13 August 2012
[edit] Personal Scripts
FBSD is a command line driven operating system. It's very hard to remember where all the config files are and what they are called. You have to be constantly working on your FBSD systems on a daily basis to remember all the commands you use to do repetitive things. I found that if I build a simple shell script and place the command I use, or the sequence of commands I used to perform repetitive tasks, I can give the script a long name that self describes what it does. All users have a bin directory which they can save their canned scripts in. The users bin directory is not created as part of the FBSD install so you must make one for root.
cd /root
mkdir bin
Now lets say for example I use IPFILTER for my firewall. I repeatedly edit the filter rules, load the rules, edit the NAT rules, and load the NAT rules. I simplify these admin functions by creating simple scripts with meaningful names.
ipf.edit.rules ipf.load.rules ipf.edit.natrules ipf.load.natrules
Here is how to create simple script.
cd /root/bin
ee ipf.edit.rules
#! /bin/sh ee /etc/ipf.rules Close and save the file. ls -l # will show you that this file only has read and write permission. It needs execute permission to run. chmod 700 ipf.edit.rules # give it execute permission for root owner only rehash # let the shell know about it
Enter ipf.edit.rules on the command line, and you find yourself looking at the screen displaying your rules file open and ready to edit.
Every time you want to create another script, copy an existing one and it will already have the correct permissions to execute.