Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )

Advanced DNS Management
New ZoneEdit. New Managment.


Sign Up Now
Reply to this topicStart new topic
> .bash_profile Permissions, adding users to groups after login
post Apr 9 2003, 07:31 AM
Post #1

Whats this Lie-nix Thing?

Group: Members
Posts: 6
Joined: 11-March 03
Member No.: 538

I have added the following code as root to a users
.bash_profile file so they will be prompted with a menu
and depending on their choice will join another group,
but when the user1 has choosen 1, permission is
denied on the change group command presumably
because it is being executed by a simple user and not
root, it had worked outside the case statement at one stage but not inside and need it to work within
the case statement.

Could you please help find a way round it.
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc

# User specific environment and startup programs


export PATH

# menu

echo "-----------------------------------"
echo "Main Menu"
echo "------------------------------------"
echo "[1] Group1"
echo "[2] Group2"
echo "[3] Group3"
echo "[4] Group4"
echo "[5] Exit"
echo -n "Enter your menu choice [1-5]: "
read yourch
case $yourch in
1) gpasswd -a user1 group1;;
2) echo "Group2"; read;;
3) echo "Group3"; read;;
4) echo "Group4"; read;;
5) exit 0;;
*) echo " Bad choice, choose again"; read;;
Go to the top of the page
+Quote Post
post Apr 9 2003, 09:22 AM
Post #2

Its GNU/

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3

As you said, when a user logs into their shell, everything in the .bash_profile is run as user only. Therefore, any change of groups cannot be done in this method, unless you want to give users permissions that you may not really want them to have. I think that as a sysadmin, you would want to have tighter control over what group a user is in. You may have to look for a different method of acheiving your goal.

Corey Quilliam
(former) Administrator

Want to help out Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 22nd July 2018 - 05:10 PM