Last active
January 20, 2024 07:57
-
-
Save azazar/41d170f38e6762fb6912aa15c58304f0 to your computer and use it in GitHub Desktop.
Aliases that changes the current directory to the home directory of a specified user and then starts a new shell session as that user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For users with read-only or otherwise unusable HOME directory | |
alias www='sudo -u www-data /bin/bash -c "mkdir -p /tmp/$(id -n -u)-home && cd /tmp/$(id -n -u)-home && (test -e realhome || ln -s $(getent passwd www-data|cut -d':' -f6) realhome) && HOME=/tmp/$(id -n -u)-home exec /bin/bash -l"' | |
# For users with writable HOME | |
alias uuu='cd $(getent passwd www-data|cut -d':' -f6) && sudo -u www-data -s /bin/bash' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment