1. What is a shell?
The shell is the interface between the user and the kernel;
2. What are the different types of shells commonly used on typical Linux systems?
bash, sh, etc .;
3. What is the difference between soft links and hard links?
The soft link is equivalent to a shortcut, which is a link to the file name. Deleting the original file will make the soft link in a broken state;
The hard link is equivalent to copying and deleting the original file without affecting the hard link;
4. How to pass and access script parameters in Linux?
Write $ 1, $ 2 in the script (a.sh), and add parameters when executing the script (./a.sh "arg1" "arg2")
5. What is the meaning of $ #?
$ # Display the parameter count passed to the script;
6. I want to monitor a constantly updated log file, what command can be used to achieve this purpose most effectively;
tail -f file name; the last 10 lines are displayed by default, and the updated part of the file is continuously displayed;
7. I want to connect to a remote server and execute some commands, how do I achieve this?
We can use ssh to do this; ssh username @ serverIP -p sshport; if sshport is 22, you can also omit -p, for example, ssh root $ 183.13.27.97;
8. What are the 3 standard streams in Linux?
0-standard input; 1-standard output; 2-standard error;
9. Syntax of for loop
10. Write the syntax of if condition in linux;
11. What is a shell script, is it necessary?
A shell script is a text file that contains one or more commands. Sometimes it is often necessary to use multiple commands to complete a task, we can add all these commands to the shell script to complete these daily tasks;
12. What types of variables can be used in shell scripts?
System-defined variables (set view), user-defined variables (variable value can be viewed by echo $ variable name);
13. Execute the script;
bash a.sh; cat a.sh |bash; ./a.sh;
14. Variable use
name=`cat a.sh`
echo $ name (unformatted); echo "$ name" (consistent with the Linux viewing effect, formatted)
When assigning a shell, you don't need to consider the value type, such as string, integer, and decimal; the default assignment is a string;
Local variable, name = xixi is used in the current process (parent process or child process cannot be used); pstree -p; (view process tree)
Global variables (environment variables), export name or export name = hehe (assigned and declared as a global variable) or declare -x name = hehe; (you can always download n-level processes down); (env view global variables)
unset name; delete variable name;
set displays all variables, standard variables, global variables;
() Open the subshell (pid is the same as the current shell and pid), one-time, does not affect the current shell; it is over after the execution;
{} Affect the current environment;
(ls; pwd), {ls; pwd;} There is no difference, but the assignment is different, such as (name = hua; echo $ name)
Remote file upload: scp file name username @ ip: path
shift
$? Determines whether the last command was successful; after executing the script, $? Determines whether the last command executed in the script is correct (for example, the first script has a syntax error, and the last one in the script position is not executed);
bash -x a.sh distributed execution;