In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what are the tips for using sudo in the Linux system. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Practical Tips 1)! And!-1 usage: want to allow an authorized ordinary user to execute a command as a root user, but forget to add "sudo" before the command when you just execute the command, what should I do? Don't worry, we can use "sudo!!" Combine the command history to execute the command you just wanted to execute. Parameter "!!" Like "!-1", both allow authorized ordinary users to execute the commands we just entered as root users. Of course, we can use "sudo!-2" to execute the penultimate command.
2)-u Note:-u takes the specified user as the new identity. If this parameter is not added, root is used as the new identity by default; usage: we can use "sudo-u username-I" to specify a user to log in to shell. Note that username can be changed to another user name you want to use, and you need to enter the authorization password of username in the process.
3) sudo output redirection
[yuki@myhost] $cd / home/script/ [yuki@myhost script] $ll Total usage 1-rw-r--r--. 1 root root May 21 13:45 test.sh [yuki@myhost script] $cat test.sh [yuki@myhost script] $echo "I am the newly added content" > / home/script/test.sh-bash: / home/script/test.sh: insufficient permissions [yuki@myhost script] $sudo echo "I am the newly added content" | sudo tee / home/script/test.sh I am the newly added content [yuki@ Myhost script] $ll Total amount 2-rw-r--r--. 1 root root 25 May 21 13:50 test.sh [yuki@myhost script] $cat test.sh I am the newly added content [yuki@myhost script] $sudo echo "I am the second newly added content" | sudo tee-a / home/script/test.sh I am the second new addition [yuki@myhost script] $cat test.sh I am the second addition [yuki@] Myhost script] $sudo echo "I am the first to clear and then add." | sudo tee / home/script/test.sh I am the first to clear and then add. [yuki@myhost script] $cat test.sh I am the first to clear and then add content. 1234567891011121314151617181920212223242526274): W! sudo tee%: W! sudo tee% can be used in the vi/vim editor. We often encounter that the current login user does not have w (write) permission for a file, so when editing the file and saving it, enter this first and then you don't have to worry about not having permission to modify it.
This is the end of this article on "what are the tips for using sudo in the Linux system?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.