In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you an example of the use of commonly used commands in Linux, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Basic concept
Linux system has the same file management as Windows, and the path of file is divided into absolute path and relative path. The absolute path starts with /, such as / usr/local, while the relative road strength does not start with /, such as.. /, which is the upper level of the current directory.
In the Linux system, different users have different home directories (that is, different users log in to the initial location of the Linux). If you log in as a root account, the home directory is / root/,. If you log in as an ordinary user xxx, then the default home directory of the system is / home/xxx/,. Of course, you can also specify the home directory of ordinary users as other directories, which will be supplemented in subsequent articles.
Common command
1. Pwd, check the absolute path of the current directory and show that it starts with /
2. Ls, view the files or folders under the current path
Ls / display only the name of the file or folder in this directory ls-l / display the details of the file or folder in this directory, ls-l = = > ll, more often use ll instead of for example: [hadoop@hadoop01 ~] $ls-l / hometotal 0drwx-(permission) 2 hadoop (user) hadoop (user group) 79 Jun 3 19:31 (time) hadoop (file or folder name) ll-h view file size You can only look at files, not folders. If you want to see the folder size, please use the du-sh file or folder name ll-rt to sort the files or folders in time. You can find the latest files or folders.
3. Cd, switch directories
Cd-go back to the previous directory cd.. / roll back the previous directory (relative path) cd.. / fallback 2 directories (relative path) three ways to return to the home directory: cd+ enter, cd ~, cd / the absolute path of the user's home directory
4. Mkdir, create a folder
Mkdir xxx can only create 1 mkdir-p xxx/1/2 cascade create folder mkdir 4 5 6 parallel create 4 5 6 folder
5. Vi/touch, create a file
Touch filename vi filename 1. Command line mode I enter edit mode 2.esc fallback to command line mode 3.shiftkeeper: trailing mode wq save exit
6. Cp, copy files / folders
Cp xxx.log xxx/cp-r xx xx/ folder copy requires-r parameter
7. Mv, move or rename files / folders
Mv test.log test move file to new place name unchanged mv test1.log test/test123.log move file to new place name change mv test1 test mobile folder
8. Cat/more/less, view the contents of the file
The contents of the cat file are all displayed in one fell swoop applicable byte content less view log content ERROR location error if the file is oversized 10m is sent to the window computer Global search via editplus if the file is 100m + (grep-C means 10 lines before and after the search "ERROR") cat install.log | grep-C 10 "ERROR" if there are many results filtered by ERROR (> redirect overwrites the output to the file) > > append) cat install.log | grep-C 10 "ERROR" > the contents of the error.logmore file page by page. Press the spacebar to go back. Press Q to exit the contents of the less file with slightly more bytes. Press the arrow up and down and press Q to exit.
9. Tail, real-time viewing
In practical work, the log is always faced with the problem that the log is too large, so the cutting method is generally used. Reach a certain number, mv xxx.log xxx.log1, and then touch xxx.log. The recommended use of tail-F xxx.log,-F=-f+retry,-f is not powerful enough. As long as the file is removed, even if the new one is exactly the same, it will not monitor [root@hadoop001] # tail-F xxx.log 1234tail: `xxx.log' has become inaccessible: No such file or directorytail: `xxx.log' has appeared; following end of new file5 in real time, but if you want to see a log starting with the bottom 50 lines, it can only be tail-50f xxx.log.
10. Help, command help
Command-- help for example: [root@hadoop001 ~] # ls-- helpUsage: ls [OPTION]. [FILE]... [] means you can omit all the above examples of commonly used commands in Linux. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.