echo ~ executed by user alice. What will it output?echo ~
The tilde (~) is a shortcut that the shell expands to the current user's home directory path. For user alice, this is typically /home/alice.
echo ~root when run by a normal user?echo ~root
The shell expands ~root to the home directory of the root user, which is usually /root.
bob's home using a shortcut. Which command is correct?cd ~bob changes directory to bob's home directory. Options A and B are incorrect because ~/bob means 'bob' folder inside current user's home, and ~ /bob is invalid syntax. Option D is valid and equivalent to C; the trailing slash is optional and does not change meaning.
~+ represent in the shell?~+ expand to?The shortcut ~+ expands to the current working directory, same as the shell variable $PWD.
cd /tmpecho ~-What will be printed?
cd /tmp echo ~-
~- expands to the previous working directory.The shortcut ~- expands to the previous working directory. Assuming the user started in /home/alice and then changed to /tmp, ~- will expand to /home/alice.
