How command works in Linux?

Heechul Yoon·2021년 3월 11일
0

Currently I am studying on Operting System and came to understand how commands work in Linux terminal.

Before we go, let us check out how Linux receive input from hardware and convey it to OS.

Basically, Linux control everything in file so Standard Input(so called stdin) in terminal what we type by keyboard is written in /dev/stdin in real time. then when you press enterreturn, OS raise interruption to the running proccess and reset PC(Program Counter) to the start of executing file that you input as "command"

Here with an example when you put ls -al in terminal

  1. your ls -al is written in /dev/stdin file in real time
  2. when you press enter, OS raise interruption to OS. To be in more detail, OS embed "interruption code" to PC(Program Counter) by force
  3. reset PC(Program Counter) to the first line of excuting file of ls
  4. CPU run excuting file of ls which is already defined somewhere in root/

Then how OS find ls file in root/ and execute it?
Actually every commands in terminal is exist as files somewhere in file system
and the path where excution file at is predefined at/etx/paths

#/etx/paths
  1 /usr/local/bin
  2 /usr/bin
  3 /bin
  4 /usr/sbin
  5 /sbin

Otherwise, you would type /usr/bin/ls instead of ls

profile
Quit talking, Begin doing

0개의 댓글