How Do I Create a Tmp Folder in Linux?
Contents

In Unix/Linux shell we can use the mktemp commmand to create a temporary directory inside the /tmp directory. The -d flag instructs the command to create the directory. The -t flag allows us to provide a template. Each X character will be replaced by a random character.

How do I create a tmp file in Linux?

How to create a temporary file using mktemp? Simple. Just execute ‘mktemp’ sans any option. You’ll see a temporary file will get created in the /tmp/ folder.

How do I create a folder in tmp?

5 Answers. Use mktemp -d . It creates a temporary directory with a random name and makes sure that file doesn’t already exist. You need to remember to delete the directory after using it though.

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest