Skip to main content

This page shows a growing list of common commands for viewing and managing your Centos server.

ls syntax
$ ls [options] [file|dir]

ls command main options:

ls -a list all files including hidden file starting with '.'
ls --color colored list [=always/never/auto]
ls -d list directories - with ' */'
ls -F add one char of */=>@| to enteries
ls -i list file's inode index number
ls -l list with long format - show permissions
ls -la list long format including hidden files
ls -lh list long format with readable file size
ls -ls list with long format with file size
ls -r list in reverse order
ls -R list recursively directory tree
ls -s list file size
ls -S sort by file size
ls -t sort by time & date
ls -X sort by extension name

 

ls command examples

Remember that you can press the tab button to auto complete the file or folder names.

List directory var/vhosts with relative path:

ls var/vhosts

List directory /home/var/www/ with absolute path.

ls /home/var/www

List root directory:

ls /

List parent directory:

ls ..

List user's home directory:

ls ~

List with long format:

ls -l

Show hidden files:

ls -a

List with long format and show hidden files:

ls -la

List with long format and show hidden files:

ls -ld .*

Sort by date/time:

ls -t

Sort by file size:

ls -S

List all subdirectories:

ls *

Recursive directory tree list:

ls -R

List only text files with wildcard:

ls *.txt

ls redirection to output file:

ls > out.txt

List directories only:

ls -d */

List files and directories with full path:

ls -d $PWD/*

 

Related articles

Andrew Fletcher15 Apr 2025
Fine-tuning Fail2Ban to stop Apache bogus FCGI attacks
Building a resilient web server Early in the year, we encountered a number of challenges, one of the most disruptive was a sustained wave of automated attacks hammering several of the web servers we manage. The volume of traffic overwhelmed server resources, slowing websites to a crawl and...
Andrew Fletcher08 Apr 2025
How smart blocking protects your digital infrastructure
Across every industry, the operational risks of cyber threats are escalating. Automated bots, denial-of-service attacks and vulnerability scanners are increasingly common. For businesses operating in Australia and globally, implementing resilient, proactive security measures is essential to ensure...
Andrew Fletcher16 Jan 2025
get IP address from terminal OSX
When troubleshooting network issues or configuring devices, knowing your IP address can be essential. Whether you're connected via Wi-Fi, Ethernet, or tethering through a mobile provider, macOS offers powerful built-in tools to quickly identify your IP address. Here's a practical guide tailored to...