What is the primary goal of the Managing Files and Directories lab?
To reinforce the commands for creating, copying, moving and deleting files and folders.
Which command is used to create an empty file?
The touch command
example touch file.txt
What is the function of the mkdir command with -p flag? example mkdir -p
It creates parent directories as needed in the specificed path.
What redirection operator overwrites the entire content of a file or creates the file if it doesn’t exist?
The standard output redirection operator >
The echo ‘Hello’ > file.txt command will __ any previous data in the file.txt
overwrite
Which redirection operator adds new data to the end of a file while preserving its existing content?
The append redirection operator»_space;
example echo “Hi”»_space; file.txt
The echo “World”»_space; file.txt
command will add “World” to the __ of the file.
to the end of the file
What command is used to copy a file?
The cp command
example cp file.txt new_location
Which single command is used for both moving and renaming files in linux?
The mv command.
how would you rename the file old.txt to new.txt using the mv command?
mv old.txt new.txt
In Linux renaming a file is conceptually the same as __ it to the same location with a different name.
moving
Why would the command rmdir FolderName fail?
It fails if the folder is not empty.
What command is used to delete a directory and all of its contents including subdirectories?
The rm - r command
ex: rm -r directory
What does the -r flag in the rm -r FolderName
command signify?
It signifies a recursive deletion processing the directory and all its contents.
What is a critical safety consideration when using the rm -r command?
The deletion is permanent and cannot be easily undone.
What command is used to navigate into a specific directory?
The cd command
ex: cd Project_Alpha
From within a subdirectory. What command navigates you back to the parent directory?
The cd command
What command is used to verify the text contents of a file directly in the terminal?
The cat command
ex: cat data_raw.txt
What command is used to list the files and directories in the current location?
The ls command
ex: ls directory_name
In the labs P2.2 step which command writes Initial Setup Complete to data_raw.txt?
echo “Inital Setup Complete” > data_raw.txt
In the lab P2.3 step. Which command appends File Version 1.0 to data_raw.txt?
echo “File Version 1.0”»_space; data_raw.txt
What command is used in step P2.4 to copy data_raw.txt into the Source folder with the new name data_v1.txt
cp data_raw.txt Source/data_v1.txt
In the labs P2.5 step, what command moves the config.ini file into the Source subfolder?
mv config.ini Source/
What is the purpose of the step P2.6 which uses the command mv data_raw.txt archive.txt?
To rename the file data_raw.txt to archive.txt