I have achieved the goal but in an unusual way.
Target: The original target was to restrict usres to do all kind of stuff after loging in. They only should be able to execute some specific commands.
Solution:
1. Created following script and placed it in /usr/bin,
Code:
command=11
while [ "$command" != "Q" -o "$command" != "q" ]
do
echo -e "\033[32m**************************************\033[0m"
echo -e "\033[32mEnter your command (1, 2, 3, 4, 5 or Q)\033[0m"
echo -e "\033[32m**************************************\033[0m"
echo -e "\033[36mdf -k : 1\033[0m"
echo -e "\033[36msar 1 5 : 2\033[0m"
echo -e "\033[36muptime : 3\033[0m"
echo -e "\033[36mfree mem : 4\033[0m"
echo -e "\033[36mPostpaid MMS Count : 5\033[0m"
echo -e "\033[36mQuit : Q or q\033[0m"
echo -e "\033[32m**************************************\033[0m"
echo -n "Your Selection: "
read command
echo " "
case "$command" in
1)
df -k
echo " "
;;
2)
sar 1 5
echo " "
;;
3)
uptime
echo " "
;;
4)
free mem
echo " "
;;
5)
echo -n "Please enter date: "
read target
/usr/bin/trstat.x $target 2>> /dev/null
echo " "
;;
Q)
exit
;;
q)
exit
;;
*)
echo -e "\033[31mBad command, your choices are: 1, 2, 3, 4, 5 or Q/q\033[0m"
echo
;;
esac
done
2. Created sort of another shell in /bin directory. Following is the content of shell file,
Code:
node1# cat ressh
#!/bin/bash
/bin/bash /usr/bin/login_script
node1#
3. For all users to be restricted, i modified /etc/passwd and set their default shell to
ressh.
Now when any restricted user logs in to the system, the above script is automatically executed and he have no choice but to select from the available command. Even if wants to hit Ctrl+C to exit from script, he instead will logout from the system.