• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
sharadchhetri

sharadchhetri

Tutorials On Linux, Unix & Open Source

  • Home
  • Linux Commands
  • Resources
    • Learn Linux
  • My WordPress plugins

list files and directories by 4 commands in linux

September 9, 2013 by Sharad Chhetri Leave a Comment

When I started learning linux ,for listing files and directory I firsts learnt the command ls.
ls command is widely in linux and Unix like operating system.It is a system command which by default shipped with operating system.Today I am sharing the 4 commands by which you can list file and directories.On other hand you can also say alternate of ls commands.

Note: ls commands has many flags and it make the ls command very strong and useful.The given below information is for reference to understand other options available instead of ls command.

To list files and directories below given command can be used

(1) ls : list directory contents and bydefault do listing in alphabetical order.It is preferred to use ls command and is available in all linux and Unix like operating system.

example:

list the file (simply using ls command ,no flag is used)

linux@tuxworld:/tmp$ ls
CRX_75DAF8CB7768  pulse-2L9K88eMlGn7  qtsingleapp-smplay-ca73-3ea-lockfile  unity_support_test.0
orbit-linux	  pulse-NlEgkniQzH6U  ssh-jILc18mdYgH9
plugtmp		  pulse-PKdhtXMmr18n  tmpMUt_t8
linux@tuxworld:/tmp$

list the file and dir along with information (Using -l option)

linux@tuxworld:/tmp$ ls -l
total 28
drwx------ 2 linux   linux   4096 Sep  9 08:59 CRX_75DAF8CB7768
drwx------ 2 linux   linux   4096 Jan  1  1970 orbit-linux
drwx------ 2 linux   linux   4096 Sep  8 19:02 plugtmp
drwx------ 2 lightdm lightdm 4096 Sep  4 08:36 pulse-2L9K88eMlGn7
drwx------ 2 linux   linux   4096 Sep  4 08:36 pulse-NlEgkniQzH6U
drwx------ 2 root    root    4096 Sep  4 08:36 pulse-PKdhtXMmr18n
-rw-rw-r-- 1 linux   linux      0 Sep  7 08:49 qtsingleapp-smplay-ca73-3ea-lockfile
drwx------ 2 linux   linux   4096 Sep  4 08:36 ssh-jILc18mdYgH9
-rw------- 1 linux   linux      0 Sep  4 08:36 tmpMUt_t8
-rw-rw-r-- 1 linux   linux      0 Sep  4 08:36 unity_support_test.0
linux@tuxworld:/tmp$

list ALL file and dir as well as hidden files (hidden files name start with dot example .testfile)

linux@tuxworld:/tmp$  ls -la
total 76
drwxrwxrwt 15 root    root    16384 Sep  9 12:01 .
drwxr-xr-x 27 root    root     4096 Jul 21 19:25 ..
drwx------  2 linux   linux    4096 Sep  8 19:08 .com.google.Chrome.tR19ls
drwx------  2 linux   linux    4096 Sep  9 08:59 CRX_75DAF8CB7768
drwx------  2 linux   linux    4096 Sep  4 08:36 .esd-1002
drwx------  2 lightdm lightdm  4096 Sep  4 08:36 .esd-104
drwxrwxrwt  2 root    root     4096 Sep  4 08:36 .ICE-unix
drwx------  2 linux   linux    4096 Jan  1  1970 orbit-linux
drwx------  2 linux   linux    4096 Sep  8 19:02 plugtmp
drwx------  2 lightdm lightdm  4096 Sep  4 08:36 pulse-2L9K88eMlGn7
drwx------  2 linux   linux    4096 Sep  4 08:36 pulse-NlEgkniQzH6U
drwx------  2 root    root     4096 Sep  4 08:36 pulse-PKdhtXMmr18n
-rw-rw-r--  1 linux   linux       0 Sep  7 08:49 qtsingleapp-smplay-ca73-3ea-lockfile
drwx------  2 linux   linux    4096 Sep  4 08:36 ssh-jILc18mdYgH9
-rw-rw-r--  1 linux   linux       0 Sep  9 12:01 .testfile
-rw-------  1 linux   linux       0 Sep  4 08:36 tmpMUt_t8
-rw-rw-r--  1 linux   linux       0 Sep  4 08:36 unity_support_test.0
drwx------  2 linux   linux    4096 Sep  7 08:03 .vbox-linux-ipc
-r--r--r--  1 root    root       11 Sep  4 08:36 .X0-lock
drwxrwxrwt  2 root    root     4096 Sep  4 08:36 .X11-unix
linux@tuxworld:/tmp$

(2) dir: Similar to DOS version, dir command is also available in Linux and Unix like O.S. Almost similar to ls command

examples:

list file and directory

linux@tuxworld:/tmp$ dir
CRX_75DAF8CB7768  pulse-2L9K88eMlGn7  qtsingleapp-smplay-ca73-3ea-lockfile  unity_support_test.0
orbit-linux	  pulse-NlEgkniQzH6U  ssh-jILc18mdYgH9
plugtmp		  pulse-PKdhtXMmr18n  tmpMUt_t8
linux@tuxworld:/tmp$

list files and directory with information

linux@tuxworld:/tmp$ dir -l
total 28
drwx—— 2 linux linux 4096 Sep 9 08:59 CRX_75DAF8CB7768
drwx—— 2 linux linux 4096 Jan 1 1970 orbit-linux
drwx—— 2 linux linux 4096 Sep 8 19:02 plugtmp
drwx—— 2 lightdm lightdm 4096 Sep 4 08:36 pulse-2L9K88eMlGn7
drwx—— 2 linux linux 4096 Sep 4 08:36 pulse-NlEgkniQzH6U
drwx—— 2 root root 4096 Sep 4 08:36 pulse-PKdhtXMmr18n
-rw-rw-r– 1 linux linux 0 Sep 7 08:49 qtsingleapp-smplay-ca73-3ea-lockfile
drwx—— 2 linux linux 4096 Sep 4 08:36 ssh-jILc18mdYgH9
-rw——- 1 linux linux 0 Sep 4 08:36 tmpMUt_t8
-rw-rw-r– 1 linux linux 0 Sep 4 08:36 unity_support_test.0
linux@tuxworld:/tmp$

list ALL files and directory with all info(including hidden files and dir)

linux@tuxworld:/tmp$ dir -la
total 76
drwxrwxrwt 15 root    root    16384 Sep  9 12:05 .
drwxr-xr-x 27 root    root     4096 Jul 21 19:25 ..
drwx------  2 linux   linux    4096 Sep  8 19:08 .com.google.Chrome.tR19ls
drwx------  2 linux   linux    4096 Sep  9 08:59 CRX_75DAF8CB7768
drwx------  2 linux   linux    4096 Sep  4 08:36 .esd-1002
drwx------  2 lightdm lightdm  4096 Sep  4 08:36 .esd-104
drwxrwxrwt  2 root    root     4096 Sep  4 08:36 .ICE-unix
drwx------  2 linux   linux    4096 Jan  1  1970 orbit-linux
drwx------  2 linux   linux    4096 Sep  8 19:02 plugtmp
drwx------  2 lightdm lightdm  4096 Sep  4 08:36 pulse-2L9K88eMlGn7
drwx------  2 linux   linux    4096 Sep  4 08:36 pulse-NlEgkniQzH6U
drwx------  2 root    root     4096 Sep  4 08:36 pulse-PKdhtXMmr18n
-rw-rw-r--  1 linux   linux       0 Sep  7 08:49 qtsingleapp-smplay-ca73-3ea-lockfile
drwx------  2 linux   linux    4096 Sep  4 08:36 ssh-jILc18mdYgH9
-rw-rw-r--  1 linux   linux       0 Sep  9 12:01 .testfile
-rw-------  1 linux   linux       0 Sep  4 08:36 tmpMUt_t8
-rw-rw-r--  1 linux   linux       0 Sep  4 08:36 unity_support_test.0
drwx------  2 linux   linux    4096 Sep  7 08:03 .vbox-linux-ipc
-r--r--r--  1 root    root       11 Sep  4 08:36 .X0-lock
drwxrwxrwt  2 root    root     4096 Sep  4 08:36 .X11-unix
linux@tuxworld:/tmp$ 

(3) printf : printf command is used for formatted output but by using switches it can list the directories and files

example:

list the files and dir horizontally

linux@tuxworld:/tmp$ printf "%s" *
CRX_75DAF8CB7768orbit-linuxplugtmppulse-2L9K88eMlGn7pulse-NlEgkniQzH6Upulse-PKdhtXMmr18nqtsingleapp-smplay-ca73-3ea-lockfilessh-jILc18mdYgH9tmpMUt_t8unity_support_test.0linux@tuxworld:/tmp$ 
linux@tuxworld:/tmp$

list the files and dir vertically by using n (new line)

linux@tuxworld:/tmp$ printf "%s n" *
CRX_75DAF8CB7768 
orbit-linux 
plugtmp 
pulse-2L9K88eMlGn7 
pulse-NlEgkniQzH6U 
pulse-PKdhtXMmr18n 
qtsingleapp-smplay-ca73-3ea-lockfile 
ssh-jILc18mdYgH9 
tmpMUt_t8 
unity_support_test.0 
linux@tuxworld:/tmp$ 

list files and directory including hidden files

linux@tuxworld:/tmp$ printf "%s n" * .*
CRX_75DAF8CB7768 
orbit-linux 
plugtmp 
pulse-2L9K88eMlGn7 
pulse-NlEgkniQzH6U 
pulse-PKdhtXMmr18n 
qtsingleapp-smplay-ca73-3ea-lockfile 
ssh-jILc18mdYgH9 
tmpMUt_t8 
unity_support_test.0 
. 
.. 
.com.google.Chrome.tR19ls 
.esd-1002 
.esd-104 
.ICE-unix 
.testfile 
.vbox-linux-ipc 
.X0-lock 
.X11-unix 
linux@tuxworld:/tmp$

(4) echo: echo is used to display line of contents.

list files and dir

linux@tuxworld:/tmp$ echo *
CRX_75DAF8CB7768 orbit-linux plugtmp pulse-2L9K88eMlGn7 pulse-NlEgkniQzH6U pulse-PKdhtXMmr18n qtsingleapp-smplay-ca73-3ea-lockfile ssh-jILc18mdYgH9 tmpMUt_t8 unity_support_test.0
linux@tuxworld:/tmp$

list files and dir (including hidden)

linux@tuxworld:/tmp$ echo * .*
CRX_75DAF8CB7768 orbit-linux plugtmp pulse-2L9K88eMlGn7 pulse-NlEgkniQzH6U pulse-PKdhtXMmr18n qtsingleapp-smplay-ca73-3ea-lockfile ssh-jILc18mdYgH9 tmpMUt_t8 unity_support_test.0 . .. .com.google.Chrome.tR19ls .esd-1002 .esd-104 .ICE-unix .testfile .vbox-linux-ipc .X0-lock .X11-unix
linux@tuxworld:/tmp$ 

Share this:

  • Twitter
  • Facebook
  • More
  • Print
  • Email
  • LinkedIn
  • Reddit
  • Tumblr
  • Pinterest
  • Pocket
  • Telegram
  • WhatsApp
  • Mastodon

Related posts:

  1. linux command to list the files from rpm package without extracting
  2. rsync all files,hidden files,symlinks,hardlinks to remotes Linux Server
  3. shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
  4. script to change group from a file having list of users
  5. How to list all installed python modules
  6. How to list users above or below particular user id
  7. find command to search keyword in files recursively in linux
  8. How to rename and move the directory and files in linux
  9. Extract single and selected files from RPM package on Linux
  10. Linux Basic Commands With Examples For Every Beginner

Filed Under: Linux Tagged With: ls

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Our Social Media Presence

  • Facebook
  • GitHub
  • Twitter

Linux Command

What is Linux Internal And External Command

Linux Basic Commands With Examples For Every Beginner

tr command to convert lines to space , tab and vertical tab

smbpasswd command not found on CentOS 7 and RHEL 7

Solution : semanage command not found

Unix / Linux : How to print duplicate lines from file

More Posts from this Category

You Might Like These Articles!

simplecodesyntax wordpress plugin

SimpleCodeSyntax : My Another WordPress Plugin

Install Nginx

How To Install Nginx On Ubuntu 22.04 LTS

Install Latest Git package in Ubuntu Operating System

How To Always Install Latest Git Package In Ubuntu Operating System

Bash script for installing VirtualBox on Ubuntu 22.04 LTS Desktop

Install VirtualBox On Ubuntu 22.04 LTS Desktop (Bash Script)

libfuse

dlopen(): error loading libfuse.so.2 – Got Error On Ubuntu

Failed to open/create the internal network

VirtualBox Error: Failed to open/create the internal network

Always Useful Tips And Tricks

Replace keyword with its filename without extension : bash script

How to see system load average in terminal with graphical representation

How to see line numbers in file through cat command

df command not showing correct free space in linux

error command ‘gcc’ failed with exit status 1 in Ubuntu

linux release renew dhcp assigned ip address

Edit the crontab without using crontab -e

Explore 90+ Article On "Linux Tips And Tricks"

Copyright © 2023 ยท
The material in this site cannot be republished either online or offline, without our permission.
Proudly Blogging From Bharat.

  • Contact
  • About Me
  • My WordPress plugins
  • Privacy Policy