ls — list directory contents
The basic command for viewing the list of files in a folder. -l/-a/-h options, sorting, real-world check examples, and execution screens.
💬 "ls command"
- Concept: The most basic command that lists files and folders in a directory. It is the first thing you type when you connect to a server.
- Output structure: When run without options, it only lists names, so you cannot see type, permissions, or size.
- Recommended output in practice: Using
ls -alorganizes permissions, owner, size, and modification time on one line. Add-hto make the size easier to read. - Left column: file type and permissions (e.g. <code>drwxr-xr-x</code>), link count, and owner and group are displayed.
- Right column: file size, last modification time, and file name are printed.
3 Essential Command Combinations
ls— Quickly check only the names in the current folderls -l— Check permissions, size, and time in detaills -al— Check all files, including hidden files (starting with.)
Here are some useful options worth knowing.
-h— Display sizes in easy-to-read KB/MB/GB units-t— Sort by most recently modified files first
💬 "Show me how to solve a problem using this"
Scenario: Checking that files have been uploaded correctly to the deployment folder.
Step 1: Check the full list
Check the list including hidden files.
ls -al /var/www/app
Step 2: View recently modified files first
The file you just deployed appears at the top.
ls -lt /var/www/app | head
Step 3: Make the size easy to read
Check again in units that are easier for people to read.
ls -lh /var/www/app
Actual execution screen
An example screen of checking folder contents with ls -al and ls -lh.
!ls command output: permissions, size, modification time and file name
A real production server
Source (HTML): https://games.aidebatehub.com/programs/linux/filesystem/ls.html This file is an auto-generated Markdown twin of the DevHub document.
AI Knowledge Hub
Visitor Comments