Their usual test work in the Linux often to build a test environment, there are related to start/Stop the server, modify the Tomcat configuration file, occasionally hit the port is occupied ...
At this point, you have to need some basic Linux commands to handle these problems (by the way, to pack B tour)
1.CD command
For switching directories (you can switch one level at a time, or you can switch to the specified directory at once)
[[Email protected] ~]$ CD Shipping/[[email protected] ~]$ CD Shipping/apache-tomcat-7.0.55/bin/[[email protected] ~]$ CD. . Back to previous level [[email protected] ~]$ CD/ back to root directory
2.ls command
Show which files are in the current directory
[[email protected] ~]$ ls2017-03-27_all.log gold shipping test[[email protected] ~]$ ls-a Show All Files, Include hidden files (preceded with ".") files). 2017-03-27_all.log . bash_history. bashrc . java shipping test ... Ansible . Bash_profile Gold lesshst . SSH . Viminfo[[email protected] ~]$ ls-l Show file Details total usage 276-rw-r--r--. 1 Hanmengkai default 269527 March 16:41 2017-03-27_all.logdrwxr-xr-x 4 hanmengkai default 4096 March 2 09:41 Golddrwxr-xr-x. 3 Hanmengkai default 4096 March 1 18:58 shippingdrwxr-xr-x 3 hanmengkai default 4096 May 13:56 test
3.mkdir command
Create a Directory
[Email protected] test]$ mkdir KK Create a new directory under current directory [[email protected] test]$ mkdir QQ AA Create multiple directories simultaneously [email Protected] test]$ mkdir-p kk/mk Plus-p parameter, you can create a new directory under a directory
4.RM command
Delete a file or directory
[[Email protected] test]$ RM sh.xml Delete a file (followed by file name) [[email protected] test]$ rm-i ssa.xml plus parameter-I, Before deleting, ask whether to delete RM: Delete normal file "Ssa.xml"? [[email protected] test]$ rm-i *.log Delete any. log files; Confirm RM: Delete normal empty file "1.log" before deleting? NRM: Do you want to delete the normal empty file "2.log"? NRM: Do you want to delete the normal empty file "3.log"? N[[email protected] test]$ rm-r KK plus parameter-r, means delete directory Kk[[email protected] test]$ rm-ri QQ directory and directory in the file delete, (without the I parameter, RM: Do you want to enter the directory "QQ"? YRM: Do you want to enter the directory "QQ/QQ"? YRM: Do you want to delete the directory "qq/qq/km"? YRM: Do you want to delete the directory "QQ/QQ/MK"? Y
5.CP command
Copy a file or directory
CP [Options] ... Source... purpose [[email protected] test]$ CP 1.log aa/ copy 1.log files to the AA directory
[[email protected] test]$ cp-r aa/ccvv/ Copy the contents of the AA directory and directory into the CCVV directory [[email protected] test]$ CP-a 1.log 2.log Complex (Backup) A 1.log file, the name of the new file is 2.log[[email protected] test]$ cp aa/1.log sh/ Copy the 1.log file under the AA directory to the SH directory
6.tar command
You can package a bunch of files or directories into a single file that you can package, compress, unzip
Syntax: Tar parameter package compressed file name needs to be packaged files/directory name common parameters:-C Package- x Extract files from a compressed package- v display operation Process- F Specify ZIP/Unzip file name- z package simultaneous compression/decompression [[email protected] test]$ TAR-CVF log.tar 1.log 2.log 3.log 3 log files into a tar package, Named Log.tar[email protected] test]$ tar-xvf log.tar unpacking [[email protected] test]$ TAR-ZCVF log.tar.gz 1.log 2.log 3.lo G 3 log files into a tar package and compressed in gzip format, named Log.tar.gz[[email protected] aa]$ tar-zxvf log.tar.gz extract log.tar.gz to the current folder [ [Email protected] aa]$ TAR-ZXVF log.tar.gz 1.log extract only the 1.log files in the package [email protected] aa]$ TAR-ZTVF LOG.TAR.GZ
view file names in log.tar.gz (parameter T)-rw-r--r--hanmengkai/default 7 2017-05-12 15:34 1.log-rw-r--r--Hanmengkai/default 0 2017-05-12 15:15 2.log-rw-r--r--hanmengkai/default 0 2017-05-12 15:15 3.log[[email protected] aa]$ TAR-ZXVF log.tar.gz- The C wq/ -D parameter extracts the compressed package to the specified directory (the WQ directory specified here)
7.true command
Empty the contents of the file
[[email protected] aa]$ true >catalina.out so that the contents of the file is emptied (can be used to view the log, the first empty the existing log, and then re-log, so that the eyes are not easy to blind ...) )
Several Linux commands frequently used in test work (first bullet)