← Linux and the Command Line Lesson 3 of 51 · 10 XP

ls — listing files

Theory and problem statement

Machine translation, not yet reviewed by a native speaker.

ls shows the contents of a folder:

ls                 # the current folder
ls /etc            # the given one
ls -l              # in detail: permissions, owner, size, date
ls -a              # including hidden files (the name starts with a dot)
ls -la             # options can be combined
ls -lh             # sizes in a human-readable form: 4.0K, 1.2M
ls -t              # newest first
ls -R              # recursively, with all the subfolders

Hidden files are just files whose name starts with .: .bashrc, .git, .ssh. Settings are usually kept like this.

. is the current folder, .. is the folder one level up. They exist in every folder, and ls -a shows them.

If the output of ls goes not to the screen but to a program or a file, it prints one name per line. That's handy for processing.

Task. The starter code has already created the folder project with files (don't change it). Print first the list of files in project, and then the list with hidden files, but without . and .. (the -A option).

Sign up for free to solve this task right in your browser: code editor, running, test checks and hints.