mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
1.3 KiB
1.3 KiB
Get users' login shell
TL;DR
# Works on Linux and Mac OS X.
# Tested with BASH, CSH, DASH, FISH, KSH, TCSH and ZSH.
finger "$USER" | grep 'Shell:' | awk '{print $NF}'
# Works on Linux.
# Tested with BASH.
getent passwd "$USER" | awk -F ':' '{print $NF}'
getent passwd "$USER" | cut -d ':' -f '7'
# Works on Linux.
# Does *not* work on Mac OS X because it uses Apple's OpenDirectory and only
# refers to '/etc/passwd' or '/private/etc/passwd' when in single user mode.
# Tested with BASH.
grep "$USER" '/etc/passwd' | awk -F ':' '{print $NF}'
grep "$USER" '/etc/passwd' | cut -d ':' -f '7'
# Works on Mac OS X.
# Does *not* work on systems without OpenDirectory.
# Tested with BASH, CSH, DASH, FISH, KSH, TCSH and ZSH.
dscl '.' -read "/Users/$USER" 'UserShell' | awk '{print $NF}'
dscl '.' -read "/Users/$USER" 'UserShell' | cut -d ' ' -f '2'