Knowee
Questions
Features
Study Tools

How do you customize the PS1 prompt to display the current working directory?*1 pointa) PS1="%C"b) PS1="%d"c) PS1="%H"d) PS1="%P"

Question

How do you customize the PS1 prompt to display the current working directory?*1 pointa) PS1="%C"b) PS1="%d"c) PS1="%H"d) PS1="%P"

🧐 Not the exact question you are looking for?Go ask a question

Solution

The correct answer is d) PS1="%P". This command will customize the PS1 prompt to display the current working directory. Here are the steps to do it:

  1. Open your terminal.
  2. Type PS1="%P" and press Enter.
  3. Now, your prompt should display the current working directory.

Please note that this change is temporary and will be reset once you close the terminal. If you want to make it permanent, you need to add this line to your shell's startup file, which is usually ~/.bashrc or ~/.bash_profile for the bash shell. Here are the steps:

  1. Open your shell's startup file with a text editor. For example, you can type nano ~/.bashrc or nano ~/.bash_profile and press Enter.
  2. Add the line PS1="%P" to the file.
  3. Save the file and exit the text editor.
  4. Restart your terminal or source the startup file by typing source ~/.bashrc or source ~/.bash_profile and pressing Enter.
  5. Now, your prompt should always display the current working directory.

This problem has been solved

Similar Questions

Which character is used to represent the username in the PS1 prompt string?*1 pointa) %ub) %nc) %hd) %p

What would you enter at the shell prompt on a Linux system to display the present working directory?

Bourne Again Shell (bash), similarly to other UNIX shells utilises environmental variable PS1'' to store prompt string description. Willing to change it, it is enough to replace its value with a new one. The most permanently looking effect can be obtained by performing adequate substitution in start script, which in case of bash is in ~/.bash_profile'' file (~'' stands for the home directory of a user in question).Prompt string can contain sequences like \x'', where x - a character, which during printing of prompt will be interpreted and substituted with specific information, e.g. \t'' - actual time. Description of other standard sequences can be found in man page concerning bash (man bash).Task: Permanently set URL-like prompt of the form:

How can you change the shell prompt temporarily for the current session?*1 pointa) Modify .bashrc and restart the shellb) Use the 'chsh' commandc) Use the 'PS1' environment variabled) Use the 'exit' command

In Linux, what does the PS1 environment variable control?*1 pointa) System passwordb) Shell promptc) Disk spaced) User profile

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.