Solutions to insufficient prompt permission of Linux echo command and Linux echo command


Echo command of Linux is very commonly used in shell programming. It is also often used when printing the variable value under the terminal. Therefore, it is necessary to understand the usage of echo.

The function of echo command is to display a paragraph of text on the display, which generally plays a role of prompt.

The general format of this command is:Echo [- n] string

Where option n means no line wrapping after the output text; strings can be quoted or not. When using echo command to output quoted string, the string will be output as it is; when using echo command to output unquoted string, each word in the string will be output as a string, and each string will be separated by a space.

Function Description: display text.

Grammar:Echo [- Ne] [string] or echo [-- help] [-- version]

Note: echo will send the input string to standard output. The output strings are separated by white space characters, and the line number is added at the end.

Argument: – n do not wrap at the end

-E if the following characters appear in the string, they will be treated specially, rather than as general characters

Text output:

Give a warning tone;
Delete the previous character;
Do not add line break at the end;
Line break but the cursor remains in the original position;
Wrap the line and move the cursor to the beginning of the line;
Move the cursor to the beginning of the line without wrapping;
\ tinsert tab;
Same as \ f;
\ \ insert \ character;
Insert the ASCII character represented by NNN (octal);
– help display help
– version displays version information

Echo command is a sub command of DOS batch command that everyone is familiar with. However, some of its functions and usage may not be known to you.

1. As a switch format to control whether the batch command displays the command line itself when executing: echo [on|off] if you want to turn off the display of the “echo off” command line itself, you need to add “@” before the command line.

2. Display the current echo setting status format: Echo

3. Output prompt message format: the above is the common three usage of echo command, which is familiar and can be used by everyone, but as a gold digger of DOS command, you should also know the following skills:

4. Close the DOS command prompt. Type echo off at the DOS prompt. The display of the DOS prompt can be closed so that only the cursor is left on the screen. The prompt will not reappear until you type echo on.

5. Output blank line, which is equivalent to entering a carriage return format: echo. It is worth noting that “.” in the command line must be followed by echo without space in the middle, otherwise “.” will be output to the screen as a prompt message. In addition, the “.” can be replaced by any symbol such as,:; “/ [/] +. In the following example, the return output by echo. Is turned as the input of the time command through the DOS pipeline, which is equivalent to giving a return after the time command is executed. Therefore, the system will automatically return to DOS prompt status after displaying the current time during execution:C:〉ECHO.|TIME ECHOAnother application example of the command output blank line is to add echo. To the automatic batch file so that the prompt screen originally displayed at the bottom of the screen appears at the top of the screen.

6. Question format in reply command: echo reply | command filename the above format can be used to simplify the operation of some commands requiring man-machine conversation (such as CHKDSK / F; format drive:; del *. *). It uses the preset reply output from echo command as the input of man-machine conversation command through DOS pipeline command. The following example is equivalent to entering “Y” enter: C: > echo y| CHKDSK / F C: > echo y| del A: *.*

7. Create new file or add file content format: echo file content > file name echo file content > file name for example: C: > echo @ echo off > autoexec.bat create auto batch file C: > echo C: / cpav / bootsafe > autoexec.bat add content to auto batch file C: type autoexec.bat display the auto batch file @ echo off C: / cpav / bootsafe [common]

8. Output print content or print control code format to printer: echo printer control code > PRN echo print content > PRN the following example is to input print control code to m-1724 printer. < ALT > 156 is to press and hold the ALT key and type 156 on the keypad, and so on: C: > echo (ALT) + 156 (ALT) + 42 (ALT) + 116) PRN (enter underline command FS * t) C: > echo (ALT) + 155 @) PRN (enter initialization command ESC @) C: > echo. > PRN (line feed)

9. Make the horn sound C: > echo ^ g “^ g” is entered by using Ctrl + G or Alt + 007. Multiple sounds can be generated by entering multiple ^ G. The use method is to directly add it to the batch file or make it into a batch file call.

10. Execute ESC control sequence to modify screen and keyboard settings. We know that ansi.sys, the device driver of DOS, provides a set of ESC control sequence to modify screen and keyboard settings. If the following batch program is executed, function key F12 can be defined as DOS command “dir / W”, and screen color can be changed to white character and blue background. @Echo “← [0; 134;” dir / W “; 13P @ echo” ← [1; 37; 44m (Note: the input method of “←” character in batch file is to press the 27 on ALT keypad in editing state). DOS command is the first thing that people who contact the computer should learn. It’s too familiar to many people. It’s too simple. In fact, there are rich contents in these commands, which need to be further studied. To understand and develop, if you are a person with intention, you will surely find new flash points from these commands that you think are familiar with, and get real gold.

Here’s how to solve the insufficient permission of the command prompt of Linux echo

Problem Description:

When using Ubuntu system, I encountered such a problem: when I log in to the system with a normal user and execute sudo echo “this is testpage.” > / usr / local / nginx / HTML / index.html command, I am prompted that the permission is not enough.

Although I know that the echo command belongs to the root user’s permission, I always thought that adding sudo would get all the root permissions. Now I find that this is wrong. After using the sudo command, only part of the root permission is obtained.

terms of settlement:

1. Use root directly, so there will be no problem;

2. The specific implementation is as follows:

sudo sh -c 'echo "This is testPage." >/usr/local/nginx/html/index.html' 

**Note here that you want to single quote the entire echo command.


The above is the solution to the insufficient permission of Linux echo command and Linux echo command prompt introduced by Xiaobian to you. I hope it can help you. If you have any questions, please leave a message to me, and Xiaobian will reply to you in time. Thank you very much for your support of the developepaer website!