In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to use the script command in Linux. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
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] $script Script started, file is typescript [alvin@VM_0_16_centos test] $echo hello hello [alvin@VM_0_16_centos test] $ls test1.py test2 test2.cpp test2.py test3 test3.c test.py typescript WeixinBot wxpy wxRobot [alvin@VM_0_16_centos test] $exit exit Script 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-script Script started File is / home/alvin/alvin-script [alvin@VM_0_16_centos test] $ll total 64-rw-rw-r-- 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 typescript drwxrwxr-x 6 alvin alvin 4096 Nov 10 11:19 WeixinBot drwxrwxr-x 6 alvin alvin 4096 Nov 10 11:30 wxpy drwxrwxr-x 11 alvin alvin 4096 Nov 10 11:34 wxRobot [alvin@VM_0_16_centos test] $echo hello hello [alvin @ VM_0_16_centos test] $exit exit Script 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-job Script started, file is cooperate-job [alvin@VM_0_16_centos test] $echo this is alvin_s job this is alvin_s job [alvin@VM_0_16_centos test] $ls cooperate-job test1.py test2 test2.cpp test2.py test3 test3.c test.py typescript WeixinBot wxpy wxRobot [alvin@VM_0_16_centos test] $exit exit Script 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-job Script started, file is cooperate-job [alvin@VM_0_16_centos test] $echo this is harry_s job this is harry_s job [alvin@VM_0_16_centos test] $pwd / home/alvin/test [alvin@VM_0_16_centos test] $exit exit Script done, file is cooperate-job
How to record the operation process when asking someone to assist remotely?
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.6 Script started, file is / home/alvin/test/script-file # hint [alvin@VM_0_16_centos ~] $on "how to use script commands in Linux" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.
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.