Open main menu

CDOT Wiki β

Changes

Tutorial 2 - Unix / Linux File Management

No change in size, 18:35, 30 August 2021
Part 3: Removing Directories
# Confirm that you are located in your home directory.<br><br>The '''rmdir''' command is used to remove <u>empty</u> directories.<br><br>
# Issue the following Linux command to remove the empty directory called '''tutorials''': <span style="color:blue;font-weight:bold;font-family:courier;">rmdir uli101xxosl640xx/tutorials</span><br><br>
# Issue a command to confirm that you removed the '''tutorials''' directory.<br><br>
# Issue the following Linux command to remove the empty directory called '''uli101xxosl640xx''': <span style="color:blue;font-weight:bold;font-family:courier;">rmdir uli101xxosl640xx</span><br><br>NOTE: You should get an '''error message''', since the '''uli101xxosl640xx''' directory is '''NOT''' empty.<br><br>To remove non-empty directories, you can use the '''rm -r''' command.<br>The '''-r''' option stands for recursive, which can travel down the directory paths and their contents.<br><br># Issue the following Linux command to remove the '''uli101xxosl640xx''' directory and its contents: <span style="color:blue;font-weight:bold;font-family:courier;">rm -r uli101xxosl640xx</span><br><br># Issue the '''tree''' command to confirm that the uli101xx osl640xx directory (contained in your home directory) and its contents have been removed.<br><br>'''NOTE:''' To <u>safely</u> remove non-empty directories, you can add the '''-i''' option which will prompt the user if they wish to remove contents as it your travel recursively down a directory to remove directories and their contents.<br><br># Issue the following Linux command (entering "y" when prompted): <span style="color:blue;font-weight:bold;font-family:courier;">rm -ri xyz100xxnwk680xx</span><br><br>'''NOTE:''' You should have removed all directories that you have created.<br><br>Let's run a checking script to confirm that you have correctly removed all of those directories.<br><br>
# Issue the '''tree''' command to confirm that all of those recently created directories have been removed.<br><br>
# Issue the following Linux command to run a checking script to confirm removal of those directories:<br><span style="color:blue;font-weight:bold;font-family:courier;">~uli101osl640/week2-check-3</span><br><br>
# If you encounter errors, make corrections and re-run the checking script until you receive a congratulations message, and proceed to the next INVESTIGATION.<br><br>