File and Directory related command for Linux (Ubuntu)

Here we will learn about the command related to File System

List of File in Folder

ls command can be used to list down all the files in Folder.

 

[email protected]:~/Learning$ ls 

firstcript Hadoop script1 ShellScript tree.txt

Note*: All command in Linux are case sensitive. So ls or Ls or lS or LS all are different.

By default ls command will show the files from current directory. If you want to display list of files from different directory then provide the directory path as an argument.

 

[email protected]:~/Learning$ ls ShellScript/

2script 3script firstscript

[email protected]:~/Learning$

With ls you will get list of files and folder in alphabetical order. If you want to see other details of files/folder you can user other argument with ls.

Available argument

  •    -l   :  Show long listing format of file or folder

 

[email protected]:~/Learning$ ls -l
total 63

-rwxr-xr-x 1 root   root      11 Aug  5 23:22 firstcript drwxrwxr-x 3 viveka viveka  1024 Aug 11 19:35 Hadoop -rwxr-xr-x 1 viveka viveka    91 Aug  6 23:47 script1 drwxrwxr-x 2 viveka viveka  1024 Aug  7 21:29 ShellScript -rw-rw-r– 1 viveka viveka 58833 Aug  7 19:59 tree.txt

[email protected]:~/Learning$

 

  • -a (minus and small A) : ls by default ignores . (Current directory) and .. (Parent Directory) -a is used to display .. and . while listing files and folders.
[email protected]:~/Learning$ ls -a

. ..

  firstcript  Hadoop  script1  ShellScript  tree.txt
[email protected]:~/Learning$
  • –file-type : Used to identify file types
[email protected]:~/Learning$ ls --file-type
firstcript

Hadoop/

  script1

ShellScript/

  tree.txt
[email protected]:~/Learning$

Here Hadoop and ShellScript are directories while others are files. As you can differenciate by seeing / in the end.

By | 2017-07-21T21:54:13+00:00 August 15th, 2013|Unix|0 Comments

About the Author:

Leave A Comment