Simple Shell Script to Create Quicklink in Home Folder

Lately I’ve been finding myself working predominantly in and around a particular directory for a day or two, and then moving somewhere else. I like a lot of organization in my file system, but the downside to that is a lot of times, the project I’m working on is buried many levels deep in my folder structure, and I start to spend a lot of time typing out change directory commands (okay, not a lot, but definitely enough to be annoying!). Today I wrote a script to do something about it. Now all I have to do is type set-current from any directory, and a link to the current directory titled current will be placed in my home folder. Here’s the script:

#!/bin/sh
# set-current
 
if [ -e $HOME/current ]; then
    echo "Overwrite $HOME/current? (y or n)"
    read answer
    if [ $answer = y ]; then
        rm $HOME/current
        ln -s $PWD $HOME/current
    fi
else
    ln -s $PWD $HOME/current
fi

Place set-current in /usr/local/bin, or any other place you wish in your PATH and that’s it.

Samba – Setting up Public and Private Shares

smb.conf:


[global]
security = user
encrypt passwords = true
map to guest = bad user
guest account = nobody
create mask = 0644
directory mask = 0755

[PrivateShareName]
comment = File Server
path = /path/to/private/share
browseable = no
read only = no
valid users = USER

[PublicShareName]
comment = Media Drive
path = /path/to/public/share
read only = yes
guest only = yes
guest ok = yes

Be sure to add USER to the samba password database by executing the following on the samba server:
$ smbpasswd -a USER

The smb.conf shown above will create two shares, a public share named PublicShareName located at /path/to/public/share which is available to everyone read only, and a private share named PrivateShareName located at /path/to/private/share invisible to all except USER, who has full access.

Attribute Explanations:

security = user
A user must present a valid username and password to access the share.

map to guest = bad user
Logon attempts with an invalid username/password combo will be rejected, unless the username doesn’t exist on the server, then the user will be treated as guest.

create mask = 0644
This is a mask which is logically ANDed with the permissions on the client file system. The easy way to think about it is the max permissions a file stored on the share from the client can have. 0644 gives read access to all, write access to the file’s owner, and execute access to none.

directory mask = 0755
Same as create mask, but for directories. 0755 is the same as 0644, but with execute permission given to all. This is necessary for directories.

browseable = no
This prevents the share from being viewable on the network’s list of available shares.

For further information, see the smb.conf man page at samba.org or the free ebook, Using Samba, 2nd Edition.

cluefire.com beta

Welcome.

This site was just installed today, so you’ll find that the shelves are all empty. In time, they’ll be stocked with information I’ve found useful and notes on projects I’m working on or have worked on. My hope and belief is that if I’ve found a particular piece of information useful, then someone else probably will also. Now for some SEO so folks actually have a chance at coming across this info!