WalzoneInterview Prep
📞 Interviewing soon? Practice with a realistic AI mock phone interview — it calls you, then scores you. First 15 min FREE →

Linux · Basic · question 11 of 100

How do you create, copy, move, and delete files and directories in Linux?

📕 Buy this interview preparation book: 100 Linux questions & answers — PDF + EPUB for $5

In Linux, creating, copying, moving, and deleting files and directories can be done using a variety of command-line tools. Here are some commonly used commands for these tasks:

Creating Files and Directories:

touch: Creates a new empty file. For example, "touch newfile.txt" would create a new file named "newfile.txt".

mkdir: Creates a new directory. For example, "mkdir newdir" would create a new directory named "newdir".

Copying Files and Directories:

cp: Copies a file from one location to another. For example, "cp file.txt /home/john" would copy the file "file.txt" to the "john" directory within the "home" directory.

cp -r: Copies a directory from one location to another. For example, "cp -r directory /home/john" would copy the directory "directory" and all of its contents to the "john" directory within the "home" directory.

Moving Files and Directories:

mv: Moves a file from one location to another. For example, "mv file.txt /home/john" would move the file "file.txt" to the "john" directory within the "home" directory.

mv -r: Moves a directory from one location to another. For example, "mv directory /home/john" would move the directory "directory" and all of its contents to the "john" directory within the "home" directory.

Deleting Files and Directories:

rm: Deletes a file. For example, "rm file.txt" would delete the file "file.txt".

rm -r: Deletes a directory and all of its contents. For example, "rm -r directory" would delete the directory "directory" and all of its contents.

It is important to use caution when deleting files and directories, as these actions cannot be undone and can result in permanent data loss. Additionally, some system files and directories may be restricted and require administrative privileges to modify or delete.

Reading is step one. Saying it out loud is the interview. Our AI interviewer calls your phone and runs a realistic Linux interview — then scores it.
📞 Practice Linux — free 15 min
📕 Buy this interview preparation book: 100 Linux questions & answers — PDF + EPUB for $5

All 100 Linux questions · All topics