Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

10 Basic ‘ls’ Command

Examples in Linux
About
In computing, ls is a command to list computer files in Unix and Unix-like operating systems. ls is specified by POSIX and the Single UNIX
Specification. When invoked without any arguments, ls lists the files in the current working directory. The command is also available in the
EFI shell.[1] In other environments, such as DOS, OS/2, and Microsoft Windows, similar functionality is provided by the dir command. The
numerical computing environments MATLAB and GNU Octave include an ls function with similar functionality.[2][3]
1. List Files using ls with no option
ls -l

0001.pcap Desktop Downloads index.html install.log.syslog


Pictures Templates

anaconda-ks.cfg Documents fbcmd_update.php install.log Music


Publ
2 List Files With option –l
ls -a

total 176

-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap

-rw-------. 1 root root 1586 Jul 31 02:17 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Desktop

drwxr-xr-x. 2 root root 4096 Jul 31 02:48 Documents

drwxr-xr-x. 4 root root 4096 Aug 16 02:55 Downloads

-rw-r--r--. 1 root root 21262 Aug 12 12:42 fbcmd_update.php


3. View Hidden Files

# ls -a

. .bashrc Documents .gconfd install.log


.nautilus .pulse-cookie

.. .cache Downloads .gnome2 install.log.syslog


.netstat.swp .recently-used.xbel

0001.pcap .config .elinks .gnome2_private .kde


.opera .spice-vdagent

anaconda-ks.cfg .cshrc .esd_auth .gtk-bookmarks .libreoffice


Pictures .tcshrc

.bash_history .dbus .fbcmd .gvfs .local


4. List Files with Human Readable Format with option -lh

# ls -lh

total 176K

-rw-r--r--. 1 root root 683 Aug 19 09:59 0001.pcap

-rw-------. 1 root root 1.6K Jul 31 02:17 anaconda-ks.cfg

drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Desktop

drwxr-xr-x. 2 root root 4.0K Jul 31 02:48 Documents

drwxr-xr-x. 4 root root 4.0K Aug 16 02:55 Downloads

-rw-r--r--. 1 root root 21K Aug 12 12:42 fbcmd_update.php

You might also like