Showing posts with label Administration. Show all posts
Showing posts with label Administration. Show all posts

Wednesday, December 12, 2007

Changing Environmental Variables

It's really handy to be able to change the way your shell works for you. Being able to add aliases, and other options makes the shell a much more powerful tool. Changing or setting environmental variables is done differently for each shell.

To change an environment variable in csh or tcsh use:$ setenv NAME "value"where NAME is the name of the variable and "value" its new value.

To change an environment variable in /bin/sh use:
$ VARIABLE="value"
$ export VARIABLE

You can permanently set environment variables for your shell by putting them in a startup file for the shell. The name of the startup file varies depending on the shell;
csh and tcsh uses .login,
bash, sh, ksh and zsh use .profile.
When using bash, sh, ksh or zsh, don't forget to export the variable.

*Note:
.login and .profile are to set conditions which apply to the whole session and to perform actions that are relevant only at login.

.cshrc and .shrc are used to set conditions and perform actions specific to the shell and to each invocation of it.
The guidelines are to set ENVIRONMENT variables in the .login, .profile file and SHELL variables in the .cshrc, .shrc files.

Monday, December 03, 2007

Protecting Your Terminal

BSD Quick Tip
When ssh across my systems I often need to step away from the keyboard for a few minutes. This can pose a massive security threat to the system, therefore I think it's important to lock the terminal, this way I don't need to log in/out, nor leave the system insecure.

In all of the BSD's you can use a built-in utility called
lock(8). When you use:$ lockwithout any options you will be asked to enter a key twice. Then your terminal will be locked for 15 mins, after that time it will become available again.

Options:
To keep your terminal locked until you return, (no 15 minute timeout), use:$ lock -n
To use your normal user password instead of a key you enter use:$ lock -p
Personally I like to use these options all of the time, therefore I add an alias so I only have to type lock.

To Alias `lock -np` to `lock` in csh or tcsh:$ edit ~/.cshrcadd:alias lock lock -np
To Alias lock -np to lock in sh:$ edit ~/.shrcadd:alias lock='lock -np'

Sunday, December 02, 2007

Humanise the output of OpenBSD's root mail

OpenBSD Quick Tip
I've discussed how to humanise the output of FreeBSD's root mail, and the same can be achieved in OpenBSD by running the following commands:# vi /etc/daily
change:df -klto:df -hikl

Humanise the output of FreeBSD's root mail

FreeBSD Quick Tip
The output of the root mail, daily run: disk status is in bytes, which is not quick and easy to read. To humanise this output and to show you the inodes being used do the following:
# vi /etc/periodic/daily/400.status-disks
change:df $daily_status_disks_df_flags && rc=1 || rc=3todf -hi $daily_status_disks_df_flags && rc=1 || rc=3