Skip to content

Linux-FileSystems

Linux File System:

  • The Linux file system is a hierarchical structure that organizes data and files in a tree-like format.
  • The root directory ("/") is the top-level directory from which all other directories and files stem.
  • Directories are used to organize and group files into logical categories.
  • Files are organized based on their type, and they can be text files, binary files, directories, device files, and more.

All Types of Directories:

  • Directories in Linux can be categorized as system directories (critical for system operation), user directories (for user-specific data), and temporary directories (for temporary files).
  • Examples of system directories include "/bin", "/etc", "/lib", "/usr", etc.
  • User directories like "/home/username" store user-specific data and configurations.
  • Temporary directories like "/tmp" hold temporary files that can be safely deleted.

VIM Editor and Its Modes:

  • Vim is a powerful text editor available in most Unix-like systems.
  • Vim has different modes: Normal mode (default mode for navigation and manipulation), Insert mode (for text input), Visual mode (for selecting text), and Command-line mode (for entering commands).
  • To switch from Normal mode to Insert mode, press "i". To switch back to Normal mode from Insert mode, press "Esc".
  • In Normal mode, you can navigate using arrow keys or "hjkl" keys, perform editing operations, and execute commands.
  • In Command-line mode, you can save changes with ":w", quit with ":q", and save and quit with ":wq".

How to Insert, Write, Quit in VIM:

  • To insert text in Vim, first switch to Insert mode by pressing "i". Then, type your text.
  • After inserting text, switch back to Normal mode by pressing "Esc".
  • To save changes, type ":w" in Normal mode and press "Enter".
  • To quit Vim, type ":q" in Normal mode and press "Enter".
  • If you want to save and quit, type ":wq" and press "Enter".

Variable Path and Actual Path in Linux:

  • In Linux, a "variable path" usually refers to a variable containing a directory path that can change.
  • An "actual path" refers to the absolute and unchanging directory path to a specific location in the file system.
  • For example, if you have a variable $HOME that stores the path to the user's home directory, its value might change for different users, but the actual path (e.g., "/home/username") remains fixed.

Here are the notes for the unique commands from your history, excluding the repeated ones:

  1. clear: Clears the terminal screen.

  2. logout: Logs out of the current user session.

  3. ls /: Lists the contents of the root directory.

  4. pwd: Prints the current working directory.

  5. ls /home: Lists the contents of the /home directory.

  6. touch teja.txt: Creates an empty file named teja.txt in the current directory.

  7. vi teja.txt: Opens the teja.txt file in the Vim editor for editing.

  8. vi ravi.txt: Attempts to open a file named ravi.txt in the Vim editor.

  9. cat ravi.txt: Displays the contents of the ravi.txt file using cat.

  10. cat ravi.txt: Displays the contents of the ravi.txt file again.

  11. ls /home/: Lists the contents of the /home directory.

  12. sudo adduser teja: Adds a user named teja using sudo.

  13. cd /home/teja/: Changes the working directory to /home/teja.

  14. sudo -i: Opens a new shell session with superuser privileges.

  15. mkdir sample: Creates a directory named sample in the current directory.

  16. touch 1 2 3 4: Creates empty files named 1, 2, 3, and 4.

  17. mkdir -p stevejobs/apple/ios: Creates a directory structure.

  18. ls stevejobs/: Lists the contents of the stevejobs directory.

  19. ls stevejobs/apple/: Lists the contents of the apple directory within stevejobs.

  20. cd ios/: Changes the current working directory to ios within apple.

  21. touch iphone11: Creates a file named iphone11 in the ios directory.

  22. touch /home/ubuntu/stevejobs/apple/ios/iphone12: Creates a file at the specified path.

  23. vi /home/ubuntu/stevejobs/apple/ios/iphone12: Opens the iphone12 file in the Vim editor.

  24. cat /home/ubuntu/stevejobs/apple/ios/iphone12: Displays the contents of iphone12 using cat.

  25. mv sample/ stevejobs/: Moves the sample directory to stevejobs.

  26. history: Displays the command history.