• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

mktemp: command not found

by Deepika

“mktemp” is a command-line utility in Linux and Unix-like systems used to create temporary files or directories. The primary purpose of “mktemp” is to provide a convenient and safe way to create temporary files in shell scripts and other programs, to avoid potential race conditions and security issues that can arise when using simple file names based on the current time or process ID.

The “mktemp” command takes a template string as an argument, which specifies the desired file name or directory name pattern. The template string can contain X’s, which are replaced with unique characters to create a unique file or directory name. For example, if you use the template “/tmp/tmp.XXXXXX”, “mktemp” will replace the X’s with a unique string of characters to create a file or directory such as “/tmp/tmp.z48xd3”.

The “mktemp” command also provides options to control the permissions of the created file or directory, to specify the directory where the temporary file should be created, and to ensure that the file or directory is readable and writable only by the user who created it.

In general, “mktemp” is a useful tool for shell script developers and system administrators, as it provides a convenient and secure way to create temporary files and directories in scripts and other programs.

If you encounter the below error while running the command mktemp:

mktemp: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install coreutils
Ubuntu apt-get install coreutils
Alpine apk add coreutils
Arch Linux pacman -S coreutils
Kali Linux apt-get install coreutils
CentOS yum install coreutils
Fedora dnf install coreutils
OS X brew install coreutils
Raspbian apt-get install coreutils

mktemp Command Examples

1. Create an empty temporary file and print the absolute path to it:

# mktemp

2. Create an empty temporary file with a given suffix and print the absolute path to file:

# mktemp --suffix ".ext"

3. Create a temporary directory and print the absolute path to it:

# mktemp -d

Filed Under: Linux

Some more articles you might also be interested in …

  1. Linux OS Service ‘yppasswdd’
  2. Command ‘df -i’ Shows ‘Inode=0’ on BTRFS File System
  3. renice Command Examples in Linux
  4. How To Create An Almost Root Equivalent Users But Not Root Identical User in Linux
  5. lrzuntar: command not found
  6. How to split iso or file using ‘split’ command in Linux
  7. lsattr: command not found
  8. How to Customize Linux Password Expiration and Complexity Requirements
  9. How to Disable the ‘lvm2-lvmetad.socket/service’ on CentOS/RHEL 7
  10. How to use ipset Command in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • protonvpn-cli Command Examples in Linux
  • protonvpn-cli connect Command Examples
  • procs Command Examples in Linux
  • prlimit: command not found

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright