Unless you need to type a password when you run newgrp
(a very rarely used feature), you don't need to use newgrp
to make files owned by the appropriate group. You can use chmod
instead. For example, instead of the following workflow:
newgrp lab1
mkdir project1
$EDITOR project1/file1
you can do this:
mkdir project1
chgrp lab1 project1
$EDITOR project1/file1
chgrp lab1 project1/file1
On most current unices, either project1/file1
will already belong to lab1
like the directory it contains (*BSD), or you can force this behavior (Linux, Solaris, …):
mkdir project1
chgrp lab1 project1
chmod g+s project1
$EDITOR project1/file1
All of this requires that your umask
be set to 002 or 007.
It's easier to manage permissions if access control lists (ACL) are supported. ACL support must be present in the disk filesystem driver and enabled in the mount options, and again for the network filesystem if applicable. ACLs support is not yet generalized, so you might not have it.
To see if you can use ACLs, on a Linux client, try running
touch foo
setfacl -m user:myfriend:rwx foo
ls -l foo
If the permissions of foo
show up as -rw-rw-r--+
or similar (with a +
at the end), ACLs are enabled. If the setfacl
utility isn't available, then your campus network probably doesn't have ACLs all around.
If you do have ACLs, then you don't need to have a permissive umask, you can stick with 022 or 077. With ACLs, to set up a group-writable directory (where newly created files will be writable by the group as well), do
mkdir project1
setfacl -m group:lab1:rwx project1; setfacl -d -m group:lab1:rwx project1
In addition to not requiring a permissive umask, ACLs let you share files between an arbitrary set of users and groups.
To load environment variables you've put into a file, you can use the source
command. e.g.
See current path:
> echo $PATH
/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
File with custom environment settings..
> cat exports
export PATH="/home/me/bfin2012:$PATH"
export ...
Load custom environment
> source exports
Confirm changes.
> env | grep '^PATH'
PATH=/home/me/bin2012:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin
Best Answer
You can make
.tcshrc
check a special environment variable (likesubuser
), and conditionallysource .tcshrc_cust
. When you log in, runsubuser=nozimica tcsh
. It will get that enironment variable and execute your custom rc script. In addition, vim's:sh
command will work. You can even make it fancy andsource .tcshrc_$subuser
; that way everyone could do it.You can skip the part where you run
subuser=nozimica tcsh
when you login by having ssh run it for you. If you setup ssh key authentication, then in~/.ssh/authorized_keys
on the server, you can prefix your key withcommand="subuser=nozimica tcsh"
, and ssh will run that command for you.