Programming TutorialsCommands for dealing with branching

These commands are used to deal with tagging and branching in SVN:
$ cd /path/to/project && svn copy trunk branches/mybranch-N && svn commit -m 'Created new branch'
$ cd /path/to/project/branches/mybranch-N

Read more...
29-10-2010, 08:31   |   Views: 308  

Programming TutorialsAdd Line Numbers

Add line numbers to your source code with expand and some quick perl:
expand /etc/motd | perl -pe 's/^/\t=$.=\t/'

Read more...
29-10-2010, 08:30   |   Views: 418  

Programming TutorialsAdding Users with Passwords

BSD is a little paranoid about where your passwords come from, so they'll insist on getting it from a stream. Here's an example:
(edit the file '/tmp/pass' and deposit the password there)
% su root -c sh
Password:
# pw useradd -n test -c "Test User" -m -h 3 3< /tmp/pass
# grep test /etc/master.passwd
test:$1$T2tu0BET$UGPrNB1FavzjlzhTwUWRN.:1002:1002::0:0:Test User:/home/test:/bin/sh
# exit
% su test
Password: [typed "foobar" here...]
$ exit

Read more...
29-10-2010, 08:28   |   Views: 406  

Programming TutorialsAdding Services

To add a service to boot automatically on startup, do the following:
# chkconfig --level 345 on

Read more...
29-10-2010, 08:26   |   Views: 368  

Programming TutorialsAdding a Database and a User

To create a Postgres user sam and a database samdb that is owned by the sam user:
$ su - postgres
$ createuser -P -A -D sam
$ createdb -O sam samdb
(Change the -A, and -D options to affect the new user's abilities.)

Read more...
29-10-2010, 08:26   |   Views: 380  

Programming TutorialsAdd a Newline to the End of a File

Use sed to add a newline to the end of a file (this will perform an in-place replacement and create a backup file, MYFILE.bak):
$ sed -i.bak '$G' MYFILE
Some programs, such as Emacs, will omit the trailing newline from a file unless configured to add one. Emacs can be configured to add a newline automatically.

Read more...
29-10-2010, 08:25   |   Views: 350