Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Explaining more on this question. Are commands like ls, cd, rm,... applications if they are than how does the terminal knows where they are, and is the terminal just a interface to interact with the programs, is nothing more than just programs just interacting with each other? Secondly, Is bash the only language that will work in the terminal, if it is just programs just interacting with each other?

share|improve this question

closed as too broad by belacqua, Braiam, terdon, guntbert, waltinator Jun 15 at 1:01

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

This might be better on U+L (unix.stackexchange.com) (it is not specific to Ubuntu but Linux in general and you will get better answers there. –  Rinzwind Jun 13 at 20:51
unix.stackexchange.com/questions/79334/… has been asked already –  Wilf Jun 13 at 20:53
@Wilf doen't answer my question –  Andrew Jun 13 at 20:55
And then, WHAT IS your question? –  KasiyA Jun 13 at 21:01
@Andrew try to make your questions readable! Write complete sentences, use proper punctuation. –  guntbert Jun 14 at 16:53
show 1 more comment

5 Answers 5

up vote 6 down vote accepted

The terminal can be used to execute programs within a given PATH - you can find it by running echo $PATH in a bash teminal - example output:


This is set when the terminal starts - when it using using the BASH shell (default on lots of Linux systems), it checks ~/.bashrc before starting. Then when you run a command, it searches the path for the command, and executes if it finds it.

With my example $PATH above, I can place an executable script in /home/wilf/.local/bin (e.g. extension-update from here), and then be able to run it terminal without specifying the full path to the executable (e.g. /home/wilf/.local/bin/extension-update, /usr/bin/firefox, etc)

share|improve this answer
it does basicly thanks, I can't just accpted it just yet –  Andrew Jun 13 at 20:59
You can accept an answer in 20 seconds! –  Andrew Jun 13 at 20:59
you answer "what is a terminal", not "how does a terminal work". i can always write a program that call "bash", but definitely it will not become a terminal - stopping there and start taking input. –  Peter Teoh Jun 14 at 0:58
A terminal is just a place to send output to, and get input from a user. It knows nothing about programs or paths; that's the shell, which is the first program that is normally run when you log into a terminal. –  psusi Jun 14 at 21:27
@psusi + Peter - yes, i know this is not a perfect answer - I could of gone on about shells, terminal emulators, rc files and other stuff - I'm surprised it did so well... I may have a go at improving it later –  Wilf Jun 14 at 22:28
add comment


The terminal is an interface in which you can type and execute text based commands. It can be much faster to complete some tasks using a Terminal than with graphical applications and menus. Another benefit is allowing access to many more commands and scripts.

A common terminal task of installing an application can be achieved within a single command, compared to navigating through the Software Centre for example.

See this post for more information.

share|improve this answer
I saw it. Doen't answer my question –  Andrew Jun 13 at 20:53
add comment

doing a "ps -ef" you can see all the process, including the terminal processs:

tthtlc    2964     1  0 08:31 ?        00:00:02 gnome-terminal

just "ps" alone, you see your own terminal only:

 PID TTY          TIME CMD
 2974 pts/0    00:00:00 bash
 6420 pts/0    00:00:00 ps

See "pts/0"? Go to /dev/pts:

ls -al
total 0
drwxr-xr-x  2 root   root       0 Jun 14 08:31 .
drwxr-xr-x 18 root   root    4420 Jun 14 08:31 ..
crw--w----  1 tthtlc tty  136,  0 Jun 14 09:03 0
crw--w----  1 tthtlc tty  136,  1 Jun 14 09:02 1
crw--w----  1 tthtlc tty  136,  2 Jun 14 09:02 2
crw--w----  1 tthtlc tty  136,  3 Jun 14 09:02 3
crw--w----  1 root   tty  136,  6 Jun 14 08:31 6
crw--w----  1 root   tty  136,  8 Jun 14 08:31 8
c---------  1 root   root   5,  2 Jun 14 08:31 ptmx

Here u can see I have 0, 1, 2 ==> 3 terminal created. "gnome-terminal" is implemented as a process that open stdin, stdout, and stderr on the same character device as listed above. First, notice the pid 2974 for "bash" above? Go to /proc/2974/fd to see all the file descriptor opened:

/proc/2974/fd>ls -al
total 0
dr-x------ 2 tthtlc tthtlc  0 Jun 14 09:30 .
dr-xr-xr-x 8 tthtlc tthtlc  0 Jun 14 09:30 ..
lr-x------ 1 tthtlc tthtlc 64 Jun 14 09:30 0 -> /dev/pts/2
l-wx------ 1 tthtlc tthtlc 64 Jun 14 09:30 1 -> /dev/pts/2
l-wx------ 1 tthtlc tthtlc 64 Jun 14 09:30 2 -> /dev/pts/2
lrwx------ 1 tthtlc tthtlc 64 Jun 14 09:55 255 -> /dev/pts/2

So that means all input/output/stderr for bash comes from the /dev/pts device drivers.

If you open up multiple gnome-terminal, and depending on which one is the foreground process, the actual keyboard will be redirected to that corresponding process. ie, if you do a "strace -p <pid>" where <pid> is the process 2974 presently, the first time you enter a character in that terminal you will immediately see a read() - here below I enter multiple "f":

read(0, "f", 1)                         = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
write(2, "f", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(0, "f", 1)                         = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
write(2, "f", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(0, "f", 1)                         = 1
rt_sigprocmask(SIG_BLOCK, [INT], [], 8) = 0
write(2, "f", 1)                        = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
read(0, "f", 1)                         = 1

So that is how a terminal worked in general: reading character by character, and outputting character by characters simultaneously (call "echoing") to the screen at the same time. Multiple terminal can be running at the same time, but only one will be getting direct keyboard input, others will block at read() API.

share|improve this answer
add comment

Terminal opens in the default shell interpretor defined in /etc/passwd. /etc/shells file defines the other shell interpretors available with your Ubuntu distro, there are some others zsh for one. The shell can execute the programs of other programming languages but are seldom used as an actual programming language like C++, python, ruby and so on.

The shells do provide access to builtin commands, scripts and applications and will execute the many various programs written in other programming languages,as well as, providing access to the many builtin commands avaialble in Linux, provided the appropriate language dependencies are available in your install.

Shells are mostly alike with some differences in commands and syntax but bash is the default and most shell scripts which are readily available are written in the bash syntax.

Other shells, sh=Bourne shell, bash=Boure again shell, pdksh=public domain korn shell, zsh=z shell, csh=c shell, ksh=korn shell, and several others. Each having their own flavor of syntax and commands, completion, expansion. But all have one thing in common, their primary function is to allow access to controlling, managing, monitoring and general administration of Linux and Ubuntu.

share|improve this answer
add comment

I think most of the things are answered. I just want to add.

You can run any application from the terminal. Even the non-terminal (Application Like Chrome / firefox) will run from terminal.

To run any application, user have to know the file path of that application and call the application using that file location. for example


but for user convenience, PATH is defined. and application from those paths can be called without calling the the full path. that's why you can run these commands:

cat a_simple_text_file.txt
firefox    ## this is the same as double clicking the firefox icon in your desktop

You can write your own shell-script and run it on the terminal. And you can write program, using any programming language (C, C++, python, Java, Objective-C, PHP), it can be run in the terminal. each programming language has it's own way to show output and take input and building-running it self.

" just programs just interacting with each other."

technically, programs does not interact with each other. all the program request OS, OS interact with all. (OS means Operating System, Ubuntu / Windows / OSX etc.)

For example. You want to upload a file using firefox. when you click a upload button on a site. firefox will requested to OS for a file manager application. File manager will take your choice and send the file location to OS >> Firefox. Firefox will upload the file by requesting OS for use other applications.

Now you can say, OS is a program too. So, programs do Interact with each other!!

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.