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/03 Report--
The main purpose of this article is to share common commands for operating directories and files in Linux. The article also introduces the directory structure of linux and the use of vi text editor. I hope you can get something through this article.
I. Linux directory structure
The Linux directory structure adopts a tree directory structure, including root directories and subdirectories.
1. Root directory
The location starting point of all partitions, directories, files, etc., is represented by a separate "/" in the entire tree directory structure.
2. Subdirectories
Common subdirectories such as / root, / bin, / boot, / dev, / etc, / home, / var, / usr, / sbin.
3. The function of subdirectories
2. Linux View File content basic Command 1, cat-- View File content
Cat is used to display the entire contents of a file at one time. The basic syntax format is as follows:
Application examples:
[root@centos01 ~] # cat / etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 [root@centos01 ~] # cat / etc/sysconfig/network# Created by anaconda [root@centos01 ~] # cat / etc/sysconfig/network / etc/hosts# Created by anaconda127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain62, more-- View File content
More is used for paging the contents of the file in full-screen mode. The basic syntax format is as follows:
Interactive operation method:
Press Enter to scroll down line by line
Press the spacebar to flip down one screen
Press Q key to exit
Application examples:
[root@centos01 ~] # more / etc/httpd/conf/httpd.conf # # This is the main Apache HTTP server configuration file. It contains the# configuration directives that give the server its instructions.# See for detailed information.# In particular, see #-More-- (2%) 3, less-- to view file contents
The less command has the same effect as the more command, but has more extended functions. The basic syntax format is as follows:
Interactive operation method:
Page Up key: turn the page up
Page Down key: turn the page down
"/" key: find key content
"n": find the next key content
"N": find the last key content
Other functions are basically similar to the more command
4. Head and tail-- view the contents of the file
The basic syntax format of the head and tail commands is as follows:
Head: view part of the beginning of the file (default is 10 lines)
Tail: view part of the end of the file (default is 10 lines)
Application examples:
[root@centos01] # head-2 / var/log/messages Jan 10 20:20:01 centos01 systemd: Started Session 9 of user root.Jan 10 20:20:01 centos01 systemd: Starting Session 9 of user root. [root@centos01 ~] # [root@centos01 ~] # tail-3 / var/log/messages Jan 10 23:10:01 centos01 systemd: Starting Session 30 of user root.Jan 10 23:20:01 centos01 systemd: Started Session 31 of user root.Jan 10 23:20:01 centos01 systemd: Starting Session 31 of user root. [root@centos01] # [root@centos01] # tail-f / var/log/messages Jan 10 23:01:01 centos01 systemd: Starting Session 29 of user root.Jan 10 23:03:19 centos01 yum [11583]: Installed: httpd-tools-2.4.6-67.el7.centos.x86_64Jan 10 23:03:19 centos01 yum [11583]: Installed: mailcap-2.1.41-2.el7.noarchJan 10 23:03:20 centos01 systemd: Reloading. Jan 10 23:03:20 centos01 yum [11583]: Installed: httpd-2.4.6-67.el7.centos.x86_64Jan 10 23:03:20 centos01 journal: g_dbus_interface_skeleton_unexport: assertion 'interface_- > priv- > connections! = NULL' failedJan 10 23:10:01 centos01 systemd: Started Session 30 of user root.Jan 10 23:10:01 centos01 systemd: Starting Session 30 of user root.Jan 10 23:20:01 centos01 systemd: Started Session 31 of user root.Jan 10 23:20: 01 centos01 systemd: Starting Session 31 of user root.5 、 Contents of wc-- statistics file
Wc is used to count the number of words, (Word Count), lines, bytes, and so on. The basic syntax format is as follows:
The common options for wc are as follows:
-l: count the number of rows
-w: count the number of words
-c: count the number of bytes
Application examples:
[root@centos01 ~] # wc-l / etc/passwd 41 / etc/passwd [root@centos01 ~] # wc-w / etc/passwd 81 / etc/passwd [root@centos01 ~] # wc-c / etc/passwd 2104 / etc/passwd [root@centos01 ~] # wc / etc/passwd 43 85 2223 / etc/passwd [root@centos01 ~] # find / etc-name "* .conf" | wc-l 437 6, grep-- retrieves and filters file contents
The grep command is used to find and display the line containing the specified string in the file. The basic syntax format is as follows:
Common options for the grep command are as follows:
-I: ignore case when looking up
-v: reverse lookup and output lines that do not match the condition
Grep lookup criteria settings:
The string to be found is enclosed in double quotation marks
"^.": it means to find. The starting string
". $": means to find. The string at the end
"^ $": means to find a blank line
Application examples:
[root@centos01 ~] # grep-I "SSHD" / etc/passwd sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin [root@centos01 ~] # grep "ftp" / etc/passwd ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin [root@centos01 ~] # grep-v "^ #" / etc/yum.conf | grep-v "^ $" [main] cachedir=/var/cache/yum/$basearch/$releaseverkeepcache=0debuglevel=2logfile=/var/log/yum.logexactarch=1obsoletes=1gpgcheck=1plugins=1installonly_limit=5bugtracker_url= http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yumdistroverpkg=centos-release III. Compress and decompress Files 1, gzip, gunzip-- Compression and decompression
Application examples:
[root@centos01] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg [root@centos01 ~] # gzip-9 initial-setup-ks.cfg [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg.gz [root@centos01 ~] # gzip-d initial-setup-ks.cfg.gz [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4 -x8634-1708.iso initial-setup-ks.cfg [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg [root@centos01 ~] # gzip initial-setup-ks.cfg [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg.gz [root@centos01 ~] # gunzip initial-setup-ks.cfg.gz [root@centos01 ~] # Lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg2, Bzip2, bunzip2-- compression and decompression
Application examples:
[root@centos01] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg [root@centos01] # bzip2-9 initial-setup-ks.cfg [root@centos01] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg.bz2 [root@centos01] # bzip2-d initial-setup-ks.cfg.bz2 [root@centos01] # lsanaconda-ks.cfg CentOS-7. 4-x86_64-1708.iso initial-setup-ks.cfg [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg [root@centos01 ~] # bzip2 initial-setup-ks.cfg [root@centos01] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg.bz2 [root@centos01 ~] # bunzip2 initial-setup-ks.cfg.bz2 [root@centos01 ~] # lsanaconda-ks.cfg CentOS-7.4-x86_64-1708.iso initial-setup-ks.cfg3, Tar-- Archive Command
The tar command makes the archive and releases the archive. The basic syntax format is as follows:
Common options for the tar command are as follows:
-c: create a package file in .tar format
-x: unlock the package file in .tar format
-v: output details
-f: indicates the use of archive files
-p: retain the permissions of the original files and directories when packing
-t: list to view the files in the package
-C: specify the target folder to release when unpacking
-z: call the gzip program to compress or decompress
-j: call the bzip2 program to compress or decompress
Application examples:
[root@centos01 ~] # tar zcvf yun.gz yun/ yun/ [root@centos01 ~] # ls1.txt anaconda-ks.cfg initial-setup-ks.cfg www yun yun.gz [root@centos01 ~] # tar zxvf yun.gz-C / usr/src/ yun/ [root@centos01 ~] # cd / usr/src/ [root@centos01 src] # lsdebug kernels yun [root@centos01 ~] # tar jcvf yun.bz2. / yun [root@centos01 ~] # tar Jxvf yun.bz2-C / usr/src/. / yun/ [root@centos01 ~] # cd / usr/src/ [root@centos01 src] # lsdebug kernels yun4, Dd command compression and backup
Options and parameters:
If:input file (original file) can also be a device
Of:output file (backup file) can also be a device
Bs: the size of a planned block (block). If not specified, it defaults to 512Bytes (bytes).
Count: what do you mean by how many dollars?
Application examples:
[root@centos01 ~] # dd if=/dev/zero of=/usr/src/1.iso bs=30M count=10 recorded 10'0 read in, 10'0 write out 314572800 bytes (315 MB) copied, 0.212995 seconds, 1.5 GB/ seconds [root@centos01 ~] # cd / usr/src/ [root@centos01 src] # ls1.iso debug kernels 4, vi text editor 1, the role of text editor
Create or modify text files to maintain various configuration files in the Linux system.
2. The most commonly used text editor in Linux
Vi: the default text editor in Unix-like systems
The enhanced version of the vim:vi editor has traditionally become the working mode of vi;3 and vi editors.
Command mode, input mode, last line mode. The switching between different modes is as follows:
4. Common operations in command mode 1) cursor movement
2) copy, paste, delete
3) find the content of the file
4) undo edits and save exit
5. Basic operation of the last line mode 1) Save the file and exit the vi editor
2) Open a new file or read the contents of other files
3) File content replacement
After reading the above, do you have any further understanding of the common commands of linux? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel. Thank you for reading.
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.