Linux File System and Basic Commands Overview
File System Overview
- The file system in Linux is similar to Windows, where C drive contains various folders and files.
- In Linux, the root directory is represented by
/, which contains all files and directories. - The
bindirectory is crucial as it contains basic executable commands.
Understanding Directories
- Directories in Linux are the equivalent of folders in other operating systems, but the term "directories" is preferred for command clarity.
- Important directories include:
/bin: stores basic commands (e.g.ls,cd)/etc: contains configuration files (e.g. Zoom configuration)/home: contains personal directories for users/sbin: holds system administration commands
Basic Commands
lsCommand: Lists files and directories in the current directory.- Variants:
ls -l(detailed output),ls -a(list hidden files) cdCommand: Changes the current directory. Usecd ..to move one level up.pwdCommand: Prints the current working directory.mkdirCommand: Creates a new directory.rmdirCommand: Removes an empty directory; cannot remove non-empty directories.rmCommand: Removes files or directories, can be dangerous if used without caution.cpCommand: Copies files, can rename them in the process.mvCommand: Moves (or renames) files.touchCommand: Creates a new empty file.chmodCommand: Changes file permissions (e.g., add or remove execute permissions).
Advanced Commands
sudo&su: Gain administrative privileges;sudoruns a command with root privileges without switching users.catCommand: Displays file contents in the terminal.nanoEditor: A terminal-based text editor for creating or editing files.apt-getCommands:apt-get update: Updates the package list.apt-get upgrade: Upgrades installed packages.apt-get install <package>: Installs a new package.apt-get remove <package>: Uninstalls a package.
Safety and Best Practices
- Be cautious with
rmandrmdirto avoid accidental data loss. - Use
rm -rfwith extreme caution as it can recursively delete all contents, including root directories if misused. - Practice using commands often to build "muscle memory" for faster navigation and command execution.
- Be cautious with
Shortcuts and Efficiency in Terminal
- Control Shortcuts:
Ctrl + L: Clears the terminal screen.Ctrl + Shift + C/V: For copying and pasting text in the terminal.- Use the arrow keys to navigate command history.
tab: Auto-completes commands or files when partially typed.
Practical Approach
- Emphasize practice by performing file operations entirely through the terminal without a mouse.
- Create a habit of checking your current directory with
pwd, listing files withls, and experimenting with command combinations. - Encourage continuous learning and practice for Linux proficiency.