02 Files and Directories
File Interaction¶
find- Finds a specific file within a tree of directories.grep- Searches the contents of a file.touch- Create file.mkdir- Makes new directory.cp- Copy files.mv- Move files.rm- Remove files.file- Displays information about the file type.cat- Read from a file.head -n 20 <FILE_NAME>- Read first 20 lines from a text file.
File Permissions¶
-r- Read permission.-w- Write permission.-x- Execute permission.
Common Directories¶
- / - Parent for all the directories in Linux.
- /root - Home directory for root user.
- /etc - Etcetera - Common place for storing system files. etc folder contains the following important files.
- sudoers - Contains the list of users and groups allowed to run as sudo (Admin privileges).
- passwd - Contains the passwords for all the users. Encrypted in SHA512.
- shadow - Supporting file for passwd implemented as a security mechanism.
- /var - Variable data - Stores the data which is frequently accessed by files and services running in the system.
- /var/log - Stores the log files from applications and services.
- /tmp - Contains only the temporary data. When the computer is restarted the contents of this folder are cleared out.
Search Files¶
- Find files by name.
- Find files by name ignoring error messages.