Thursday, February 4, 2021

All ls command in Linux/Unix

 

ls is a Linux shell command that lists directory contents of files and directories.

ls syntax

$ ls [options] [file|dir]

ls command options

ls command main options:
optiondescription
ls -alist all files including hidden file starting with '.'
ls --colorcolored list [=always/never/auto]
ls -dlist directories - with ' */'
ls -Fadd one char of */=>@| to enteries
ls -ilist file's inode index number
ls -llist with long format - show permissions
ls -lalist long format including hidden files
ls -lhlist long format with readable file size
ls -lslist with long format with file size
ls -rlist in reverse order
ls -Rlist recursively directory tree
ls -slist file size
ls -Ssort by file size
ls -tsort by time & date
ls -Xsort by extension name

ls command examples

You can press the tab button to auto complete the file or folder names.
List directory Documents/Books with relative path:
$ ls Documents/Books

List directory /home/user/Documents/Books with absolute path.
$ ls /home/user/Documents/Books

List root directory:
$ ls /

List parent directory:
$ ls ..

List user's home directory (e.g: /home/user):
$ ls ~

List with long format:
$ ls -l

Show hidden files:
$ ls -a

List with long format and show hidden files:
$ ls -la

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/*

No comments:

Post a Comment

To generate a PDF using JavaScript in Oracle APEX from a collection

  To generate a PDF using JavaScript in Oracle APEX from a collection, you can follow these steps: 1. Create a button or link on your APEX p...