I had an unusual error after creating a CIS Hardened Ubuntu 18.04 image from the Azure Marketplace. As soon as I would log on I would get the error: -bash: [: too many arguments.
I asked the question on EE and this is what we did to find the answer:
I logged on and ran an strace: strace bash -l 2>output.txt
While that was running I logged on to another session. As soon as I got the error after logging in, I stopped the strace process on the first session.
I opened the output.txt file in Notepad++ and did a search for -bash: [: too many arguments
and found this:
write(2, "/etc/profile: line 22: [: too ma"..., 45/etc/profile: line 22: [: too many arguments
) = 45
I opened /etc/profile and commented out the lines:
#if [ -d /etc/profile.d ]; then
# for i in /etc/profile.d/*.sh; do
# if [ -r $i ]; then
# . $i
# unset i
I logged on again and didn't get the error.
What we ended up doing was deleting the file in /etc/profile.d called '*.sh' using; rm -fi '*.sh'