Helpful UNIX Customizations

Setting the date:

Since having a correct date is very important in networking, you should make sure you have a correct date everytime you log in. You can type date to see the date, and compare that to your laptop to make sure it's correct. If it's not, you want to set the date. How will you remember to do this every time? Add a reminder to the "Message of the Day" that the system already prints every time you login.

    Change the date using format mmddHHMMyyyy,
       e.g., 011314452016 for 13 Jan '16, 2:45pm (14:45) would be
    sudo date 011314452016

The way you add those three lines to the end of your /etc/motd file is to copy them from above and then:

    sudo vi /etc/motd
    G              (jump to last line in the file)
    o              (opens a new line below last line; puts you in insert-mode)
    Control-v      (paste the contents of the 3 lines above)
    ESC            (to get out of insert-mode)
    :wq            (write and quit)

To test it, type cat /etc/motd. The next time you login to your pi, you should see the reminder.

You can also set the time zone on your pi (this should only have to be done once).

Mac users: if you want to set the date to the same date as your Mac with just a copy and paste, create an alias for yourself on your Mac (not your pi), e.g. alias pidate='date "+%m%d%H%M%Y"' in some dot file that is getting executed on your Mac. Then you can run pidate on the Mac and paste the output into the date command on your pi. If you want the date in your local time zone, leave off the -u, and set the time zone on your pi.

Customizing via dot files:

To make myself more efficient, the first thing I do on any Unix machine is to get a good set of dot files in place (aliases, environment variables, etc). I especially want to have the aliases back, l, ll, and recent, a good PS1 primary prompt, and my usual .vimrc.

If you want to use the aliases, environment variables, or vi configuration information I have made available on GitHub, you can copy and paste the contents into files on the pi even without a file transfer mechanism. You can copy the contents right from GitHub while viewing them there, or from a cloned or downloaded repository on your laptop. (The GitHub url is here)

The simple way to create any of these files on the pi, if they are not already there, is to use the cat command and redirect standard output to the new file (this will create or overwrite the file). E.g.,

    cat >.bash_aliases
      <paste the contents of the file>
    Control-D                        End-of-file

You can do this for any new dot files, e.g., .bash_aliases, .bash_aliases-linux, .env_vars, .bashrc_custom, and .vimrc. This will get you the aliases and vi settings, although the nice primary prompt is commented out. If you want that, edit .env_vars and delete the commenting before the two PS1 lines that have color codes in them (e.g., \033). For example:

    vi .env_vars
      <use arrows to move to one of the two PS1 lines with color codes>
    xx             (delete the # sign and the space after it)
      <use arrows to get to other PS1 line with color code>
    xx             (delete the # sign and the space after it)
    :wq            (write and quit)

To get the system to execute your new files, you will also need to add a few lines to your existing .bashrc file. You can include a blank line and the three lines of code you need

    if [ -f $HOME/.bashrc_custom ]; then
        . ~/.bashrc_custom;

by editing the .bashrc and copying and pasting them. If you make a mistake at any point, just do "ESC :q!" (without the quotes).

    vi .bashrc
    G              (jump to last line in the file)
    o              (opens a new line below last line; puts you in insert-mode)
    Control-v      (paste the contents of the 4 lines above)
    ESC            (to get out of insert-mode)
    :wq            (write and quit)

If the final fi is not on the left margin, aligned with the if, then move the cursor to that line while in vi and type << to shift the line left (or delete spaces using x).

These hints are from Alyce Brady. These should also work on your "pi" and most distributions of Linux. Feel free to email the instructors if you have any other helpful hints.

This page is maintained by Gerry Howser ghowser{at}kzoo{dot}edu.
Official Disclaimer