default shell for the user


 
Thread Tools Search this Thread
# 1  
default shell for the user

for example, if we specify,
Code:
#!/usr/bin/ksh

then the script will be executed in korn shell.
If we don't specify that line, the script will be executed using the default shell.
So, how we can identify the default shell for the current user?
Will it be in .profile file ?

Thanks
# 2  
Code:
grep "username" /etc/passwd

last field
# 3  
echo $SHELL

Quote:
Originally Posted by pandeesh
for example, if we specify,
Code:
#!/usr/bin/ksh

then the script will be executed in korn shell.
If we don't specify that line, the script will be executed using the default shell.
So, how we can identify the default shell for the current user?
Will it be in .profile file ?

Thanks
Hello,

use echo $SHELL

Regards
# 4  
use echo $0
Code:
$ echo $0
-bash


Last edited by Franklin52; 01-16-2012 at 04:26 AM..
# 5  
Thanks!!
Code:
pandeeswaran@ubuntu:~$grep "pandeeswaran" /etc/passwd|cut -d: -f7
/bin/bash

also works

---------- Post updated at 11:53 PM ---------- Previous update was at 11:51 PM ----------

i have one more query:
Code:
pandeeswaran@ubuntu:~$ echo $0
bash
pandeeswaran@ubuntu:~$ echo $SHELL
/bin/bash

Why echo $0 returns bash alone where as the second command returns /bin/bash?

Thanks
# 6  
Echo $0 ==>will give you the shell type
Echo $SHELL ==> will give you the absolute path of the shell

thanks,
venkat
# 7  
Thanks!
I have tried the below code for listing out all the shells:
Code:
#!/bin/bash
echo $SHELL
#!/bin/sh
echo $SHELL
#!/bin/csh
echo $SHELL
#!/bin/ksh
echo $SHELL
#!/bin/csh
echo $SHELL
#!/bin/zsh
echo $SHELL
#!/bin/ash
echo $SHELL

But i have got the result as:
Code:
/bin/bash
/bin/bash
/bin/bash
/bin/bash
/bin/bash
/bin/bash
/bin/bash

After that i have understood that
Code:
echo $0

is giving the subshell.
So i have changed the script to:
Code:
#!/bin/bash
echo $0
#!/bin/sh
echo ${0}
#!/bin/csh
echo ${0}
#!/bin/ksh
echo ${0}
#!/bin/csh
echo $0
#!/bin/zsh
echo $0
#!/bin/ash
echo $0

But i am getting :
Code:
pandeeswaran@ubuntu:~$ ./shells_1
./shells_1
./shells_1
./shells_1
./shells_1
./shells_1
./shells_1
./shells_1

Please help me to achieve to list out the shells.

Thanks
 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Switch from Local user to root user from a shell script?

Hi, I need to switch from local user to root user in a shell script. I need to make it automated so that it doesn't prompt for the root password. I heard the su command will do that work but it prompt for the password. and also can someone tell me whether su command spawns a new shell or... (1 Reply)
Discussion started by: Little
1 Replies

2. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

3. Shell Programming and Scripting

Change default shell of a specific user with awk

I would like to replicate the functionality of chsh (or passwd -e) by awk. This is what I got so far, but I think there should be an easier way to search and replace field $7 only for lines beginning with user_name: awk -v user_name="$user_name" -v new_shell="$new_shell" -F: '$1 == user_name {... (2 Replies)
Discussion started by: nomad84
2 Replies

4. Shell Programming and Scripting

How to Login as another user through Shell script from current user[Not Root]

Hi Every body, I would need a shell script program to login as different user and perform some copy commands in the script. example: Supppose ora_toms is the active user ora_toms should be able to run a script where user: ftptomsp pass: XXX should login through and run the commands ... (9 Replies)
Discussion started by: ujjwal27
9 Replies

5. UNIX for Dummies Questions & Answers

FTP user default shell defunct

Hello, I have a problem with my FTP users. I have create the ftp user on my AIX server, I set the default shell /bin/false or /usr/bin/false. Its enough that the user can logon via FTP. But when I try the user for example via ssh, the shell session is not killed, the session is defunct... (4 Replies)
Discussion started by: kalaso
4 Replies

6. UNIX for Dummies Questions & Answers

How to change Default Shell for any user?

Hi, I am new for solaris... how can we change default shell for any user and how to check that which shall currently we are in...... (1 Reply)
Discussion started by: lalit21984
1 Replies

7. Shell Programming and Scripting

root user command in shell script execute as normal user

Hi All I have written one shell script for GPRS route add is given below named GPRSRouteSet.sh URL="www.google.com" VBURL="10.5.2.211" echo "Setting route for $URL for GPRS" URL_Address=`nslookup $URL|grep Address:|grep -v "#"|awk -F " " '{print $2}'|head -1` echo "Executing ... (3 Replies)
Discussion started by: mnmonu
3 Replies

8. Virtualization and Cloud Computing

Cloud User Shell 1.0 (Default branch)

http://c.fsdn.com/fm/screenshots/70112_thumb.png Cloud User Shell (cush) is a multi-call executable bringing RESTful cloud control to the command line, combining many useful cloud computing utilities into a single executable. It follows the Unix philosophy of writing components that work together,... (0 Replies)
Discussion started by: Linux Bot
0 Replies

9. Shell Programming and Scripting

How do i change to super user then revert back to ordinary user ,using shell script?

Hi all, I am trying to eject the cdrom from a livecd after certain stage... Now assuming that it is possible to eject,please consider my issue!!! The OS boots into a regular user by default...so i am unable to use the eject command to push out the drive... However if i try pfexec eject it... (3 Replies)
Discussion started by: wrapster
3 Replies

10. Shell Programming and Scripting

New z-shell user

Hi, I've just downloaded the following files and have been tinkering with using zsh on my NT box. Z-shell executable: ftp://ftp.blarg.net/users/amol/zsh/zsh.exe.gz Unix Utilities: http://homepage.mac.com/shadowboxer/unxutils.exe First impressions are good but I have 2 questions.... (0 Replies)
Discussion started by: Damian Ibbotson
0 Replies

Featured Tech Videos