How do you change directory in Linux?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Linux / Shell Scripting basics — a prerequisite for any developer role.
Answer
Use the cd (change directory) command. cd /path/to/dir moves to an absolute path. cd dirname moves into a subdirectory relative to the current location. cd .. moves up one level. cd ~ or just cd moves to your home directory. cd - returns to the previous directory. Example: cd /var/www/html navigates to the web root. The current directory is always represented by . and the parent by ...
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Linux / Shell Scripting candidates.
Previous
How do you list files and directories in Linux?
Next
How do you display the current working directory?