I made the mistake of running the command:
cat /dev/urandom
And the console (hosted on Windows) filled with junk and stopped responding to Ctrl-Z or anything else.
Is there any way I could have recovered the console from this?
I made the mistake of running the command:
cat /dev/urandom
And the console (hosted on Windows) filled with junk and stopped responding to Ctrl-Z or anything else.
Is there any way I could have recovered the console from this?
First of all I want to highlight there is a significant difference between ctrl+z and ctrl+c:
More about the signals you can read at man 7 signal.
Sometimes just closing the terminal window is not the best solution because you will lost the recent history which could be important for you.
By opening another terminal window (or TTY at real Linux) you can try to kill the cat process by either of the following commands.
killall -s 9 cat
The command killall kills processes by name and it will try to kill all cat processes. The option -s 9 will send SIGKILL instead SIGTERM which could be read as force kill. In most cases just killall cat is enough.
kill -9 $(ps -e | awk '/cat/ {print $1}')
The command kill will send a signal to a process and by the option -9 we will send SIGKILL as in the above command, but here we must provide PIDs (process identifiers) instead of names. The command substitution $() will provide a list of all cat processes running on the system. Here is haw:
ps -e will list all running processes on the system,| as input to the awk command,awk '/cat/ {print $1}' will filter the list by printing the first field $1 of each line that contains the string cat. This first field contains the PID of the relevant process.Note in both commands you do not need to use sudo because normally your user should be the owner of the cat process(es).