Tuesday, January 22, 2013

List Files and Directories


ls

The ls command is used to list the contents of a directory. It is probably the most commonly used Linux command. It can be used in a number of different ways.

Examples:-

Command Result
ls List the files and folders in the working directory
ls /etc List the files and folders in the /etc directory
ls /dev List the files and folders in the /dev directory
ls -l List the files and folders with long details in the working directory
ls -l /etc /dev List the files and folders with long details in /etc and /dev directory
ls -l /var/tmp List the files and folders with long details in /var/tmp directory
ls -a  List  hidden files and folders also in working directory
ls -la  List of hidden files and folders also with long details


  1. Open a terminal login as a normal user. Then type ls command in terminal you get like this out put


    It means there is no files and folders in your current working directory.

  2. Type ls -la in your terminal



    In this picture
    .                               indicate your working directory
    ..                              indicate your parent directory
    .bash_history       indicate one hidden file or folder is there in your working directory that named .bash_history (which folder or file is started with . that file or folder do not display by default in linux. That means the file or folder is hidden)
    .bash_logout        is another hidden file or folder
    .bash_profile and .bashrc also tha hidden

    Some other things are displayed in this picture
    check the first line that is drwx------ . 2 user user 4096 Jan 15 22:49 .
    in this line first letter
    d                 Indicate this is a directory(Folder)
    rwx------      
    Indicate the permition of file or folder


 

    No comments: