• Home
  • About 404TS
  • Contact

404 Tech Support

Where IT Help is Found

  • Articles
    • Code
    • Entertainment
    • Going Green
    • Hardware, Gadgets, and Products
    • Management
    • Network
    • News
    • Operating Systems
    • Security and Privacy
    • Software
    • System Administration
    • Talking Points
    • Tech Solutions
    • Web
    • Webmaster
  • Reviews
  • Media
    • Infographics
    • Videos
  • Tech Events
  • Tools
    • How do I find my IP address?
    • Browser and plugin tests
  • Get a Technical Consultation
You are here: Home / Articles / System Administration / Command line to take ownership and change permissions

Command line to take ownership and change permissions

2016-03-28 by Jason

Taking ownership of files can be a very tedious task. If you select more than one file, the Security tab is not available. This means that you have to right-click on each individual file, go to Properties, select Security, select Advanced, and take ownership of the file. If you’re working with any significant number of files, that is far too time consuming. Once you take ownership of the files, you also want to change the permissions on the file to give yourself access.

I found myself in this situation this weekend. There was a folder full of files but I needed to delete only the ones that started with the word ‘pending’. I did not have permission to access the files as they’re controlled by SYSTEM.

Opening up the elevated command prompt, I ran this command:

dir path\to\folder\pending*

This listed all of the files in the folder that started with ‘pending’. I confirmed that the list exactly matched the files I needed to delete. I then ran the command

takeown /f path\to\folder\pending*

This successfully gave me ownership of each of those files. Now I could go modify the permissions, but since I already have Command Prompt open…

cacls path\to\folder\pending* /e /p [username]:[permission]

This gave me the permission that I specify at the very end since I specified my user name. The available permission options are:

  • N – none
  • R – Read
  • W – Write
  • C – Change (write)
  • F – Full control

The /e specifies to edit the ACL instead of replacing it and the P specifies the new permission. Since I was deleting the files, I gave myself full control over the files. So the actual command looked like:

cacls pending* /e /p Jason:F

cacls.exe is actually deprecated, so I should have used icacls to change the permissions.

icacls folder\pending* /grant [username]:(F)

Icacls allows for a lot more complexity when specifying permissions. Your options or simple rights are:

  • N – no access
  • F – full access
  • M – modify access
  • RX – read and execute access
  • R – read-only access
  • W – write-only access
  • D – delete access

You can also specify a comma-separated list of specific rights instead. Use icacls.exe /? to see your full list of options.

Filed Under: System Administration Tagged With: command line

Trending

  • Product Review: HP MultiSeat and Windows MultiPoint Server 2010
    In Going Green, Hardware, Gadgets, and Products, Reviews, Software, System Administration
  • Gmail Helps with your Security Concerns, Pt. 3
    In Media, Security and Privacy
  • NVIDIA SHIELD tablet available July 29
    In Hardware, Gadgets, and Products

Latest Media Posts

Find Out Where To Download SNES ROMs

Find Out Where To Download SNES ROMs

Multifunctional Video Conversion Tools – Wondershare Video Converter

Multifunctional Video Conversion Tools – Wondershare Video Converter

  • Popular
  • Latest
  • Today Week Month All
  • How to ‘Unblock’ multiple files at a time with PowerShell How to 'Unblock' multiple files at a time with PowerShell
  • Increase IIS Private Memory Limit to improve WSUS availability Increase IIS Private Memory Limit to improve WSUS availability
  • Command line to take ownership and change permissions Command line to take ownership and change permissions
  • Creating and editing views in phpMyAdmin Creating and editing views in phpMyAdmin
  • Read the Event Logs on Windows Server Core Read the Event Logs on Windows Server Core
  • How to Purchase Cryptocurrencies? How to Purchase Cryptocurrencies?
  • Top 6 necessary aspects to consider when hiring Angular developers Top 6 necessary aspects to consider when hiring Angular developers
  • Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business
  • Benefits of End-To-End Testing That Will Match Company Expectations Benefits of End-To-End Testing That Will Match Company Expectations
  • 3 Key Features of Pets Health Monitoring Systems 3 Key Features of Pets Health Monitoring Systems
Ajax spinner

Elevator Pitch

404 Tech Support documents solutions to IT problems, shares worthwhile software and websites, and reviews hardware, consumer electronics, and technology-related books.

Subscribe to 404TS articles by email.

Recent Posts

  • How to Purchase Cryptocurrencies?
  • Top 6 necessary aspects to consider when hiring Angular developers
  • Full guide on drawbacks and benefits of Node.js for making the perfect choice for your business

Search

FTC Disclaimer

404TechSupport is an Amazon.com affiliate; when you click on an Amazon link from 404TS, the site gets a cut of the proceeds from whatever you buy. This site also uses Skimlinks for smart monetization of other affiliate links.
Use of this site requires displaying and viewing ads as they are presented.

Copyright © 2023 · Magazine Pro Theme on Genesis Framework · WordPress · Log in