text stuck on screen

eumdaeum

New Member
Joined
May 6, 2024
Messages
1
Reaction score
0
Credits
12
I am a beginner using kali linux and I am attempting to change my PS1 enviornment variable and the text I put in is stuck on screen despite pressing CTRL+C and CTRL+D is not acting normally and it's closing the terminal.
1714952530446.png
 


beginner + kali = ......does not compute
 
Hello @eumdaeum

I note that you are a young teenager, and evidently keen to continue with linux, so kudos and plaudits to you! Congratulations on such a judicious choice of interest.

If the following is a bit obscure to you, you might like to consider looking at another distro other than Kali, that is, a more fully-featured distro that is more comprehensive in what it offers the user.

Here a few questions, the answers of which would be helpful to the issues you have written.

1. Where is the prompt for zsh configured?
2. What does Cntl+c do?
3. What does Cntl+d do?
4. Where are persistent environment variables configured?
5. What have the developers of Kali designed the OS for?

Here are some reflections on the questions:
1. /home/<user>/.zshrc is the usual file to configure the prompt for zsh. There are numerous examples of prompt configs online. You add the configured PS1 variable to the file (without deleting anything else there), save the file, and source it with a command like: source .zshrc, and then the terminal in which it's been sourced will run the new prompt. Next time there's a login, the new configuration will operate.

2. and 3. Run the command: stty -a, and the output will show that Cntl-c is the "interrupt" command, and that Cntl+d is the "end of file" command. Cntl+c will stop a process running in the terminal by interrupting it. For example, run the command: yes, in the terminal, and then press Cntl+c to interrupt and stop it. Cntl+d on the other hand will close the terminal itself because it sends the "end of file" message to the shell and since the terminal is a file to the system, the shell closes it.

4. Environment variables, to persist for the user, can be set in the home user's dotfiles, one of which is
/home/<user>/.zshrc. For the environment variables to persist for the whole system they can be set by the root user in /etc/environment.

5. To see what the Kali developer's have designed Kali for, and whom they think it suits to use, see: https://www.kali.org/docs/introduction/should-i-use-kali-linux/
and please note post #3 by @Condobloke
 
Last edited:
Ctrl + d is the shortcut for EOF (end of file).
Pressing ctrl + d whilst running a terminal based program that reads from stdin will stop it from receiving input and then it will typically do whatever it needs to do with any input received, before finally ending and returning you to a prompt.

But if you’re already at your prompt in the terminal, with nothing running in the foreground - if you press ctrl + d, the terminal itself will stop receiving input from the user and the terminal WILL close. This is entirely correct and expected behaviour.

ctrl + d is a perfectly acceptable way to exit a shell. I use it all of the time. Mostly because it’s quicker than entering the exit command (5 characters including the enter key vs 2 characters pressed at once (ctrl+d) - it’s a no brainer!)

Ctrl + c (interrupt) is used to interrupt/cancel a running command.
But whilst at your prompt in a terminal, ctrl + c isn’t going to do anything. Other than interrupting/cancelling whatever you might have already started to type on the current line and will drop you to a new line, before outputting your prompt and waiting for input from you.

Running ctrl + c (interrupt) after changing your prompt isn’t going to cancel the change to the prompt, because once you’ve changed your prompt via a change to the PS1 variable, there’s nothing running to interrupt. The shell is waiting for you to enter another command.

So pressing ctrl + c at this point will just interrupt the current line and drop you back to a fresh line with your new prompt.

So again, you’re seeing expected behaviour.

As Osprey pointed out, any change made to your PS1 in the terminal will only affect the environment of the current instance of your shell (bash/zsh) until it is closed/dismissed, or until you change the prompt again.

To revert your prompt back to its original state, you can simply close the terminal and open a new instance, or reload your config file (.bashrc for bash, or .zshrc for zsh). Or you could manually set PS1 back to its original value.

In order to make a permanent change to PS1 - you need to set the PS1 environment variable in the config file for your shell.
 
I am a beginner using kali linux and I am attempting to change my PS1 enviornment variable and the text I put in is stuck on screen despite pressing CTRL+C and CTRL+D is not acting normally and it's closing the terminal.View attachment 19755
You can't assign just any garbled text to PS1 variable and expect it to work.
That variable is expecting text that formats the prompt.
 
Last edited:
Welcome to the forums
Kali is not for those unfamiliar with Linux
Kali is not "Kool"
Kali has one job and only one job as purely a tool for professional pen-testers
Please learn Linux using a standard desktop distribution before you you Bulk your machine. [and you will at some point]
 
You can't assign just any garbled text to PS1 variable and expect it to work.
That variable is expecting text that formats the prompt.
Yes, to make a prompt that includes some information like the user's name and the hostname, it's the formatting for PS that will achieve that. Not thinking that you were referencing alternatives, it's nevertheless quite possible to have the shell working with any number of creative turns without the formatting, however uninformative it is:
Code:
[tom@min ~]$ ls
file1 file2 file3 file4

[tom@min ~]$ PS1="funnyFace:-) "

funnyFace:-) ls
file1 file2 file3 file4

funnyFace:-) PS1="\[\e[32;1m\][\u@\h \w]$ \[\e[0m\]"
[tom@min ~]$ ls
file1 file2 file3 file4

[tom@min ~]$
 
Yes, to make a prompt that includes some information like the user's name and the hostname, it's the formatting for PS that will achieve that. Not thinking that you were referencing alternatives, it's nevertheless quite possible to have the shell working with any number of creative turns without the formatting, however uninformative it is:
You're right, I just tested OP's sample in Kali and it works in my case, not sure what the problem is:

kali.png
 

Members online


Latest posts

Top