Test the logic of basic Linux commands 1. Test the linux Logic
1. Use test to judge the result of a command. The return value is 0 or an integer. Returns 0 to true, and an integer to indicate the error code.
2. Use $?
3. For example
My server has a folder like/home/www, so the return result of the ls/home/www command is 0;
Echo $? The returned value is 0.
My server does not have a folder such as/home/kkk, so the returned result of the ls/home/kkk command is the error code after the command is executed;
Echo $? The returned result is 2. This 2 indicates that the file or folder does not exist.
4. Common file test characters
-E indicates whether the file name exists.
-F indicates whether the file name is a file.
-D indicates whether the file name is a folder.
-R indicates whether the file name is readable.
-W indicates whether the file is writable.
-X indicates whether the file is executable.
-S indicates whether the file asks socket
4.1 On my server/home/www is a folder
Therefore, the result of test-e/home/www is 0, that is, true. This file name exists.
Therefore, the result of test-f/home/www is not 0, that is, false. The file name is not a file.
Therefore, the result of test-d/home/www is 0, that is, true, and the file name is a folder.
4.2 The file name/home/kkk does not exist on my server
Therefore, the result of test-e/home/kkk is not 0, that is, false. The file name does not exist.
Therefore, the result of test-d/home/kkk is not 0, that is, false. This file name does not ask the folder.
How to view logical volumes in linux
First, from the results, your system does not use LVM (logical volume management), so there is nothing to view.
In addition, you can also use the command
# Lvdisplay
The command results also show whether the system uses LV. If you use LV, this is what you need.
If you want to view the status of the file system, use the command
# Dumpe2fs/dev/sda1
I don't know which one is what you want?
How does one perform testing in Linux?
Test whether the function is OK Based on the functions implemented by the software, and test whether unexpected bugs may occur.