ls
The command that lists the files and directories inside a directory.
In more detail
Useful options: -a includes names starting with a dot, -l shows permissions, owner, size and date, -1 prints one name per line, -F marks directories with a slash and executables with a star, and -d describes a directory itself rather than its contents. Its output is for people; scripts should use globbing or find instead of parsing it.
Examples
ls -F projectls -la ~ls -als .git/refs/headsRelated terms
- dotfile — A file whose name starts with a dot, such as .bashrc, which ls and globs hide unless asked.
- permission string — The ten characters at the start of an ls -l line, such as -rwxr-xr--, showing a file's type and its permissions.
- glob pattern — A pattern that matches names using * for any run of characters, a question mark for one character and [abc] for one of a set.
- find command — The find command, which walks a directory tree and prints, or acts on, every entry that passes its tests.
- cd — The builtin that changes the shell's current working directory.
- pwd — The command that prints the full path of the current working directory.
- dir command — The Windows Command Prompt command that lists the files and folders in a directory.
Taught in
- What A Shell Is, And What Bash Is — Bash Scripting & Command Line Automation
- Moving Around: pwd, ls, cd And Paths — Bash Scripting & Command Line Automation
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- Help, History, Completion And Aliases — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- Standard Input, Output And Error — Bash Scripting & Command Line Automation
- Command Substitution And Subshells — Bash Scripting & Command Line Automation
- trap, Cleanup And Temporary Files — Bash Scripting & Command Line Automation
- Permissions And Ownership — Bash Scripting & Command Line Automation
- Archives, Transfers And The Network — Bash Scripting & Command Line Automation
- Why Version Control, And Why Git Won — Advanced Git Internals & Distributed Workflows
- A Repository Is A Folder With A Memory — Advanced Git Internals & Distributed Workflows
- The Three Areas: Working Tree, Index, Repository — Advanced Git Internals & Distributed Workflows
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- A Branch Is A Moving Pointer — Advanced Git Internals & Distributed Workflows
- What A Remote Actually Is — Advanced Git Internals & Distributed Workflows
- First Run, And Fixing A Broken Install — Hands-on Python: Complete Video Course & Book
- Windows And Mac Specifics — Hands-on Python: Complete Video Course & Book
- Virtual Environments — Hands-on Python: Complete Video Course & Book
- Diagnosing Permission Problems — Red Hat Certified System Administrator (EX200) Exam Prep
- Recovering Root And Changing The Boot Loader — Red Hat Certified System Administrator (EX200) Exam Prep
- VFAT, ext4 And XFS: Create, Mount, Use — Red Hat Certified System Administrator (EX200) Exam Prep
- NFS Client Mounts That Survive The Boot — Red Hat Certified System Administrator (EX200) Exam Prep
- autofs: Mount On Demand — Red Hat Certified System Administrator (EX200) Exam Prep
- SELinux Contexts: Labels, restorecon And Rules That Last — Red Hat Certified System Administrator (EX200) Exam Prep
- Drill: Storage, Then SELinux, Then The Firewall — Red Hat Certified System Administrator (EX200) Exam Prep
- Social Engineering: Reading The Lure — CompTIA Security+ (SY0-801) Exam Prep
- Two Managers Down: The Night The Swarm Froze — Docker Certified Associate (DCA) Exam Prep
- One Option At A Time: How DOMC Changes The Exam — Docker Certified Associate (DCA) Exam Prep
- Five Nodes Before Lunch: Building A Swarm — Docker Certified Associate (DCA) Exam Prep
- From docker run To docker service: Replicas, Global Mode And Updates — Docker Certified Associate (DCA) Exam Prep
- One File, Five Services: Stacks From Compose Files — Docker Certified Associate (DCA) Exam Prep
- Stuck In Pending: Troubleshooting Services And Reading docker inspect — Docker Certified Associate (DCA) Exam Prep
- One Edited File, Six Rebuilt Steps: Layers, Cache And Flat Images — Docker Certified Associate (DCA) Exam Prep
- Three Names, One Image: Listing, Formatting, Tagging And Pruning — Docker Certified Associate (DCA) Exam Prep
- The App In /bin That Vanished: The FHS, Distributions And Licences — CompTIA Linux+ (XK0-006) Exam Prep
- Root Over SSH From Anywhere: Keys, sshd, setuid Files And Attributes — CompTIA Linux+ (XK0-006) Exam Prep
- What Changed Last Night? Integrity, Scans, Benchmarks And Secure Deletion — CompTIA Linux+ (XK0-006) Exam Prep
- The Cleanup That Emptied The Wrong Directory: Shell Scripts Under Exam Conditions — CompTIA Linux+ (XK0-006) Exam Prep
- You Are In Emergency Mode: Boot Failures From GRUB To fstab, On Both Families — CompTIA Linux+ (XK0-006) Exam Prep
- No Space Left, Says The Disk With Room To Spare: Inodes, Held Files, Corruption And Repair — CompTIA Linux+ (XK0-006) Exam Prep
- Forbidden, With Perfect Permissions: Paths, ACL Masks And SELinux Denials — CompTIA Linux+ (XK0-006) Exam Prep
- SELinux: Modes, Labels, Ports And Booleans That Last — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- OpenSSH: Keys, Client Aliases And A Hardened Server — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Remote File Systems: NFS, SMB And Network Block Devices — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Swap: Partitions, Volumes, Files And Priorities — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Automounters: autofs Maps And systemd Automount — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Accounts On Ubuntu: Skeletons, Groups And Offboarding — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Mock Exam, Part 1: Seventeen Tasks, One Reboot — Linux Foundation Certified System Administrator (LFCS) Exam Prep
- Sixty Questions, One Wrong Flag Each — LPIC-1 Linux Administrator (101-500 and 102-500) Exam Prep
- SSH Keys And An Account For Ansible — RHCE in Ansible (EX294): Automate Red Hat Systems
- SELinux: Labels, Ports And Booleans That Persist — RHCE in Ansible (EX294): Automate Red Hat Systems
References
Certification courses
- RHCSA course and practice exam: Red Hat Certified System Administrator (EX200)
- CompTIA Security+ course and practice exam: SY0-801
- DCA course and practice exam: Docker Certified Associate
- CompTIA Linux+ course and practice exam: XK0-006
- LFCS course and practice exam: Linux Foundation Certified System Administrator
- LPIC-1 course and practice exam: Linux Administrator (101-500 and 102-500)
- RHCE course and practice exam: Red Hat Certified Engineer in Ansible (EX294)