In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "the common file operation commands of Linux". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn the "Linux common file operation commands" it!
1, user handoff
Su (switch user)
2, display the list of files in the current directory
Ls (list)
Ls-l
Ls-a (all)
Ll
Ll-a
In Linux, hide the file to "." The beginning
3. Various operations of the directory
Switch directories: cd (change directory)
Show current directory: pwd (print working directory)
Create a directory: mkdir (make directoriy)
-p if the parent directory does not exist, the parent directory (parents)
Cp copies a file or directory (copy)
-r Recursive processing to copy files in the specified directory with subdirectories (recursive)
Mv move file or directory, file or directory rename (move)
Rmdir deletes an empty directory (remove directoriy)
Rm Delete Files (remove)
-r delete all files in this directory at the same time (recursive)
-f Force deletion of a file or directory (force)
When the average user deletes, there is no prompt
But when the Super Admin deletes, it will prompt
Supplementary points: cd ~ can quickly get to the home directory
4. Edit the contents of the file-VI,VIM (key)
Workflow flow chart:
Insert command resolution:
A: add text after the current character
A: add text at the end of the line
I: insert text before the current character
I: insert text at the beginning of the line
O: insert a blank line after the current line
O: insert a blank line before the current line
Shortcut commands:
Positioning command
: set number displays the line number
: set nonumber cancels line number
N to the nth line of the text
Gg to the first line of the text
G to the last line of the text
Delete command
X: delete the single character where the cursor is located
Dd: delete the line
Revoke an order
U undo, cancel the previous operation
Ctrl+r redo, before returning to undo
Copy command
Yy+p
5. Review and statistics of the contents of the documents
Touch creates an empty file
Display the contents of the file:
Cat displays the contents of the text file
More pagination displays the contents of the text file
Less
Head and tail view the beginning or end of the text
Head-n 3 java.txt view the first three lines of the java.txt file
Wc counts the number of lines, words, and characters of text (word count)
-m statistics of text characters and numbers
-w count the number of words in the text
-l count the number of lines of text
6, file merging and redirection
Output the contents of the merged file together, cat 1.txt 2.txt
Merge files: cat 1.txt 2.txt > 3.txt
As a standard input
Cat > 1.txt
Cat > > 1.txt
This is a symbol that redirects the output
Case: quickly empty the contents of a file
Use redirect method
> 1.txt
7, file search
Find looks for the specified file in the file system
Find / usr/local/-name word.txt
8, compression, decompression and packaging of files
Command overview
Gzip: compressed (unzipped) files with the suffix gz
Bzip2: compressed (unzipped) files with the suffix bz2
Tar: package a file or directory
Detailed explanation of command
Gzip command details: gzip [option] the file name to be compressed (unzipped)
-d unzip the compressed file (decompress)
-l for compressed files, display the size of compressed files, file size before compression, compression ratio, etc.
-num adjusts the compression speed with the specified number num, and-1 or-- fast indicates the fastest compression method (but the compression ratio is low)
-9 or-- best represents the slowest compression method (high compression ratio). The system default is 6
Bzip2 command details: bzip2 [options] file name
-d decompression
-z compression
-num ditto
Tar command details: tar [options] Packaging File name to be packaged File 1 to be packaged File 2
-c create a packaged file create
-x unlock a packaged file extract
-z compress files with gzip
-j compress files with bzip2
-v the process of compression displays the file
-f use the document name, and receive the document name immediately after f
Case study:
Realize the packaging and unpacking of files
Realize the compression and decompression of files
Gzip 1.txt compressed file
Gzip-d 1.txt.zip extract the file
Tar-cf 33.tar 1.txt 2.txt / / package file
Tar-xf 33.tar / / unpack the file
Gzip 33.tar / / compress the package file tar.gz
Tar-zcf 33.tar.gz 1.txt 2.txt / / package and compress 1.txt and 2.txt into 33.tar.gz
Tar-zxf 33.tar.gz / / decompress 33.tar.gz
9, pipe command
Command format:
Command1 | command2
For example:
Ls-l / usr/bin | less
Ls-l / usr/bin | grep less
The standard output of one command can be piped to the standard input of another command:
Grep is a powerful program for finding matching text in files.
At this point, I believe that everyone on the "Linux commonly used file operation commands" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.