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
$HOMEthat 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:¶
-
clear: Clears the terminal screen. -
logout: Logs out of the current user session. -
ls /: Lists the contents of the root directory. -
pwd: Prints the current working directory. -
ls /home: Lists the contents of the/homedirectory. -
touch teja.txt: Creates an empty file namedteja.txtin the current directory. -
vi teja.txt: Opens theteja.txtfile in the Vim editor for editing. -
vi ravi.txt: Attempts to open a file namedravi.txtin the Vim editor. -
cat ravi.txt: Displays the contents of theravi.txtfile usingcat. -
cat ravi.txt: Displays the contents of theravi.txtfile again. -
ls /home/: Lists the contents of the/homedirectory. -
sudo adduser teja: Adds a user namedtejausingsudo. -
cd /home/teja/: Changes the working directory to/home/teja. -
sudo -i: Opens a new shell session with superuser privileges. -
mkdir sample: Creates a directory namedsamplein the current directory. -
touch 1 2 3 4: Creates empty files named1,2,3, and4. -
mkdir -p stevejobs/apple/ios: Creates a directory structure. -
ls stevejobs/: Lists the contents of thestevejobsdirectory. -
ls stevejobs/apple/: Lists the contents of theappledirectory withinstevejobs. -
cd ios/: Changes the current working directory toioswithinapple. -
touch iphone11: Creates a file namediphone11in theiosdirectory. -
touch /home/ubuntu/stevejobs/apple/ios/iphone12: Creates a file at the specified path. -
vi /home/ubuntu/stevejobs/apple/ios/iphone12: Opens theiphone12file in the Vim editor. -
cat /home/ubuntu/stevejobs/apple/ios/iphone12: Displays the contents ofiphone12usingcat. -
mv sample/ stevejobs/: Moves thesampledirectory tostevejobs. -
history: Displays the command history.