0

I'm new to Linux (I am running Ubuntu). I am learning new commands for the terminal and even following some guides/forums on how to do stuff. Sometimes I will type a command and the terminal makes a newline then sits with a blinking cursor after the last command I typed.

Sometimes I think the computer is just thinking and needs time to do something (although it would be nice to have some sort of indication of the progress on the given task). Sometimes the terminal progresses to let me type a new command and other times I wait a few minutes before pressing ctrl+c to stop whatever it was doing.

It would be nice to know what I'm dealing with here so I can judge better whether I am supposed to be waiting or just wasting my time.

4
  • 2
    What particular command are you typing in the terminal?
    – ryekayo
    Jul 7, 2014 at 0:15
  • Look at this command: sudo chmod +x Naruto.sh it do nothing that mean done i think your command is somthing like this. Jul 7, 2014 at 12:33
  • @Naruto Yes, that's the command. I was trying to do "sudo chmod" something on a partition else where on my computer (rather than the partition Linux is on). Jul 8, 2014 at 3:20
  • Then it's ok this command changes the file mode for this partition and when the terminal says nothing this mean that this command is done successfully without errors . Jul 10, 2014 at 11:20

2 Answers 2

8

I would quote Eric S. Raymond's The Art of Unix Programming:

Rule of Silence: When a program has nothing surprising to say, it should say nothing.

One of Unix's oldest and most persistent design rules is that when a program has nothing interesting or surprising to say, it should shut up. Well-behaved Unix programs do their jobs unobtrusively, with a minimum of fuss and bother. Silence is golden.

This “silence is golden” rule evolved originally because Unix predates video displays. On the slow printing terminals of 1969, each line of unnecessary output was a serious drain on the user's time. That constraint is gone, but excellent reasons for terseness remain.

I think that the terseness of Unix programs is a central feature of the style. When your program's output becomes another's input, it should be easy to pick out the needed bits. And for people it is a human-factors necessity — important information should not be mixed in with verbosity about internal program behavior. If all displayed information is important, important information is easy to find.

-- Ken Arnold

Well-designed programs treat the user's attention and concentration as a precious and limited resource, only to be claimed when necessary.

Of course, many programs don't obey this rule, and the answer really depends on the particular program.

4

There are some commands that don't print anything on the standard nor error output.

But they set the return code accordingly. The return code of any command can be accessed by the $? variable just after executing the command. If it is 0, then the command ran successfully. If it is a value greater than 0, then an error occurred.

This is very convenient when using these commands in script, as you just have to do something like this :

command && echo "Returned an OK status" || echo "Returned an non-OK status"

Or, when more actions are to be taken base on the returned status :

command
if [ $? == 0 ]; then
   # code to be executed when the command was executed successfully
else
   # code to be executed when the command was not executed successfully
fi

In other cases, this is the way used by command to tell that something is enabled or not, like the selinuxenabled command which return 0 if SE (Security Enhanced) Linux is activated, 1 if it is not.

1
  • Indeed, that is why prompts which use the return code of the previous command are so useful!
    – muru
    Jul 7, 2014 at 13:51

Not the answer you're looking for? Browse other questions tagged .