In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail what Linux commands must have. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Common shortcut keys:
① ctrl + c: stop the process
② ctrl+l: clear the screen
③ ctrl + Q: exit
④ is good at using the tab key.
⑤ arrow keys: find commands that have been executed
Common command: "[option]" represents optional or non-optional when executing the command
Pwd: displays the absolute path of the current working directory
Ls: lists the contents of the directory
Syntax: ls [option] [directory or file]
Options:
-a: all files, along with hidden files (beginning with. Listed together (commonly used)
-l: long data string list, including file attributes, permissions and other data; (commonly used)
Scene:
Mkdir: create a new directory
Syntax: mkdir [option] the directory to be created
Option:-p: create a multi-tier directory
Scene:
Rmdir: delete an empty directory
Touch: creating an empty file
Syntax: touch file name
Scene: touch test.java
Cp: copy a file or directory
Syntax:
(1) cp source dest (function description: copy source file to dest)
(2) cp-r sourceFolder targetFolder (function description: recursively copy the entire folder)
Rm: remove files or directories
Syntax:
(1) rmdir deleteEmptyFolder (function description: delete empty directory)
(2) rm-rf deleteFile (function description: recursively delete everything in the directory)
Mv: move files and directories or rename
Syntax:
(1) mv oldFileName newFileName (function description: rename)
(2) mv / temp/movefile / targetFolder (function description: move files)
Cat: viewing file contents
Syntax: cat [option] file name
Options:
-A: the equivalent of-vET's integration option, which lists some special characters instead of white space
-b: list the line number, display the line number only for non-blank lines, and the blank lines are not marked with line numbers!
-E: displays the line break byte $at the end
-n: list the line number, and there will be a line number along with the blank line, which is different from the option of-b
-T: display the [tab] button as ^ I
-v: list some unrecognizable special characters
Scene:
Tac: view the contents of the file, starting with the last line
Syntax: tac file name
Scene:
More: viewing file contents
Syntax: more file name
Feature usage:
Blank key (space): for turning down one page
Enter: stands for turning down "one line"
Q: the representative immediately leaves the more and no longer displays the contents of the file.
Ctrl+F scrolls down one screen
Ctrl+B returns to the previous screen
= output the line number of the current line
: F output file name and line number of the current line
Less: viewing file contents (similar to more function)
Syntax: less file name
Feature usage:
Blank key: turn down one page
[pagedown]: turn a page down
[pageup]: turn a page up
/ string: the function of searching down for "string"; n: looking down; N: looking up
? String: the function of searching for "string" up; n: looking up; N: looking down
Q: leave the less program
Head: view the contents of the file (just the first few lines)
Syntax: head-n line count file
Example: head-n 10 file (description: view the first 10 lines of the file, 10 can be any number of lines)
Tail views the contents of the file
Syntax:
(1) tail-n 10 file (description: view the last 10 lines of the file, 10 is any number of lines)
(2) tail-f file (description: track all updates to the document in real time)
Echo write
Syntax:
(1) the content to be displayed by echo > > the file in which the content is stored (description: the content to be displayed, stored in a file)
(2) echo variable (description: displays the value of the variable)
Scene:
Ln soft link
Syntax:
Ln-s [original file] [target file] (description: create a soft link to the original file, which is stored in the target file directory)
Useradd add a new user
Syntax: useradd user name
Passwd sets user password
Syntax: passwd user name (description: set user password)
Id determines whether the user exists.
Syntax: id user name
Su switching user
Syntax: su user name (description: switch user)
Userdel Delete user
Syntax:
(1) userdel user name (description: delete the user but save the user's home directory)
(2) userdel-r user name (description: user and user home directory, both deleted)
Who to view login user information
Syntax:
(1) whoami (description: show your own user name)
(2) who am i (description: displays the user name of the logged-in user)
(3) who (description: see which users are currently logged on to this machine)
Set john ordinary users to have root permissions
Modify the / etc/sudoers file, find the following line, and add a line under root, as follows:
# # Allow root to run any commands anywhere
Root ALL= (ALL) ALL
John ALL= (ALL) ALL
Cat / etc/passwd to see which groups have been created
Syntax: cat / etc/passwd
Usermod modifies user
Syntax: usermod-g user group username
New group for groupadd
Syntax: groupadd group name
Groupdel delete group
Syntax: groupdel group name
Groupmod revises the group syntax: groupmod-n new group name old group name
Cat / etc/group to see which groups have been created
Syntax: cat / etc/group
Find looks for files or directories
Syntax: find [search scope] [matching criteria]
Scene: find / opt/-name * .txt
Grep searches the file for lines that match the string and outputs
Syntax: grep+ parameter + find content + source file
Parameters:
-c: outputs only the count of matching rows
-I: case-insensitive (for single characters only)
-h: do not display file names when querying multiple files
-l: when querying multiple files, only the file names containing matching characters are output.
-n: displays matching lines and line numbers
-s: does not display error messages that do not exist or have no matching text
-v: displays all lines that do not contain matching text
Scene:
Grep-C 1'1' test.txt
Grep-n 1 test.txt
Chmod: change permissions
Syntax: chmod [{ugoa} {+-=} {rwx}] [file or directory] [mode=421] [file or directory]
Description:
Change file or directory permissions
File: r-view; w-modify; x-execute file
Directory: r-lists directory contents; w-creates and deletes in the directory; x-enters the directory
A prerequisite for deleting a file: the directory in which the file is located has write permission before you can delete the file.
Scene:
[root@hadoop100] # chmod uplix test1.java
[root@hadoop100] # chmod gallex test1.java
[root@hadoop100] # chmod ostatx test1.java
# 777: maximum permissions
[root@hadoop100] # chmod 777 test1.java
[root@hadoop100] # chmod-R 777 testdir
Chown: change the owner
Syntax: chown [end user] [file or directory] (description: change the owner of a file or directory)
Scene:
[root@hadoop106 test1] # chown John test1.java
Chgrp: change the group you belong to
Syntax: chgrp [end user group] [file or directory] (description: change the group to which a file or directory belongs)
Scene:
[root@hadoop100] # chgrp usergroup test1.java
This is the end of this article on "what will be ordered by Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
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.