Reputation: 499
I am new to UNIX so experiencing a little problem on Oracle SOLARIS 11 Virtual operating system for UNIX.
The issue is that after I type certain commands such as CAT
etc. UNIX Command Line goes into an unusable mode after which no new command works until you manually close the terminal with mouse and restart again.
I want to know a way by which I can immediately continue working with next statements even if I type such commands like CAT
(which make next commands not to work) without closing the whole terminal and restarting again. Respect for your precious time
I have a screenshot to make my problem easily understandable to you:
Upvotes: 1
Views: 1013
Reputation: 30823
As already stated, Unix doesn't go in an unusable state but simply does what you asked it to do. Here cat
is reading its standard input (keyboard) and displays it without further processing on its standard output (terminal).
There are a lot of other standard Unix utilities that read their stdin and write their stdout, this being the most common way to build complex commands from simpler ones under the Unix philosophy. The cleaner way to end the process is to enter the end of file character, commonly Control+D.
While both Control+C and Control+D will give you back the control of the command line, in the latter case the process is not interrupted but simply ends because it has nothing more to read.
Alternatively, should you do not want to end the process but recover the shell control anyway, you usually have the possibility to suspend the running process, and possibly put it later in the backgroud. You can do that with Control+Z and then the bg
command.
Note also that sometimes processes are ignoring Control+C, if Control+D doesn't work either, you can try sending the stronger quit
signal, normally with Control+\, which, in addition to interrupt the program will dump its binary image in a file (core) for later debugging.
Upvotes: 2
Reputation: 352
For this particular case where actually you have not dealt with a command correctly and that has caused you terminal to go into an unusable mode, the answer provided by Sevle is the one to help you.
My answer is for the case where you have entered the correct command in the correct format, which got the command execution started, now the command is taking long to complete and give you back the terminal. In such scenarios where you know beforehand that some command may take long to finish, do the following
<command> &
what is does is to fire up the command and then push the process generated from the command in the background, so that you can get back the terminal for your subsequent work without having to wait for the command to finish. The above command would return you a process id which you can use to take the process to foreground once again if you need it.
Once you get back the terminal after firing command with '&' character appended, use the command
ps
to get the list of all the processes that are executing now. You will see you processes currently running in you machine, including the process for your command. You can use the process ID from this list or from the return value returned right after the command was fired, to get the process to foreground. Use the below command for that -
fg
Upvotes: 1
Reputation: 3119
Press Ctrl + C to kill the cat process. Cat expects user input from stdin and that's the reason why the process won't stop unless you explicitly state that you want to stop it.
Check out Unix signals for more information.
Upvotes: 1