Temporary files are used to temporarily store data that the operating system needs temporarily during operation and will disappear when no longer needed. they will disappear on their own after reboot.
This command in Linux allows the user to make a temporary file or directory in the tmp folder. Now we’re gonna teach you to use the mktemp command in Linux.
The syntax:
$ mktemp [option] … [template]
For example:
$ mktemp
Output:
You have just created a temporary file in the tmp directory. And the filename is also generated automatically.
To do this. Let’s add the option -d into the command:
$ mktemp -d
Output:
If you want to name the temporary file, add more than 3 X’s at the end. For example:
$ mktemp newfileXXX
Output:
Or you can name the temporary directory:
$ mktemp -d newdicXXX
Output:
To do this. Let’s add the option –suffix into the command. For example:
$ mktemp newfileXXX --suffix ".txt"
Output:
We just taught you to use the mktemp command in Linux.
Thank you for referring!
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications including CCNA RS, SCP, and ACE. As an IT engineer and technical author, he writes for various websites.
This article provides a guide to deploy ScyllaDB on Ubuntu VPS. What is ScyllaDB? ScyllaDB…
This article demonstrates how to harden security of VPS server and is intended for server…
In this blog post, we will guide you on how to install wget on Ubuntu…
Jan 27,2026 Xfwl4 - The roadmap for a Xfce Wayland Compositor We, the Xfce team…
This article provides a step-by-step how-to guide to deploy n8n on Ubuntu VPS. What is…
In July 2025, git received CVE-2025-48384, a high vulnerability allowing arbitrary code execution when cloning…