0

I found

ls / > output.txt

creates output.txt which contains names of folders inside rootfs. But I can't understand what does ls / > exactly mean. I know command ls is used to list all files in the location but what does ls / > do? I did man ls to read definition of ls / > but I couldn't find that there.

game lover
  • 125
  • 5
  • 1
    @user535733 ok so ls / prints out files inside root linux folder and the outputs will be redirected to output.txt . is it right? – game lover Jan 28 '22 at 18:49
  • Beside the point, but for "roofts", you mean "rootfs", right? But actually, you mean "the root of the filesystem", right? cause rootfs gets mounted over during startup (IIRC) – wjandrea Jan 28 '22 at 18:49
  • 1
    @wjandrea yes, a typo sorry – game lover Jan 28 '22 at 18:49
  • 1
    Related: [What's is the difference between ">" and ">>" in shell command?](/q/382793/301745) – wjandrea Jan 28 '22 at 18:52

1 Answers1

8

/ is the root directory, which contains directories like home and root as well as files like swapfile if you have it set up.

> sends (redirects) the output of a command to a file, in this case, output.txt.

So ls / > output.txt means "list the contents of the root directory and send the output to output.txt."

wjandrea
  • 14,109
  • 4
  • 48
  • 98