Find the answer to your Linux question:
Results 1 to 5 of 5
Hello All, I am doing some basic stuffs on the terminal can any one tell me that How exactly the ls command works ? Q1 : The exact question is ...
  1. #1
    Just Joined!
    Join Date
    Feb 2008
    Posts
    45

    Thumbs up What happens in background?

    Hello All,


    I am doing some basic stuffs on the terminal can any one tell me that How exactly the ls command works ?

    Q1 : The exact question is what happens in the background when we type a command ls or some other commands on the terminal ?













    Thnaks,

    Packet

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    Assuming ls is neither a builtin or a declared function in the shell:

    - The shell looks if it can find an executable called "ls" in the directories which are in the PATH variable.

    - Shell tells the kernel to load this executable into memory and to execute it, passing it the options you typed after "ls". For example "-a".

    What ls exactly does you find out by typing "man ls" and by looking at the programs source code. "ls" is part of the GNU coreutils Index of /pub/gnu/coreutils
    Debian GNU/Linux -- You know you want it.

  3. #3
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    In case if you looking from programming point of view,use strace ls, it will show you list of system call executed to produce the desired result.
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  4. #4
    Just Joined!
    Join Date
    Mar 2008
    Location
    Chennai, India
    Posts
    26
    when you type a command in the shell, let us say "ls" in this case, shell "forks" a child process which "exec"s "ls". This is how shell works.

    Hope this was helpful.
    Sarma

  5. #5
    Just Joined!
    Join Date
    Feb 2008
    Posts
    45
    Thanks lot for everyone

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...