In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Today, I will talk to you about how to manage Linux files. Many people may not know much about it. In order to make you understand better, the editor has summarized the following contents for you. I hope you can get something according to this article.
Create a file system xfs log file system; ext is the terminal name of the virtual operating system that extends the file system to modify VMware: hostnamectl set-hostname hostname touch [path] file name
Create two files at the same time touch [path] file name [path] file name is not created, then modify time to create multiple files at the same time touch [path] file name {1line 2} touch [path] file name {1.. 10}
Create directory mkdir [parameters] [path] directory name-v display creation process-p recursive creation
Mkdir-pv / mnt/ {a / {cMagne d / {e / {TMagne S}, f _ pr}}, b / {Ymeme Z / {Q _ mai _ p _ j}
Yum-y install tree download tree tree / mnt display tree can display the created multi-level directory yum-y install is a download tool for Linux shell. 3. Copy files
Copy file: cp [parameter] [path] source file [path] destination
Copy directory: cp-r source directory destination
Parameter:-f force copy-v shows copy process-r recursion! $gets the last parameter of the previous command
(1): cp a.txt / opt (2): cp / mnt/a.txt / opt (3): cp a.txt b.txt (4): cp a.txt / opt/o.txt copy to / opt/ and rename o.txt cat view. Under the current directory
Cp-rv / etc/sysconfig/network-scripts/ifcfg-eth0 / etc/passwd / etc/hostname / home/dir2 / / copy multiple files to the same directory cp-rv / etc/sysconfig/network-scripts/ifcfg-eth0 / etc/passwd / etc/hostname / etc/hosts. / / copy multiple files to the current directory
Copy it to the original directory and rename it [root [@ xingdian] (https://my.oschina.net/u/4234815) ~] # cp-rv / etc/sysconfig/network-scripts/ {ifcfg-eth0,ifcfg-eth0.bak} [root [@ xingdian] (https://my.oschina.net/u/4234815) ~] # cp-rv / etc/sysconfig/network-scripts/ifcfg-eth0 {) -org} [root [@ xingdian] (https://my.oschina.net/u/4234815) ~] # cp-rv / etc/sysconfig/network-scripts/ {ifcfg-eth0,yang-eth0} copy to the original directory and rename it IV. Move the mv source file / source directory destination
Mv file4 file5 renamed file4 to file5, and the move in the current location is to rename mv file2 / home/dir3/file20 to move file2 to / home/dir3 and rename it to file20
5. Delete the rm-rf file name rm-rf / * cannot be executed-the legendary "delete and run" rm-rf. / * parameters can be executed as long as it is not the root directory:-r recursion-f force-v shows the detailed process
(1): under opt, delete all the contents of opt] rm-rf. / * all under the current directory (2): delete all: rm-rf / opt/* under opt (3): delete all rm-rf / opt/a* starting with a
Script deletion
/ home/dir1 [root@xingdian ~] # rm-rf / home/dir10/* / / does not include hidden files example 3: rm-rf / home/* [root@xingdian ~] # rm-rf file* m [root@xingdian ~] # rm-rf * .pdf
6. View the file content text file (cat tac less more head tail tailf grep...) cat [parameter] file name from the beginning to view the tac [parameter] file name from the end to view the less paging display Manually exit Qmore paging automatic space bar flip tac/less/more file name head-numeric file name defaults to the first ten lines tail-numeric filename defaults to the last ten lines
[root@xingdian-server-10 ~] # cat passwd | head-5 specifies to view the first five lines, "|" is the pipeline [root@xingdian-server-10 ~] # head-5 passwd to view the first five lines
Tailf real-time display tailf = tail-ftail-Fmurn display line number
[root@xingdian ~] # tail-f / var/log/secure / /-f dynamically view the tail of the file [root@xingdian ~] # tail-F / var/log/secure / /-F dynamically view the end of the file Note: vim, gedit edits the file, the index number will change
Note: tail-f is equivalent to-- follow=descriptor, which is tracked according to the file descriptor. When the file is renamed or deleted, the trace stops tail-F equals-- follow=name-- retry, tracks according to the file name, and keeps retrying, that is, if the file is deleted or renamed, if the same file name is created again, tracking will continue.
Grep filtering
Grep filters the file content by grep 'root' / etc/passwd # grep' ^ root' / etc/passwd root beginning # grep 'bash$' / etc/passwd bash ending # grep' failure' / var/log/secure
Systemctl server management
Seven, vim
File editor gedit file editor vi, vim interactive vi vim (vim is an upgraded version of vi) non-interactive sed vim / vi can only edit files (force exit immediately when a directory is encountered) several modes of vim: insert mode, trailing mode, command mode, visualization mode
Insert mode
I I An o an O (press any of these 6 keys to enter insert mode)
Keyboard shortcuts summary esc exit: wq save exit do not save: Q direct exit: Q! Forced exit does not quit: W: W! Force save gg first line G tail line (number) + yy copy a whole line p paste d delete u undo: set nu display line number number + G jump to a line (number) dd delete one (number) whole line dG delete line to the last all dgg delete line to line to line header command mode:
In command mode: / root find: s / replace content / replace with /:% s / replace content / replace with / the first match of all lines: numeric s / replace content / replace all contents of the selected line / g
: range s/old/new/ option: 1yang 5 s/root/yang/ from root of 1mer 5 lines to yang: 5jue $s/root/yang/ $represents the last line: 1Jing $s/root/yang/g =:% s/root/yang/g% indicates full text g indicates global:% s#/dev/sda#/var/ccc#g: 8 s/root/yang/ from the current line to line 8: 4 s/root/yang/ 9 s / ^ # / 4-9 replace the beginning # with blank: 5 Magi 10 s Universe. Add the # character (. * whole line & referencing what you are looking for) before the "beat" / 5-10.
Visual mode ctrl+v enters visual block mode press V to enter visual line
Visual block mode:
Block insertion (adding characters before the specified block): select block, I insert characters before the block, ESC block replacement twice: select block, r enter replacement character block delete: select block, d block copy: select block, y search: [root@k8s-node-2 mnt] # vim / etc/passwd
Enter / follow what you are looking for in command mode, and the content you find will be followed by a background color (n can switch with each other)
Permanent environment: modifying the vim environment configuration file / etc/vimrc affects all system users ~ / .vimrc affects a user
After reading the above, do you have any further understanding of how to manage Linux files? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.
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.