In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains the "small set of commonly used commands in Linux". The content of the explanation in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn the "small set of common commands in Linux".
The following subsets of Linux commands are divided into: file system operation commands, system management commands, Linux user-related commands, Linux system management commands, basic Vi commands, Linux file copy, delete and move commands, and Linux directory creation and deletion commands.
File system operation commands:
1. Cat: you can display the contents of a file (often used with more), or merge multiple files into a single file.
2. Chgrp: used to change the user group to which the file or directory belongs. The parameters of the command are separated by spaces to change the list of files belonging to the group. The file name supports wildcards. If the user is not the owner of the file, you cannot change the group to which the file belongs.
3. Chmod: used to change access to a file or directory, this command has two uses: one is to use the graphical method, and the other is the digital setting method.
4. Chown: used to make a specified user or group a specific owner. The user can be set to the user name or user ID, and the group can be the group name or group ID. A specific file is a list of files that can change permissions separated by spaces, and the file name supports wildcards.
5. Clear: used to clear the terminal screen.
6. Cmp: used to compare the size of two files.
7. Cp: (copy) you can copy files or directories to other directories, just like the copy command under Dos, which is very powerful. When using the cp command, you only need to specify the source file name or destination directory.
8. Cut: used to remove parts of the file.
9. Diff: used to find out the differences between two files.
10. Du: used to display the size of the remaining space on the disk.
11. File: used to display the type of file.
12. Find: used to search for files in the directory and perform specified operations.
13. Head: view only the first few lines of the file without having to browse the entire file.
14. Ln: you can create links between files, actually giving a file an alias to access it.
15. Less: similar to more, you can view more than one screen of file contents, except that less can not only press the space bar to display the file down, but also use the arrow keys to scroll through the file. To end browsing, just press Q after the less prompt ":".
16. Locate: can be used to find files and is faster than the find command.
17. Ls (list): used to display a list of files and subdirectories in the current directory.
18. Mkdir (make directory): create a subdirectory.
19. More: used to display files with more than one screen. In order to prevent the contents of the files from disappearing instantly, you can use the more command to pause when the files are displayed for a full screen, and continue to display the contents of the next screen when any key is pressed.
20. Rmkdir (remove directory): used to delete "empty" subdirectories or useless directory files.
21. Mv (move): you can move files and directories to another location, or change the names of files and directories.
twenty-two。 Pico: you can specify how the text is edited.
23. Pwd (print working directory): displays the directory where the user is currently located.
24. Rm: used to delete obsolete or useless files in the system, you can delete files in the directory or the directory itself, for linked files, the original files remain unchanged.
25. Sort: automatically classifies text files.
twenty-six。 Stat: used to display the status of a file or file system.
twenty-seven。 Strings: displays the string to be printed in the file.
twenty-eight。 Tail: the end of the output file.
twenty-nine。 Touch: change the timestamp of the file.
thirty。 Umask: used to start bash shell.
thirty-one。 Uniq: removes duplicate lines of text from a classified file.
thirty-two。 Vi: launch the vi text editor.
thirty-three。 Wc: displays the number of byte and word combination text lines in the file.
thirty-four。 Whereis: find the location of files such as original programs, binary programs, or user manuals in a specific directory.
thirty-five。 Man: you can use this command if you want to know more about a command.
thirty-six。 Dd: copy a file.
thirty-seven。 Df: view the disk space usage of a file system.
thirty-eight。 Edquoat: sets disk space limits for users and user groups, that is, quotas in the Windows system.
thirty-nine。 Fdformat: format the floppy disk.
forty。 Fdisk: execute the disk partition under Linux.
forty-one。 Mkfs: set up a Linux file system.
forty-two。 Mkswap: create a Linux swap partition.
forty-three。 Mount: Mount a file system.
forty-four。 Quota: limit and display the disk space available to the user.
forty-five。 Swapon,swapoff: enables or cancels the exchange page for devices and files.
forty-six。 Quotaon,quotaoff: enables or removes the quota restriction.
forty-seven。 Umount: unequip the file system.
System management commands:
1. Finger: query user information and view the default user environment.
2. Ftp: the user interface of the standard file transfer protocol, which is the simplest and most effective way to transfer files on the network.
3. Host: used for DNS queries.
4. Hostname: the hostname used to display or set the system.
5. Ifconfig: used to configure the Nic interface. (you can use down or up parameters to disable or enable a network card interface)
6. Mail: send and receive mail.
7. Netstat: displays network connections, routing tables, and network interface information, so that users can know which network connections are currently running.
8. Ping: this command is used to test whether this computer is connected to other computers on the network.
9. Rlogin: remote login command, which is similar to the telnet command and allows the user to start an interactive session of the remote system.
10. The rcp:rcp (remote file copy) command is a remote file copy command, which is used to copy files between computers in two formats, one for copying moving files, and the other for copying files or directories to other file directories.
11. Route: this command is used to display or set the IP routing table.
12. Tcpdump: this command is used to test network traffic.
13. Talk: this command can be used for timely conversations of event network users, but the information of both parties' systems must be added to their respective / etc/hosts files to identify each other.
14. Telnet: this command is used to log in to a remote computer over the network as if it were a local computer.
15. The wall:wall (write all) command can be used to send messages to users who log in to the machine. When sending a message, you can directly enter the message to be sent, or you can send the file as a message.
16. Wget: this command is used to download files from Internet in Linux environment, supports http and ftp protocols, supports proxy server and breakpoint continuous transfer function, and can recurse directories on remote hosts, find files that meet the requirements and download them to the local hard disk. The Wget command can be run in the background, intercepting and ignoring hantfup signals, so users can continue to run after they log out and log in.
17. &, the bg:&,bg command is executed in the background. Sometimes the program executed by the user may take a lot of time. If the program is executed in the foreground, it may not be able to continue other operations.
18. The fg:fg command is the command executed in the foreground. If the user has a program running in the background, you can move the program from the background to the foreground to execute through the fg command.
19. Jobs: this command is used to display a list of tasks being performed in the background. Bg,fg,jobs commands belong to bash commands
20. Kill: this command is used to terminate a program, for example: # [root@rathat9 root] kill 3793
21. Ps: this command is used to display the status of the program.
twenty-two。 Top: this command is used to display the current CPU process.
23. At batch atp atrm: these commands are used to sort, check, or delete tasks running in the background.
Linux user-related commands:
1. Passwd command: change the user password.
Format: passwd [user name]
2. Su command: you can let an ordinary user have the privileges of a super user or another user, or you can let a super advocate do something as a normal user.
Format: su [options] [?] [user account]
Note: if there is no specified user account, the system default value is superuser root. The meanings of the options in this command are:
-c: it ends after a command is executed.
The purpose of adding this minus sign is to make the environment variable the same as the user you want to convert.
-m: leave the environment variable unchanged.
Linux system management commands:
1. Wall command: sends messages to all users who log in.
2. Write command: sends information to a user in the system.
Format: write user account [terminal name]
3. Mesg command: sets whether other users are allowed to send messages to themselves with the write command.
If the command is allowed to enter: mesg y
If you are not allowed to enter commands: mesg n
4. The sync command is used when shutting down the Linux system. Sync forces data in memory to be written back to the hard disk to avoid data loss.
5. Shutdown command: you can safely shut down or restart Linux. It prompts all login users on the system with a warning before the system shuts down.
Format: shutdown [option] [time] [warning message]
The meaning of the options in the command:
K: it doesn't really turn off, but just sends a warning message to all users.
-r: restart immediately after shutdown.
-h: do not restart after shutdown.
-f quickly shut down and skip fsck when restarting.
-n: fast shutdown, without init program.
-c: cancel a shutdown that is already running.
6.The free command: view the current system memory usage, which shows the remaining and used physical memory and swap memory in the system, as well as shared memory and buffers used by the core.
Format: free [- b |-k |-m]
The meaning of each option in the command:
-b: displayed in bytes.
-k: displayed in K bytes.
-m: displayed in megabytes.
7. Uptime command: shows how long the system has been running, which in turn shows the following information: the current time, how long the system has been running, how many login users are currently, and the average load of the system in the past 1 minute, 5 minutes, and 15 minutes.
8. Df command: check the disk space footprint of the file system.
Format: df [options]
Description: the df command displays the usage of I nodes and disk blocks by all file systems.
The meaning of each option in the command:
-a: displays the disk usage of all file systems, including 0-block (block) file systems.
-k: displayed in k bytes.
-I: displays I node information instead of disk blocks.
-t: displays the disk space usage of each specified type of file system.
-x: lists disk space usage that is not a specified type of file system.
-T: displays the file system type.
9. Du command: displays disk space usage. Count the size of the disk occupied by the directory (or file).
Format: du [options] [Names …]
Description: this command enters each subdirectory of the specified directory step by step and shows how the directory occupies file system data blocks (1024 bytes). If no Names is given, the current directory is counted.
The meaning of each option in the command:
-s: only the total number of blocks occupied is given for each Names parameter.
-a: recursively displays the number of blocks occupied by each file in the specified directory and in the descendant directory. If neither-s nor-an is specified, the number of disk blocks occupied by each directory and its subdirectories in Names is displayed.
-b: lists disk space usage in bytes (the system defaults to k bytes).
-k: lists disk space usage in 1024 bytes.
Add a total (the system default).
-l: calculate all file sizes, and for hard-linked files, calculate multiple times.
-x: directories skipped on different file systems are not counted.
10. Dd command: copies the specified input file to the specified output file, and the format can be converted during the copy process.
Format: dd [options]
The meaning of each option in the command:
If = enter the file (or device name).
Of = output file (or device name).
Ibs = bytes reads bytes bytes at a time, and the number of bytes read into the buffer.
Skip = blocks skips the ibs*blocks block at the beginning of the read-in buffer.
Obs = bytes writes bytes bytes at a time, and the number of bytes written to the buffer.
Bs = bytes sets the number of bytes in the read / write buffer simultaneously (equal to setting ibs and obs).
Cbs = byte converts bytes bytes at once.
Count = blocks copies only the input block blocks.
Conv = ASC Ⅱ converts EBCDIC codes into ASC Ⅱ.
Conv = ebcdic converts ASC Ⅱ codes to EBCDIC codes.
Conv = ibm ibm converts ASC Ⅱ codes to alternate EBCDIC codes.
Conv = block converts variable bits to fixed characters.
Conv = ublock converts a fixed position into a variable position.
Conv = ucase converts letters from lowercase to uppercase.
Conv = lcase converts letters from uppercase to lowercase.
Conv = notrunc does not truncate the output file.
Conv = swab swaps each pair of input bytes.
Conv = noerror error does not stop processing.
Conv = sync adjusts the size of each input record to the size of ibs (filled with NUL).
11. Fdformat command: low-level format floppy disk.
Format: format [- n] device
Description:-n floppy disk will not be checked after formatting.
12. Echo command: displays a piece of text on the monitor, which usually serves as a prompt.
Format: echo [- n] string
13. Cal command: displays the calendar of a certain year and month.
Format: cal [option] [month [year]]
The meaning of each option in the command:
-j: shows that each day of a given month is the day of the year (from January 1).
-y: displays the calendar for the whole year.
14. Date command: displays and sets the system date and time.
Format: date [option] displays the time format (begins with +, followed by format)
Date [options] set time format
The meaning of each option in the command:
15. Clear command: clear the information on the screen.
Basic commands for Vi:
1. Move the cursor:
Ctrl + b: scroll up a screen
Ctrl + f: scroll down one screen
Ctrl + d: scroll down half the screen
Ctrl + u: scroll up half the screen
G: move to file *
W: move to the beginning of the next word
B: skip to the beginning of the previous word
two。 Delete
X: delete one character after the current cursor
# x: delete # characters after the current cursor. For example, 5x means to delete five characters.
Dd: deletes the line of the current cursor
# dd: delete the # line after the current cursor. For example, 5dd represents five lines from the delete word cursor.
For example,: 1 ~ # 12d means to delete words from line 1 to line 12.
X: delete the left character of the current cursor
D: delete to the end of the line
3. Change
Cw: change the word at the cursor to the end of the word
Cchangw: for example, c3w means to change 3 words
Cc: modifying Lin
C: replace to the end of the line
4. Replace
R: replace the character at the cursor
R: replace the character until you press ESC
5. Copy
Yw: copy the word to suffix buffer only at the cursor
P: post the data in the buffer zone.
Yy: copy the line where the cursor is located to the buffer
# yy: for example: 5yy, copy the cursor 5 lines below to the buffer
Copy, delete and move commands for Linux files
1.cp command: the function of this command is to copy the given file or directory to another file or directory. It is as powerful as the COPY command under MSDOS.
Syntax: cp [option] source file or directory, target file or directory
Indicates that the command copies the specified source file to the target file or multiple source files to the destination directory.
The options for this command mean the following:
-a: this option is usually used in the copy directory. It retains links, file attributes, and recursively copies directories, which function as a combination of dpr options.
-d: copy is to keep the link
-f: delete the existing target file without prompting.
-I: contrary to the f option, you will be prompted for support confirmation before overwriting the target file. When answering y, the target file will be overwritten and is an interactive copy.
-p: at this time, cp will not only copy the contents of the source file, but also copy its modification time and rhetorical permission to the new file.
-r; if the source file given is a directory file, cp will recursively copy all subdirectories and files in that directory. At this point, the target file must be a directory name.
-L: don't make a copy, just link the file.
It should be noted that in order to prevent users from inadvertently destroying another file with the cp command, such as the target file name specified by the user already exists, after copying the file with the cp command, the file wine will be overwritten by the new source file, therefore, it is recommended that users use the I option when using the cp command to copy the file.
2.mv command: you can use the mv command to rename a file or directory or move a file from one directory to another. This command is like a combination of ren and move under MS-DOS.
Syntax: mv [option] source file or directory destination file or directory.
Description: depending on the type of the second parameter in the mv command (whether it is the target file or the target directory), the mv command renames the file or moves it to a new directory. When the second parameter type is a file, the mv command finishes renaming the file. At this point, there can be only one source file (or source directory name), and he renames the given source file or directory to the top target file name. When the second parameter is an existing directory name, there can be many source files or directory participation parameters, and the mv command moves all the source files specified by each parameter to the target directory. When moving a file across a file system, mv copies and then deletes the original file, and the link to the file is lost.
The options in the command mean:
-I: operate interactively. If the mv operation will result in an overwrite of an existing target file, the system asks whether to rewrite and asks the user to answer y or n, which avoids mistakenly overwriting the file.
-f: interoperability is prohibited. There are no instructions for the mv operation to overwrite an existing target file, and when this option is specified, the I option will no longer work.
If the given target file (not a directory) already exists, the contents of the file will be overwritten by the new backup file. To prevent the user from destroying another file with the mv command, use the I option when using the mv command to move the file.
3.rm command: users can use the rm command to delete unwanted files. The function of this command is to delete one or more files or directories in a directory. He can also delete a directory and all files and subdirectories under it. For linked files, only the link is broken and the source file remains unchanged.
The general form of the Rm command is:
Rm [options] file...
If you do not use the-r option, rm does not delete the directory.
The options for this command mean the following:
-f: ignore files that do not exist and never give prompts.
-r: instructs rm to delete all directories and subdirectories listed in the parameter recursively.
-I: perform interactive deletion.
Be careful with the rm command. Because once the file is deleted, it cannot be restored. To prevent this from happening, you can use the I option to confirm the files to be deleted one by one. If the user enters y, the file will be deleted. If you enter anything else, the file will not be deleted.
Commands for creating and deleting Linux directories:
1. Mkdir command
Function: create a directory (similar to the md command under MS-DOS).
Syntax: mkdir [options] dir-name
Description: this command creates a directory named by dir-name. The user who created the directory is required to have write permissions in the current directory (in the parent directory of dir-name), and dirname cannot be an existing directory or file name in the current directory.
The meaning of the option in the command is:
-m: set access permissions for the newly created directory. You can also set it with the chmod command.
-p: can be a path name. At this time, if some directories in the path do not already exist, add this option, the system will automatically establish those directories that do not already exist, that is, multiple directories can be established at a time.
2. Rmdir command
Function: delete empty directory.
Syntax: rmdir [option] dir-name. /
Description: dir-name represents the directory name. This command removes one or more subdirectory entries from a directory. It is important to note that a directory must be empty before it can be deleted. The Rm-r dir command can replace rndir, but it is dangerous. When deleting a directory, you must also have write permission to the parent directory.
The meaning of the option in the command is:
-p the directory dirname is deleted recursively, and is also deleted when the parent directory is empty after the subdirectory is deleted. If the entire path is deleted or part of the path is retained for some reason, the system displays the corresponding information on the standard output.
3. Cd command
Function: change the working directory.
Syntax: cd [directory]
Description: this command changes the current directory to the directory specified by directory. If no directory is specified, go back to the user's home directory. In order to change to the specified directory, the user must have execute and read permissions to the specified directory.
This command can use wildcards (such as "*, _").
4. Pwd command
In the Linux hierarchy, users can use the mkdir command to create a new directory in any directory authorized, or they can use the cd command to convert from one directory to another. However, there is no prompt to tell the user which directory they are currently in. To know the current directory, you can use the pwd command, which displays the entire pathname.
Syntax: pwd
Description: this command shows the absolute path of the current working directory.
5. Ls command
Ls is the abbreviation of list and its function is to list the contents of the directory. This is one of the most commonly used commands to support, because users need to view the contents of a directory from time to time, which is similar to the dir command under DOS
Syntax: ls [option] [directory or file]
For each directory, the command lists all subdirectories and files in it. For each file, ls outputs its file name and other information required. By default, output entries are sorted alphabetically. However, when the directory name or file name is not given, the information about the current directory is displayed.
The meaning of each option in the command:
-a: displays all subdirectories and files under the specified directory, including hidden files.
-A: displays all subdirectories and files under the specified directory, including hidden files. But do not list "." And ".."
-b: use handle to prohibit non-displayable characters in file names
After reading the above small set of commands in one breath, have you found the commands you want to use? These commands are basic commands and lay a good foundation for skilled use of the Linux system.
Thank you for your reading, these are the contents of the "small set of commonly used commands in Linux". After the study of this article, I believe you have a deeper understanding of the problem of the small set of commonly used commands in Linux, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.