Common Linux commands (version 2) and common linux commands
Compression and decompression commands:
----------.Gz ----------
1. Compression
Gzip [GNU zip]:/bin/gzip
Format: gzip option. The extension name is .gz. It is the most common # common software source code package format in Linux.
Features: 1) only files can be compressed and directories cannot be compressed.
2) do not retain the original file
E.g.gzip newfile # Delete the original newfile
2. Decompress
1) gunzip [GNU zip]:/bin/gunzip
2) gzip-d#decompress .gz
E. g.
Gzip-d newfile.gz
----------.Tar ----------
3. Compression
Tar:/bin/tar
# Package the Directory and package it into a file to generate .tar. if you compress the directory, .gz will be generated.
Format: tar [Option cvf] [compressed file name] [file/directory name before compression]
-C: the package file of pai.tar, required
-V: displays details.
-F: Specifies the compressed file name, which is mandatory.
-Z: compress the package at the same time.
E.g.tar-cvfz dir1.tar.gz dir1 # package dir and compress it into a file
[Note-this one-step packaging and compression is not supported by all UNIX systems!]
At this time: 1) package: tar-cf newdir.tar newdir
2) compression: gzip newdir.tar # or use a connector.
4. decompress the package
Tar [Option]:
-X unpack the .tar File
-V: Show Details
-F: Specifies the file to be decompressed.
-Z Decompression
E.g.tar-zxf newdir4.tar.gz
Step-by-Step gunzip newdir.tar.gz
Tar-xvf newdir.tar
----------.Zip ----------
5. zip:/usr/bin/zip
Windows and linuxare only generic. If the file size is not large, we recommend that you use. Zip.
Format: zip [Option-r] [compressed file name] [compressed file/directory name]
E.g.zip services.zip/etc/services compressed file
Zip-r newdir.zip test compressed directory
Two major defects of gzip compensated by zip: 1) Keep the source file
2) directory can be compressed
6. unzip/usr/bin/unzip
Example: unzip newdir.zip # retain the original file
----------.Bz2 ----------
7. bzip2/usr/bin/bzip2
The compressed version is quite surprising than the upgraded version of gzip. however, it cannot be used with the compressed file name .bz2. Of course, it can also be used with tar.
Format: bzip2 option [-k] [file name] # Add-k to keep the source file, otherwise it will be the same as zip
8. bunzip2
You can use-k to retain source compressed files.
Common linux Commands include
Common linux commands (BASICS)
1. man provides help explanations for familiar or unfamiliar commands
For example: man ls, you can view the ls-related usage.
Note: Press q or ctrl + c to exit. in linux, you can use ctrl + c to terminate the current program.
2. ls view the directory or file owner * and list the files under any directory
Eg: ls/usr/man
Ls-l
A. d indicates directory. If it is a "-", it indicates a file. If it is l, it indicates a connection file (link)
B. Permission for file or directory permission. Read (r), write (w), and run (x) respectively ).
3. Copy files using cp
Eg: cp filename1 filename2 // copy filename1 to filename2
Cp 1.c netseek/2.c // copy 1.c to the netseek directory and name it 2.c.
4. rm delete files and directories
Eg: rm 1.c // Delete the. c file.
5. Remove the directory or change the file name.
Eg: mv filename1 filename2 // rename filename1 to filename2
Mv qib. tgz ../qib. tgz // move to the upper-level directory
6. Change the current directory pwd on cd to view the complete path of the current directory
Eg: pwd // view the current directory path
Cd netseek // enter the netseek directory
Cd // exit the current directory
7. cat, more command
Displays the content of a file. The two commands are different: cat prints the file content all the time, and more is displayed on the split screen.
For example; cat> 1.c // You can paste the code into the. c file and press ctrl + d to save the code.
Cat 1.c or more 1.c // you can view the content in it.
Gcc-o 1 1.c // compile 1.c into the. exe file. We can compile the Code with this command.
8. Modify the chmod command permission usage: chmod one-digit octal number filename.
Eg: chmod u + x filenmame // you only want to run the command for yourself.
// U indicates the file owner. g indicates the group of the file. O indicates others; r table readable; w table writable; x table can run
Chmod g + x filename // the same group of people to execute
9. clear, date command
Clear: clear screen, equivalent to cls in DOS; date: displays the current time.
10. mount a hardware device
Usage: mount [parameter] device load point to be loaded
Eg: mount/dev/cdrom
Cd/mnt/cdrom // enter the cd directory
11. su switches to another person's identity without logging out.
Usage: su-l user name (if the user name defaults, the user name is switched to the root state)
Eg: su-l netseek (switch to the netseek user and the user will be prompted to enter the password)
12. whoami, whereis, which, id
// Whoami: confirm your identity
// Whereis: queries the directory where the command is located and the directory where the help document is located
// Which: query the directory where the command is located (similar to whereis)
... The remaining full text>
Examples of common linux commands
There are a lot of commands, and I will forget what I learned at once. I can only accumulate them slowly. Many of them are generally not used. 1. File Viewing and connection commands
Connect the file together, use the ">" operation to combine several files into a new file, or use ">" to append the file to the end of the saved file.
Syntax:
Cat [parameter] filelist
-N or -- number: numbers the number of all output rows starting from 1
-B or -- number-nonblank: similar to n, but not numbered for empty rows
-S: two blank lines are displayed. replace them with one blank line.
-V: displays unprintable characters.
Filelist: an optional list used to combine files. 2. split-screen display command
Similar to cat, But it displays a page each time, displays the next page by space, exits by pressing the <q> key, and provides help information by pressing the Syntax
More [Options] <file>...
-Num: specifies the number of lines displayed per screen.
-D: a message is displayed below the screen.
-L: by default, more will suspend if it encounters a paper delivery character ^ L. You can use this option to cancel this function.
-F: calculate the actual number of rows.
-P: Not to display every page in a scroll mode, but to display the page first.
-S: two blank lines are displayed. replace them with one blank line.
-U: No underline is displayed.
+/<String>: Search for string in the file and display the content on the page where the string is located.
+/<Num>: displays data starting from row num.
File: the file to be displayed.
3. Display files by page. Similar to more, but can be moved before and after the file.
Syntax:
Less [parameter] File Name
-I: Case sensitivity is ignored during query.
-Num: specifies the number of lines displayed per page.
-P <string>: Search for the string in the file and display it from the first matching position.
-S: when the content of a column exceeds the width of the display screen, the excess part is directly truncated. By default, the excess part is folded back to display the commands for copying, deleting, and moving.
1. Copy an object.
Syntax:
Cp [Option] <source> <dest>
Cp [Option] <source>... <directory>
-R recursive copy directory
-F delete an existing target file and copy it again
-A tries its best to retain the structure and attributes of the source file in the backup.
2. Delete
Rm [Option] <name> ....
This command is used to delete specified files or directories one by one. By default, <name> is the file name. The rm command does not delete the directory. The directory can be deleted only when the-d option is specified.
Syntax:
-F force Delete, including read-only files, without prompting the user
-I prompt the user when deleting each file
-R recursively deletes contents in a directory to move or rename files and directories.
Syntax:
Target file of the mv [parameter] source file
-F forcibly overwrite existing files.
-I prompt the user before overwriting existing files.
-U does not overwrite the target file when the target file is earlier than the original file.
-V outputs relevant information when moving files. Create and delete directory commands
1. Create a directory command
Mkdir [parameter] Directory Name
-P if the parent directory does not exist, create all parent directories. 2. Delete the empty directory.
Syntax:
Rmdir [parameter] Directory List
-P indicates that after a specified directory is deleted, if the parent directory of the directory is empty, the switch working directory and display directory commands will be deleted.
1. Change the current working directory.
Syntax:
Cd directory name
If the directory name is not followed, the root directory of the user is returned. In addition, the user must have the permission to enter the directory. In addition, cd ~ Switch to your home directory. You can switch cd... to the upper directory 2 in front of the ticket to display the working or current directory name.
Pwd [parameter] 3. List contents in the directory.
Syntax:
Ls [parameter] [Directory]
-A shows all files, including hidden files... the remaining full text>