How does a Linux terminal work?

If you fire up a terminal and call an executable (assuming one that’s line oriented for simplicity) you get a reply to the command from the executable. How does this get printed to you (the user)? Does the terminal do something like pexpect? (poll waiting for output) or what? How does it get notified of output to be printed out? And how does a terminal start a program? (Is it something akin to python’s os.fork()? ) I’m puzzled how a terminal works, I’ve been playing with some terminal emulator and I still don’t get how all this magic works. I’m looking at the source of konsole (kde) and yakuake (possibly uses konsole) an I can’t get where all that magic happens.

Remove a directory from inside using the command line interface

Imaging the next simple file structure within the /home/user/ directory: /home/user |–dir0 |–dir1 |–file1 My current directory is ‘dir1’ and I remove the directory from inside with the following command: rm -r ../dir1 After that (and not getting any errors on the terminal), the working directory still is the same and when using the command … Read more

Terminal vs bash?

I’m on a Mac but I think this is generally Unix-applicable. I’m in the process of learning shell scripting and there’s something I seem to be missing. When I’m in the ordinary terminal, I can use scripting syntax like for loops and such in conjunction with commands to do stuff. But….bash opens an interpreter for … Read more

How do I run the same linux command in more than one tab/shell simultaneously?

Is there any tool/command in Linux that I can use to run a command in more than one tab simultaneously? I want to run the same command: ./myprog argument1 argument2 simultaneously in more than one shell to check if the mutexes are working fine in a threaded program. I want to be able to increase the number of instances of this program so as to put my code under stress later on.