What is a directory and a file and what is the difference between them?

Experience Level: Junior
Tags: File System

Answer

Directory

A directory is like a box that can contain other boxes (subdirectories).

  • There can be directory in a directory that is in a directory.
  • A directory that is stored in a directory is sometimes referred to as a subdirectory.
  • There can be zero or more directories (subdirectories) in a directory.
  • Except subdirectories a directory can contain zero or more files as well.
  • Directories can be created, renamed, deleted.

File

A file is a document that contains data.

  • The files can be stored in folders.
  • One file can be stored in one folder only.
  • Files can be created, renamed, deleted. Their content can be modified.
  • The full file name consists of the file name and file extension, these two pards are delimited by . (dot) character. The file extension usually identifies the type of the file. You can however rename the file name and the file extension to anything you want.
Related Other job interview questions

Comments

Anonymous
hii
File System and Command Line for beginners
File System and Command Line for beginners

Are you learning Other ? Try our test we designed to help you progress faster.

Test yourself