Linux learning

Difference between # and $ in Linux

【#】represents root authority
【$】represents ordinary users

If you change documents such as /etc/profile , or ~/.bashrc, you can replace them with any symbols.

[root@locate~] in the Linux window, where [~] represents the home directory of the user (root is /root, and general user is /home/username); [./] and [.] represent the current directory; [ ../] represents the parent directory

Difference between && and ; under Linux

Similar: can be executed as and when both the preceding and following statements are true.

Difference: && will execute the next sentence only if the previous sentence succeeds; the latter sentence will be executed regardless of whether the previous sentence is successfully executed or not.

experiment:

There is no folder named 123 in the precondition /home directory, enter the statement

cd /home/123 && echo zkk  

result

-bash: cd: /home/123: no such file or directory 

It can be seen that eco zkk is not executed

Experiment 2:

Preconditions remain unchanged

cd /home/123 ; echo zkk  

result

-bash: cd: /home/123: no such file or directory  
zkk  

Experimental conclusion: && will not continue to execute the next command after the previous sentence reports an error, ; will execute the subsequent command regardless of the result of the previous sentence.  

Difference between ~ and / in linux

/ stands for the root directory and ~ stands for the personal directory.

If cd, / goes to the root directory, ~ goes to the personal directory.

/ is the delimiter and symbol of the directory level. There is only one / to indicate root, and /etc/ to indicate the etc directory under the root directory (of course, the directory does not need / at the end, but / directly indicates that it is a directory, and there is no / at the end, then /etc needs to be checked to determine whether it is a directory or a directory. file, although it is customary for /etc to be a directory)
~ is a surrogate symbol, indicating the address of a personal directory, because each user has its own personal directory address, so use ~ as a unified replacement. This varies according to users, but There are rules to follow to ensure compatibility issues in some cases.
If you log in as root account
~represents /root/
If you log in as name
~represents /home/name/

The difference between linux > and >>, the use of <

>> is an addition

> is to overwrite the original content

bogon:Desktop wenxuechao$ echo 'abc' > test.txt  
bogon:Desktop wenxuechao$ echo '123' >> test.txt  

The first command will create a test.txt file on the desktop and write abc to the file.

The second command will write the content again below the file.

Difference between $() and ${} in Linux

$(): The parentheses are the command, which is the same as the `` backticks, execute this command

For example, todaydate=$(date +%Y%m%d) means to execute the date command and return the execution result to the variable todaydate, which can also be written as todaydate=`date +%Y%m%d`;

${}: variables are placed here for reference

For example, echo ${PATH} takes the value of the PATH variable and prints it, or without parentheses such as $PATH.

  

  

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325266801&siteId=291194637