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.

 

viveka@ubuntu:~/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.

 

viveka@ubuntu:~/Learning$ ls ShellScript/

2script 3script firstscript

viveka@ubuntu:~/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

 

viveka@ubuntu:~/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

viveka@ubuntu:~/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.
viveka@ubuntu:~/Learning$ ls -a

. ..

  firstcript  Hadoop  script1  ShellScript  tree.txt
viveka@ubuntu:~/Learning$
  • –file-type : Used to identify file types
viveka@ubuntu:~/Learning$ ls --file-type
firstcript

Hadoop/

  script1

ShellScript/

  tree.txt
viveka@ubuntu:~/Learning$

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

Leave A Comment

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.