Linux Hierarchical Directory Structure and Navigation

General help to Commands in Linux

  • It is not possible for any book/video series to cover all the options of the command, so it is always a good idea to explore the command by reading the manual.
  • To read the manual on the linux shell use the command man. Example : try executing man ls on the linux shell Preview
  • Other or most widely used option is to use popular search engine like google to understand the command try searching with following options <command> examples or <command> options Preview Preview

Linux Directory structure

  • Linux organizes its files in an hierarchical directory structure, which looks like tree-like pattern.
  • In Windows also the files are organized in a tree like pattern as shown below Preview
  • The linux directories are organized as shown below Preview
  • Linux file system starts with root represented as / and subdirectories append to root or child directories of root.
  • Lets look at some of the important sub directories and their basic purpose
    • /bin: Contains ready to run programs, most of the linux commands which we use such as ls cp etc.. are from this folder as shown below Preview
    • /dev: Contains information about devices or what is considered as device files. We will learn more about that in the later series
    • /etc: The system configuration directory which consists the user password, boot, device network and many other setup information files.
    • /home: Holds personal directories for users on the linux host.
    • /lib: This directory holds the library files containing code that executables use.
    • /sbin: This is directory for system executables. Programs in /sbin are releated to system management Preview
    • /tmp: temporary file storage.
    • /var: Variable subdirectory whare programs record runtime information. System loggins, caches and other files that systems programs create and manage are here
    • /boot: Contains kernel boot loader files
    • /opt: This may contain third party softwares
    • /usr: usally contains by far the largest share of data on the system. Hence, this is one of the most important directories in th system as it contains all the user binaries, their documentation, libraries. header files.
      • /usr/include: Holds header files used by the C compiler
      • /usr/local: This is the folder where administrators can install their own software

Navigation in Linux

  • In this series we will learn how to navigate the file systme on our linux system. For that we would use three commands
    • pwd: Prints the full path of the current working directory
    • cd: Change directory
    • ls: List directory Contents
  • Paths: We can specify paths in one of the two ways
    • Absolute Paths:
      • Full directory path name begining from root.
      • Consider a scenario where you want to change the current working directory to share directory in usr, Then you execute the command cd /usr/share Preview
      • Now lets assume you want to change your current working directory to local directory in usr, again you will enter the command using the full path referred as absolute path cd /usr/local Preview
    • Relative Paths:
      • Rather than using the absoulte path names, if you use a path which starts from the current working directory leading to destination, then it is referred as relative path
      • . represents current directory, .. represents parent directory
      • Assume your current working directory is /usr/local and now you want to change the current working directory to /usr/share, then the following approach of relative path can be used cd ../share Preview
      • The Relative Paths concept can be applied to ls and other linux commands as well whereever path of file/folder has to be passed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

About learningthoughtsadmin