Understanding Windows Directory System
- cd <directory> - to change the current directory.
- cipher <option> <file or directory> - shows and modifies encryption of files and directories.
- comp <file 1> <file 2> <options> - compare contents of two files.
- copy <options> <source> <destination> - copies content of one file to another file. For example: copy sample1.txt sample2.txt
- dir <drive> <pathname> <options> - the dir (directory) command lists directory contents, including files and subdirectories.
- ftype <file type>=<open command> - shows and changes file type and extension
- hostname - simple command to display the host machine's name.
- md and mkdir - md and mkdir (make directory) commands create new directory or subdirectory,syntax is : md <path> or mkdir <path>
File Management Commands in Windows Command Prompt (CMD)
1. Navigating Directories
To manage files, you first need to navigate to the correct directory.
cd [directory_path]: Changes the current directory.- Example:
cd C:\Users\JohnDoe\Documents
- Example:
cd ..: Moves up one level in the directory.dir: Lists all files and folders in the current directory.- Use
dir /ato list hidden files and directories as well.
- Use
2. Creating Files and Directories
mkdir [directory_name]: Creates a new directory.- Example:
mkdir NewFolder
- Example:
echo [text] > [filename]: Creates a new text file with specified content.- Example:
echo Hello, World! > file.txtcreates a file namedfile.txtwith "Hello, World!" inside.
- Example:
type nul > [filename]: Creates an empty file.- Example:
type nul > emptyfile.txt
- Example:
3. Copying Files
copy [source] [destination]: Copies a file from the source to the destination.- Example:
copy C:\folder1\file.txt C:\folder2\copiesfile.txttofolder2.
- Example:
xcopy [source] [destination] /s /e: Recursively copies all files and directories, including empty ones.- Example:
xcopy C:\folder1 C:\folder2 /s /ecopies everything fromfolder1tofolder2.
- Example:
4. Moving Files
move [source] [destination]: Moves a file or folder to a new location.- Example:
move C:\folder1\file.txt C:\folder2\movesfile.txttofolder2.
- Example:
5. Deleting Files and Directories
del [filename]: Deletes a file.- Example:
del file.txtdeletesfile.txtin the current directory.
- Example:
del /s /q [directory]: Deletes all files within a directory, including subdirectories.rmdir [directory]: Deletes an empty directory.- Example:
rmdir OldFolder
- Example:
rmdir /s /q [directory]: Deletes a directory and all its contents without prompting for confirmation.- Example:
rmdir /s /q C:\folder1
- Example:
6. Renaming Files and Directories
rename [old_name] [new_name]: Renames a file or directory.- Example:
rename oldfile.txt newfile.txt
- Example:
7. Finding Files and Content in Files
dir /s [filename]: Searches for a file in the current directory and all subdirectories.- Example:
dir /s file.txtsearches forfile.txtin all subdirectories.
- Example:
find "text" [filename]: Searches for specific text within a file.- Example:
find "error" log.txtsearches for the word "error" withinlog.txt.
- Example:
findstr /s /i /m [text] *.*: Searches for text across multiple files in a directory.- Example:
findstr /s /i /m "error" *.*finds the word "error" in all files in the current directory and subdirectories.
- Example:
8. Setting File Permissions
icacls [file_or_folder] /grant [username]:[permission]: Grants permissions to a file or folder.- Example:
icacls file.txt /grant JohnDoe:Fgives full control to the userJohnDoe.
- Example:
icacls [file_or_folder] /deny [username]:[permission]: Denies permissions.icacls [file_or_folder] /remove [username]: Removes all permissions for a user.
9. Checking Disk and Folder Sizes
dir: Shows the total size of files in the current directory.dir /s: Displays sizes for files in all subdirectories, including total space used.chkdsk [drive_letter]:: Checks disk usage and errors on a specific drive.- Example:
chkdsk C:
- Example:
10. Other Useful Commands
attrib [filename]: Displays or changes file attributes (e.g., read-only, hidden).- Example:
attrib +h +r file.txtmakesfile.txthidden and read-only.
- Example:
tree: Displays the directory structure in a tree-like format.fc [file1] [file2]: Compares two files line by line.- Example:
fc file1.txt file2.txt
- Example:
Permissions in Windows
Permissions in the Windows file system control which users and groups can access or modify files and folders.Permissions include Read, Write, Execute, Modify, and Full Control.The system administrator can set permissions to secure sensitive data and restrict access as needed.
1. Key Components of Windows Permissions
a. Access Control Lists (ACLs)- Each file and folder in Windows has an Access Control List (ACL), a list of permissions attached to it.
- An ACL defines the permissions for each user or group, specifying who can read, modify, delete, or execute a file or folder.
b. Security Identifiers (SIDs)- Windows identifies users and groups with Security Identifiers (SIDs), which are unique values that Windows uses to assign and check permissions.
c Ownership- Every file or folder has an Owner, the user or group with primary control over it.
- Owners can change permissions and control access to the resource. By default, the creator of a file or folder becomes its owner.
2. Types of Permissions
Permissions in Windows can be divided into two main categories: Basic Permissions and Advanced Permissions.
a. Basic Permissions
Basic permissions are straightforward and commonly used, allowing users to set access levels easily:
- Read: Allows viewing or listing the file or folder contents.
- Write: Grants permission to modify and add new content.
- Read & Execute: Allows reading and executing the file, such as running applications.
- Modify: Permits reading, writing, and deleting files or folders.
- Full Control: Provides complete access, including reading, modifying, deleting, and changing permissions.
b. Advanced Permissions
Advanced permissions offer finer control over file and folder access. They can be managed in the Advanced Security Settings and include:
- Traverse Folder / Execute File: Allows moving through folders to reach other files (useful for applications) or executing the file.
- List Folder / Read Data: Lets users list folder contents or read file data.
- Read Attributes: Grants permission to view file or folder attributes (like read-only or hidden).
- Read Extended Attributes: Allows viewing additional file or folder metadata.
- Create Files / Write Data: Enables creating new files within a folder or writing data to a file.
- Create Folders / Append Data: Lets users create subfolders or add data to files.
- Write Attributes: Allows modifying file or folder attributes.
- Write Extended Attributes: Permits modifying additional metadata associated with files or folders.
- Delete Subfolders and Files: Grants permission to delete content within folders.
- Delete: Allows deleting the file or folder.
- Read Permissions: Permits viewing the permissions of a file or folder.
- Change Permissions: Enables modifying file or folder permissions.
- Take Ownership: Allows a user to take ownership of a file or folder.
3. Permissions Conflicts and Resolution
- Deny Overrides Allow: If both “Allow” and “Deny” permissions are set, “Deny” takes precedence.
- Multiple Group Membership: If a user is in multiple groups, they’ll receive the most permissive level of access.
- Conflicts are resolved based on the most restrictive combination, ensuring security.
4. Managing Permissions in Windows
You can manage permissions through File Explorer or via the Command Prompt (using icacls or cacls commands for command-line management).
Steps to Set Permissions via File Explorer
- Right-click the file or folder, select Properties, then go to the Security tab.
- Click Edit to adjust permissions for users or groups.
- Select the user or group, then set the permissions (e.g., Full Control, Read, Write).
- To adjust advanced permissions, click Advanced and modify Special Permissions as needed.
Command-Line Management
icacls: A command-line tool for viewing and changing permissions.- Example to grant read and execute permissions to a user
icacls: A command-line tool for viewing and changing permissions.- Example to grant read and execute permissions to a user
- Example to grant read and execute permissions to a user
5. Practical Scenarios for Permission Settings
Securing Sensitive Folders
For folders containing sensitive data, restrict access by:
- Setting only Read permissions for most users.
- Granting Modify or Full Control only to trusted administrators.
Publicly Shared Folders
For public folders or files:
- Enable Read & Execute for general access.
- Limit Write and Delete permissions to prevent unwanted modifications.
For public folders or files:
- Enable Read & Execute for general access.
- Limit Write and Delete permissions to prevent unwanted modifications.
File Paths in Windows
File Path is the unique address location of a file. There are two kinds of file paths:- File Extensions are suffixes (like
.txt,.jpg,.exe) that indicate the file type and dictate which application opens it by default.

.png)
.png)

Comments
Post a Comment