In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to use the script command in Linux, which has a certain reference value, and interested friends can refer to it. I hope you can learn a lot after reading this article.
The Linux script command script is a magic command. Script can record the session of the terminal, and then use scriptreplay to play the recorded results to others. The advantage of script is that all your actions, typed commands and printed results on the terminal can be recorded as they are. It can be applied to teaching, demonstration and audit.
Working with scen
1. Debugging applications that generate a large number of log, which need to be saved locally for further analysis.
2. If you work together with your colleagues, you can record the operation process and send it to your colleagues when you have finished half of the work yourself. Colleagues can continue to work according to the records.
3. Ask someone to assist you remotely. If you are worried about the other person's mischief, you can also leave a criminal record. It is best to record his operation.
How do I use the script command?
By default, enter the script command directly, which will automatically create a typescript file in the current directory, and then all your actions on this terminal will be recorded in this file.
The record file is a text file that can be opened and viewed using any text tool.
If you want to exit recording, you can press the shortcut key ctrl + D in the terminal or type exit directly. Before exiting script, you will find that the record file size is 0 Kb. After exiting, the file size will become larger.
[alvin@VM_0_16_centos test] $scriptScript started, file is typescripts [Alvin @ VM_0_16_centos test] $echo Hellohello [Alvin @ VM_0_16_centos test] $lstest1.py test2 test2.cpp test2.py test3 test3.c test.py typescript WeixinBot wxpy wxRobot [alvin@VM_0_16_centos test] $exitexitScript done, file is typescript
If we want to have our own file name, or put the file in another location, we can just follow the file name after script.
[alvin@VM_0_16_centos test] $script ~ / alvin-scriptScript started File is / home/alvin/alvin-script [alvin@VM_0_16_centos test] $lltotal 64 RWMurray-1 alvin alvin 21 Nov 10 09:40 test1.py-rwxrwxr-x 1 alvin alvin 14074 Dec 31 07:35 test2-rw-rw-r-- 1 alvin alvin 403 Dec 31 07:35 test2.cpp-rw-rw-r-- 1 alvin alvin 2093 Nov 10 10:50 test2.py-rwxrwxr-x 1 alvin alvin 8553 Jan 7 20:03 test3-rw -rw-r-- 1 alvin alvin 78 Jan 7 20:03 test3.c-rw-rw-r-- 1 alvin alvin 94 Nov 9 23:25 test.py-rw-rw-r-- 1 alvin alvin 489 Jan 11 12:07 typescriptdrwxrwxr-x 6 alvin alvin 4096 Nov 10 11:19 WeixinBotdrwxrwxr-x 6 alvin alvin 4096 Nov 10 11:30 wxpydrwxrwxr-x 11 alvin alvin 4096 Nov 10 11:34 wxRobotalvin @ VM_0_16_centos test $echo helloloalvin @ VM_0_16_centos test] $exitexitScript done File is / home/alvin/alvin-script
By learning these two basic operations, you can cope with many scenarios where terminals need to be recorded.
How do I use script to collaborate with colleagues?
Now there is a job that needs to work with my colleagues. I finish half of it and he finishes the other half.
First of all, I'll do my job and record my work process with script:
[alvin@VM_0_16_centos test] $script cooperate-jobScript started, file is cooperate-job [alvin@VM_0_16_centos test] $echo this is alvin_s jobthis is alvin_s Jobb [Alvin @ VM_0_16_centos test] $lscooperate-job test1.py test2 test2.cpp test2.py test3 test3.c test.py typescript WeixinBot wxpy wxRobot [alvin @ VM_0_16_centos test] $exitexitScript done, file is cooperate-job
After the work is finished, send the record file to a colleague, he can use a text tool to open it, you can know your progress, and then follow your progress.
If he wants to continue to record his actions in your log file, he can add a-an option, that is, the abbreviation of append.
[alvin@VM_0_16_centos test] $script-a cooperate-jobScript started, file is cooperate-job [alvin@VM_0_16_centos test] $echo this is harry_s jobthis is harry_s Jobb [Alvin @ VM_0_16_centos test] $pwd/home/alvin/ Testt [Alvin @ VM_0_16_centos test] $exitexitScript done, how does file is cooperate-job record his operation when he asks for remote assistance?
Let others log on to their own computer, if the acquaintance is good, is a stranger, then there will be some uneasiness in the heart. To rest assured, let's secretly record what he has done.
We can add the script command to the Shell configuration file, and once the user logs in, the script command starts automatically and records all the operations of the operator.
To do this, we can modify the .bash _ profile file.
Vim / .bash_profile
On the last line, we add the script command:
/ usr/bin/script-qa your_path # make up your own path
Then save it, using source or. The order gives effect to it. The next time someone else logs in to the system, script will run automatically and save the record file in the location you specified.
In this case, the-Q option represents a silent record, and the other party will not know that you are recording in the background. If you do not use this option, he will receive this prompt:
Last login: Fri Jan 11 15:13:37 2019 from 119.33.28.6Script started, file is / home/alvin/test/script-file # Tip [alvin@VM_0_16_centos] $Thank you for reading this article carefully. I hope the article "how to use script commands in Linux" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.