Home Operation and Maintenance Linux Operation and Maintenance How to solve the problem of insufficient permissions for the linux echo command and the linux echo command prompt

How to solve the problem of insufficient permissions for the linux echo command and the linux echo command prompt

Sep 07, 2017 am 09:44 AM
echo linux

The echo command of Linux is very commonly used in shell programming. It is also often used when printing variable value in the terminal, so it is necessary to understand the usage of echo. This article will introduce you to the linux echo command and the solution to the problem that the linux echo command prompts that the permissions are insufficient. Friends who are interested should take a look.

The echo command of Linux is very commonly used in shell programming and is printed under the terminal. The variable value is also often used, so it is necessary to understand the usage of echo

The function of the echo command is to display a piece of text on the display, which generally serves as a prompt.

The general format of this command is: echo [-n] String

The option n means no line breaks after outputting text; the string can be quoted or No quotes. When using the echo command to output a quoted string, the string is output as it is; when using the echo command to output an unquoted string, each word in the string is output as a string, and each string is separated by a space. .

Function Description: Display text.

Syntax: echo [-ne][string] or echo [--help][--version]

Additional instructions: echo will replace the entered characters The string is sent to standard output. The output strings are separated by whitespace characters, and a newline is added at the end.

Parameters: -n Do not automatically wrap at the end

-e If the following characters appear in the string, they will be treated specially and will not be treated as ordinary

text Output:

\a emits a warning sound;
\b deletes the previous character;
\c does not add a newline symbol at the end;
\f breaks a newline but the cursor still stays at the original position ;
\n Line break and the cursor moves to the beginning of the line;
\r The cursor moves to the beginning of the line, but no line break;
\t Insert tab;
\v Same as \f;
\\ Insert \ character;
\nnn Insert the ASCII character represented by nnn (octal);
–help Display help
–version Display version information

ECHO command is familiar to everyone A subcommand of the DOS batch command, but you may not know all of its functions and usages. If you don’t believe it, take a look:

1. As a switch to control whether the command line itself is displayed when the batch command is executed. Format: 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 information Format: ECHO information content The above are three common uses of the ECHO command, which everyone is familiar with and can use, but as a DOS command gold digger, you should also know the following skills:

4. Close the DOS command prompt. Type ECHO OFF in the DOS prompt state to turn off the display of the DOS prompt, leaving only the cursor on the screen. The prompt will not reappear until ECHO ON is typed.

5. Outputting a blank line is equivalent to entering a carriage return. Format: ECHO. It is worth noting that the "." in the command line must immediately follow ECHO and there must be no space in the middle, otherwise "." will be output to the screen as a prompt message. In addition, "." can be replaced by any symbol such as:;"/[/]+. In the following example, the carriage return output by ECHO. is redirected through the DOS pipe as the input of the TIME command, which is equivalent to executing the TIME command Then a carriage return is given. Therefore, when executing, the system will automatically return to the DOS prompt state after displaying the current time: C:〉ECHO.|TIME ECHO Another application example of the command outputting a blank line is : 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 the reply command: ECHO reply language | command file name above. The format can be used to simplify the operation of some commands that require human-computer dialogue (such as: CHKDSK/F; FORMAT Drive:; del *.*). It uses the DOS pipeline command to use the preset reply language output by the ECHO command as a human-computer dialogue. Command input. The following example is equivalent to entering "Y" and pressing Enter when the command being called appears in the human-computer dialogue: C:〉ECHO Y|CHKDSK/F C:〉ECHO Y|DEL A:*.*

7.Create a 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 automatic batch file C:〉ECHO C: /CPAV/BOOTSAFE〉〉AUTOEXEC.BAT appends content to the automatic batch file C:TYPE AUTOEXEC.BAT displays the automatic batch file @ECHO OFF C:/CPAV/BOOTSAFE [Commonly used]

8. The printer outputs the print content or print control code format: ECHO printer control code > PRN ECHO print content > PRN The following example is to input the print control code to the M-1724 printer. 156 means holding down the Alt key and typing 156 on the small keyboard. Similar situations can be deduced: C:〉ECHO 〈Alt〉+156〈Alt〉+42〈Alt〉+116〉PRN (enter the underscore 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 input with Ctrl+G or Alt+007. Enter multiple ^G to generate Multiple beeps. The method of use is to directly add it to the batch file or make a batch file call

.

10. Execute the ESC control sequence to modify the screen and keyboard settings. We know that the DOS device driver ANSI.SYS provides a set of ESC control sequences for modifying the screen and keyboard settings. For example, if you execute the batch program below, you can define the function key F12 as the DOS command "DIR/W" and change the screen color to white characters and blue background. @ECHO”←[0;134;”DIR/W”;13p @ECHO”←[1;37;44m (Note: The input method of the “←” character in the batch file is to press Alt on the small keyboard in the editing state 27) DOS commands are the first thing people who come into contact with computers must learn. For many people, they are too familiar and too simple. In fact, they are not the case. There is rich content in these commands, which still needs to be further understood and developed by us. , if you are a thoughtful person, you will definitely find new shining points from these commands that you think you are familiar with, and make real gold.

The following will introduce to you the solution to the problem that the linux echo command prompts that the permissions are insufficient

Problem description:​​

When using the Ubuntu system, I encountered such a problem: I logged in to the system as a normal user and then executed the sudo echo "This is testPage." >/usr/local/nginx/html/index.html command. , prompting insufficient permissions.

Although I know that the echo command belongs to the permissions of the root user, I always thought that adding sudo can obtain all the root permissions. Now I realize that this is wrong. After using the sudo command, only part of the root permissions are obtained.

Solution:

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

2. The specific implementation is as follows:


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

**Be careful here to add single quotes to the entire echo command.

The above is the detailed content of How to solve the problem of insufficient permissions for the linux echo command and the linux echo command prompt. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What computer configuration is required for vscode What computer configuration is required for vscode Apr 15, 2025 pm 09:48 PM

VS Code system requirements: Operating system: Windows 10 and above, macOS 10.12 and above, Linux distribution processor: minimum 1.6 GHz, recommended 2.0 GHz and above memory: minimum 512 MB, recommended 4 GB and above storage space: minimum 250 MB, recommended 1 GB and above other requirements: stable network connection, Xorg/Wayland (Linux)

Linux Architecture: Unveiling the 5 Basic Components Linux Architecture: Unveiling the 5 Basic Components Apr 20, 2025 am 12:04 AM

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

vscode cannot install extension vscode cannot install extension Apr 15, 2025 pm 07:18 PM

The reasons for the installation of VS Code extensions may be: network instability, insufficient permissions, system compatibility issues, VS Code version is too old, antivirus software or firewall interference. By checking network connections, permissions, log files, updating VS Code, disabling security software, and restarting VS Code or computers, you can gradually troubleshoot and resolve issues.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

Can vscode be used for mac Can vscode be used for mac Apr 15, 2025 pm 07:36 PM

VS Code is available on Mac. It has powerful extensions, Git integration, terminal and debugger, and also offers a wealth of setup options. However, for particularly large projects or highly professional development, VS Code may have performance or functional limitations.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

Where to write code in vscode Where to write code in vscode Apr 15, 2025 pm 09:54 PM

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

See all articles