Basic usage of the echo command for linux
This article mainly explains "the basic usage of the echo command of linux". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the basic usage of the echo command of linux.
The most basic thing about echo is as output. The basic syntax is as follows:
Content to be exported by echo root@kali:~/eth20/eth20# echo hello eth20hello eth20root@kali:~/eth20/eth20# echo "hello eth20" hello eth20
But if there are some special characters in the output, it is very likely to be eaten!
Root@kali:~/eth20/eth20# echo "hello eth20" welcome "hello eth20 welcome
At this point, we can use the parameter-e to turn on the escape!
Root@kali:~/eth20/eth20# echo-e "hello eth20\" welcome\ "hello eth20" welcome "root@kali:~/eth20/eth20#
So we can output special characters! And you can use escape characters\ nto break lines! But you'd better leave a space before\ n.But you'd better leave a space before.
Root@kali:~/eth20/eth20# echo-e "hello eth20\ n\" welcome\ "" hello eth20 "welcome"
In addition, for single quotation marks, we do not need to add escape characters!
Root@kali:~/eth20/eth20# echo-e "hello eth20\ n\" welcome\ "'eth20'" hello eth20 "welcome"' eth20'root@kali:~/eth20/eth20# echo-e "hello eth20\ n\" welcome\ "\ 'eth20\'" hello eth20 "welcome"\ 'eth20\' root@kali:~/eth20/eth20#
Through the simple use of echo, only the content can be output, so we can write our output to a file using redirects > or adders > >!
In addition, we can use the symbol ``to execute system commands through echo, even if there is no automatic line wrapping!
Root@kali:~/eth20/eth20# echo `whoami`rootroot @ kali:~/eth20/eth20#root@kali:~/eth20/eth20# echo `cat / etc/ passwd`root: x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin bin:x:2:2:bin:/bin:/usr/sbin/nologin
Can we use wget to download any file to the server? Or use nc directly to get a reverse connection?
Finally, on windows systems, use echo. | commands to execute system commands!
F:\ eth20-CTF-Toolkits\ CTF Toolkit\ injection Detection\ Python27\ sqlmap1.1.8 > echo. | | whoamietxx\ etxxF:\ eth20-CTF-Toolkits\ CTF toolkit\ injection detection\ Python27\ sqlmap1.1.8 > echo. | whoamietxx\ etxxF:\ eth20-CTF-Toolkits\ CTF toolkit\ injection detection\ Python27\ sqlmap1.1.8 > Thank you for reading. The above is the content of "basic usage of linux echo command". After the study of this article, I believe you have a deeper understanding of the basic usage of linux echo command. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!