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:¶
-
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/home
directory. -
touch teja.txt
: Creates an empty file namedteja.txt
in the current directory. -
vi teja.txt
: Opens theteja.txt
file in the Vim editor for editing. -
vi ravi.txt
: Attempts to open a file namedravi.txt
in the Vim editor. -
cat ravi.txt
: Displays the contents of theravi.txt
file usingcat
. -
cat ravi.txt
: Displays the contents of theravi.txt
file again. -
ls /home/
: Lists the contents of the/home
directory. -
sudo adduser teja
: Adds a user namedteja
usingsudo
. -
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 namedsample
in 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 thestevejobs
directory. -
ls stevejobs/apple/
: Lists the contents of theapple
directory withinstevejobs
. -
cd ios/
: Changes the current working directory toios
withinapple
. -
touch iphone11
: Creates a file namediphone11
in theios
directory. -
touch /home/ubuntu/stevejobs/apple/ios/iphone12
: Creates a file at the specified path. -
vi /home/ubuntu/stevejobs/apple/ios/iphone12
: Opens theiphone12
file in the Vim editor. -
cat /home/ubuntu/stevejobs/apple/ios/iphone12
: Displays the contents ofiphone12
usingcat
. -
mv sample/ stevejobs/
: Moves thesample
directory tostevejobs
. -
history
: Displays the command history.