Home TechnologySoftwareOperating SystemsLinux Subscribe to RSS
 

How To Make And View A Directory's Contents Inside The Linux?

Answer Question

2 Answers - Sort by: Date | Rating

    (mkdir) This is similar to the DOS command md. The syntax for mkdir ismkdir [options] directories. The mkdir command creates one or more directories. You must have write permission (for the parentdirectory) to create a directory. Let's see how we can use the mkdir command:
    stimpy $ cd
    stimpy $ pwd
    /home/mtobler
    stimpy $ ls
    name.txt
    stimpy $ mkdir spreadsheet
    stimpy $ ls
    name.txt
    spreadsheet
    stimpy $ mkdir database documents source
    stimpy $ ls
    database
    documents
    name.txt
    source
    spreadsheet
    stimpy $ mkdir timesheet
    stimpy $ ls
    database
    documents
    name.txt
    source
    spreadsheet
    timesheet
    stimpy $
    If you recall, a directory is not like a file; it does not contain data, other than a list of files and directories. When you create a directory with mkdir, what actually happens is that Linux creates a new.

    Viewing a Directory's Contents:
    In Linux (and UNIX), the command to view the contents of a directory is ls, which is short for list. A
    directory list contains both files and directories. This command is similar to the DOS command dir. In fact, most Linux systems define dir to be an alias for ls. The syntax for ls is as follows:
    ls [options] [names]
    The ls command has many switches (or options) - too numerous to list here. Refer to the man page for ls. Some examples follow.
    The following lists the status of /bin:
    stimpy $ ls -ld /bin List the files in the current directory, listing the oldest first:
    stimpy $ ls -rt * List all files in the current directory, in long format:
    stimpy $ ls -al * Depending on the shell, you can get a directory listing in color. The differing colors represent the
    different types of files. For example, green represents executable files.
    0 0

    Azzi 

    answered 3 years ago

      A new empty directory can be created by a very simple command; 'makedir'. In order to create a new directory in Linux, simply write . Here  is the name of the directory that is going to be created by 'makedir' command. Now if you want to view the contents saved within the directory, use 'ls' command. There are so many parameters or options which can be used with this 'ls' command.

      To view the full list of 'ls' parameters write . Hidden or dot files can also be seen by writing '-a' with the 'ls' command. So if we write then all the files within the directory will be displayed. Hidden files will also be displayed along with the unhidden. If you want to view the permissions along with the contents of the directory, write . All of the permissions along with the modes, size, and creation date will be displayed. If we write , the directory contents will be displayed in reverse sort order.  If you want to view the files in sorted order according to their sizes, use –S (a parameter) with the 'ls' command. Simply write to view the files sorted according to their sizes.
      0 0

      Srana 

      answered 3 years ago

        Answer Question - Answers are editable for 5 min.

        If you do not Sign-in or Register your answers will be anonymous,

        your answers may also be checked before going online.

        More

           
           

          Ask a Question via Twitter

          Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

          Blurtit Store

          Get T-shirts, hoodies, caps and more at the Blurtit store

          Blurtit International