mktemp Create temporary files or directories in a safe way. Applicable scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora. 1. Grammar mktemp [options] [TEMPLATE] 2. List of options
3. Examples 1) Create a temporary file [root@localhost weijie]# mktemp wj123.XXXX //The name contains 4 Xs wj123.kpET You have new mail in /var/spool/mail/root [root@localhost weijie]# mktemp wj123.XXXXXX //The name contains 6 Xs wj123.oH2o4P [root@localhost weijie]# ls 1.c wj123.kpET wj123.oH2o4P 2) Create a temporary directory [root@localhost weijie]# mktemp -d wjtp //There is no X in the name mktemp: too few Xs in template "wjtp" [root@localhost weijie]# mktemp -d wjtpxxx //There is no X in the name. Here you can see that X must be uppercase. mktemp: Too few Xs in template "wjtpxxx" [root@localhost weijie]# mktemp -d wjtpXXX //Created successfully wjtpflR [root@localhost weijie]# ls -l Total dosage 4 -rw-r--r-- 1 root root 0 Sep 7 09:11 1.c -rw------ 1 root root 0 September 7 14:47 wj123.kpET -rw------ 1 root root 0 Sep 7 14:47 wj123.oH2o4P drwx------ 2 root root 4096 September 7 14:50 wjtpflR 3) Create a temporary file in /tmp [root@localhost weijie]# mktemp --tmpdir wj234.XXX //tmpdir does not specify a path, create /tmp/wj234.BNy under tmp You have new mail in /var/spool/mail/root 4) Create a temporary directory in the specified directory [root@localhost weijie]# mktemp --tmpdir=/weijie wj234.XXX //Create /weijie/wj234.q1C in the path specified by tmpdir [root@localhost weijie]# ls 1.c wj123.kpET wj123.oH2o4P wj234.q1C wjtpflR 5) Create using option -u [root@localhost weijie]# mktemp -u wj123.XXXXXX //Use the -u option wj123.dSgIKl [root@localhost weijie]#ls //Cannot see the temporary file because it is not created 1.c wj123.kpET wj123.oH2o4P wj234.q1C wjtpflR Supplement: Linux basic commands 1. Basic commands 1. ls: List files or directories in the current directory 2. ls -a: List all files and directories in the current directory (including hidden files) 3. ls -l: Display detailed information of the file (long format information view), equivalent to ll ls -hl: Display detailed information and file size of the file 4. cat command: view file information (can only view files) [root@com ~]# cat /etc/passwd: View all user information Note: Every time a user is created in the Linux system, a corresponding user group will be automatically generated. 5. cd command: switch directory [root@com ~]# cd /etc: Switch to the etc directory under the root directory pwd: Display the directory of the current file whoami: View the current user [root@com etc]# whoami: View the current user is root user root 6. /: indicates the user's root directory Home directory (host directory) 1) Home directory of the administrator user: [root@com ~]# pwd /root 2) Home directory of ordinary users: [java17@com ~]$ pwd /home/java17 7. Switch user command: su - username 1) Switch to a normal user [root@com ~]# su - java17 [java17@com ~]$ pwd /home/java17 2) Switch to the root administrator user [java17@com ~]$ su - or [java17@com ~]$ su - root Password: 8. Shutdown, restart, clear screen Shutdown: halt, init 0, shutdown now Summarize The above is a detailed explanation of mktemp, a basic Linux command, introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: How to change the root password of Mysql5.7.10 on MAC
>>: Detailed explanation of vite2.0 configuration learning (typescript version)
1. Command method Run the nginx service in the cr...
In fact, it is very simple to encapsulate axios i...
This also caused the inability to upload png files...
Table of contents 1. Detailed syntax of entires()...
Table of contents 1. Preface 2. Find two pop-up c...
This article shares the specific code of javascri...
Table of contents 1. Introduction 2. Interface 3....
Table of contents 1. Basic storage of files and d...
vue+element UI encapsulates a public function to ...
Today someone talked to me about a website develo...
This article shares the specific code of JavaScri...
Payment countdown to return to the home page case...
Written at the beginning I remember seeing a shar...
This article example shares the specific code of ...
Docker Installation curl -fsSL https://get.docker...