mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-09 05:44:23 +00:00
chore(kb): get users' login shell
This commit is contained in:
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@@ -64,6 +64,7 @@
|
||||
"freshclam",
|
||||
"gbps",
|
||||
"gcloud",
|
||||
"getent",
|
||||
"getfacl",
|
||||
"getfattr",
|
||||
"gettext",
|
||||
@@ -158,6 +159,7 @@
|
||||
"sysrc",
|
||||
"systool",
|
||||
"tclsh",
|
||||
"TCSH",
|
||||
"templating",
|
||||
"tfvars",
|
||||
"tmpfs",
|
||||
|
||||
48
knowledge base/get users' login shell.md
Normal file
48
knowledge base/get users' login shell.md
Normal file
@@ -0,0 +1,48 @@
|
||||
# Get users' login shell
|
||||
|
||||
1. [TL;DR](#tldr)
|
||||
1. [Further readings](#further-readings)
|
||||
1. [Sources](#sources)
|
||||
|
||||
## TL;DR
|
||||
|
||||
```sh
|
||||
# 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'
|
||||
```
|
||||
|
||||
## Further readings
|
||||
|
||||
### Sources
|
||||
|
||||
- [Users don't appear in /etc/passwd on Mac OS X]
|
||||
|
||||
<!--
|
||||
References
|
||||
-->
|
||||
|
||||
<!-- In-article sections -->
|
||||
<!-- Knowledge base -->
|
||||
<!-- Files -->
|
||||
<!-- Upstream -->
|
||||
<!-- Others -->
|
||||
[users don't appear in /etc/passwd on mac os x]: https://superuser.com/questions/191330/users-dont-appear-in-etc-passwd-on-mac-os-x#1425510
|
||||
@@ -142,6 +142,10 @@ launchctl stop 'job_label'
|
||||
|
||||
# Enable file trimming on SSD.
|
||||
sudo trimforce enable
|
||||
|
||||
|
||||
# Get information about users.
|
||||
dscl '.' -read "/Users/$USER" 'UserShell'
|
||||
```
|
||||
|
||||
## Hidden settings
|
||||
|
||||
Reference in New Issue
Block a user