In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Document viewing (cat, more, less, head, taid)
Cat
To view the contents of the file in positive order.
Tac looks at the contents of the file in reverse order.
The cat-A text will be followed by the Terminator $
Cat-n displays the line number
More
View the contents of the file one screen at a time
Press the spacebar to turn the page down; ctrl+b to turn the page up
Less
Similar to more, it is also to view the contents of the file on a screen and press the space bar to turn the page. There are many shortcuts for single-function machines.
J: down k: up
Ctrl+b flips up and ctrl+f flips down
G: navigate to the first line G: navigate to the last line
/ search keywords to view from the back, press the n key: search down for the same characters shift+n: look forward
? View from back to front n: down N: up
Q exit
Head
View the first ten lines of a file
You can specify a number such as: head-n 2 1.txt (file name) only look at the first two lines
Tail
Just look at the last ten lines of a file.
Specify the number of lines: tail-n 3 filename only looks at the last three lines
Tail-f can dynamically view a document (such as a log). By default, it only shows the last ten lines down by space.
Ctrl+c, return it.
Chmod command (used to change permissions)
Rwx r: readable w: writable x: executable
Rang 4 wags 2 x girls 1
Rwx=7 r-x=5 Rmurmuri 4-- xylene 1 rw-=6 for example: rwxr-xr-x=755
How to change it, for example, if a file has 644 permissions, change it to 700
Use the command: chmod 744 1.txt (with the file you want to change)-rw-r---r-- (755)-rwx-
Or use this method: chmod uplirwx.glos.o = 2.txt
U: owner g: group o: others
Command: chmod-R changes all files and subdirectories recursively
A means all chmod axioms means everyone adds executable commands.
Umask
Enter umask and you will see the umask of the system
To determine the permissions of the default files and directories
Change method: for example, the umask number of the system is 0022. We want to change it to 0002. Enter: umask 002 change (usually omit the preceding 0).
Ask for directory permissions: use 777-umask if umask is 022 and ask for directory permissions: (rwxrwxrwx) minus (- wmurmurw -) = rwxr-xr-x=755
Ask for file permissions: use 666-umask if umask is 022 and ask for file permissions: (rw-rw-rw) minus (- wmurmurw -) = rw-r--r--=644
Principle:-(nothing) minus r or w or x he still has nothing.
Chown command (used to change what belongs to the master group)
Useradd is used to create user groupadd create group
! Ls! The meaning is the nearest command that begins with ls in the history of commands.
History: command history
For example, we need to change 111.txt
Chown users1 111.txt changes user owner
Chgrp user1 changes the group to which it belongs
Chown: users1 111.txt changes the user group
Chown root:root 111.txt changes together.
Chown-R root:root changes the master and group of all directories and files
Hide permissions lsattr, chattr
Chattr adds permissions to a file or directory
Permission for lsattr to view a file or directory
Chattr + a file + a permission you cannot delete this file or change the content to change the name, only touch file or append (> > means append redirect) > means that the redirect directory can append energy redirection energy touch file
Chattr + I files plus I permissions can change nothing more strictly, while directories can be appended or redirected to remove-I
Lsattr-R looks at the subdirectories layer by layer
Lsattr-d only looks at the directory itself
Special permission set_uid
When an ordinary user executes this command, it will temporarily have the identity of the root user.
Function: to ensure that the ordinary user temporarily owns the identity of the owner of the command
To set set_uid for a file, the file must be a binary file (such as ls, passwd, and 1.txt file settings are meaningless) and executable.
How to follow a file to authorize set_uid?
For example, I want to add a command to ls-l / usr/bin/ls: chmod Utility / usr/bin/ls as shown below:
Let's first switch to su-aming whoami for ordinary users. It is not possible to use the ls / root/ command now.
You can view it with the command chmod UBSs / usr/bin/ls plus this permission.
However, the permissions remain the same, but only temporarily give root the identity of a tiger and have the rights of root users.
Cancel the command: chmod Umurs / usr/bin/ls
Set_uid can only be used on files
Special permission set_gid
Chmod gears
This permission bit acts on the group permission bit, which used to be the identity of the owner owned by the ordinary user, and now the identity of the group to which the ordinary user belongs. It can act not only on the file but also on the directory.
When you create a child file or directory under this directory after setting up gid, the group of the child file and subdirectory will be the same as the parent directory. As shown below:
After removing the gid:
Similar to set_uid when acting on a file, it allows the ordinary user who executes the file to temporarily have the identity of the group to which he belongs.
When working on a directory, when you create a subdirectory or subfile, the subdirectories and files you create belong to the same group as the group that belongs to that directory.
Soft link file
Soft connection command: ln-s form: ln-s file destination address
For example: put yun.log under tmp into directory 111 under root
Command: ln-s / tmp/yum.log / root/111/yum.log as shown below:
Form: source file on the left and soft link file on the right
You can soft connect not only files but also directories, and across zones
Hard link file
Format: the destination address of the file to be done by ln
Meaning: you create a file that is the same as the inode number of another file. These two files are hard-linked files to each other.
Hard links do not take up extra space, which is equivalent to the skin of a file, and each skin points to the same inode number. This skin can be deleted, but not all of it, leaving at least one.
The hard connection can be deleted because he has other files using the ionde number.
It doesn't matter whether the hard link is deleted or not, because the file itself is deleted if the file is deleted by the soft link.
Only hard links to files are supported, hard links to directories are not supported, only files are supported and not across regions
Find command
Detailed introduction of http://man.linuxde.net/find
-type: only find files that match the specified file type f ordinary files l symbolic connection d directory c character device b block device s socket pFifo
-mtime: find files or directories that have been changed at a specified time, calculated in 24 hours
-mmin finds files or directories that have been changed at a specified time (in minutes)
-size: find files that match the specified file size
-exec: if the return value of the find instruction is True, the instruction is executed
-name: specifies a string as a template style for finding files or directories
The command to search for files, and some similar commands such as which, which is found in the echo $PATH environment variable
For example, I want to search SSHD _ config under etc.
Command: find / etc/-name "sshd_config"
You can also fuzzy search: find / erc/-name "sshd*" below:
Just the directory command: find / etc/-type d-name "sshd*"
Just the file command: find / etc/-type f-name "sshd*"
Or you may not specify: find / etc/-type d
-l soft connection file
Find followed by path followed by conditional option
The stat command is used to view file details as shown in the figure:
-recent visit time of atime
-mtime last changed time
-time of last change in ctime
The time and content of changing the file-mtime and-ctime will change, as long as you change the content of the file-ctime will change because it records the size, time, permissions, owner, and group of the file.
How do I see files that have changed under etc in one day? Use the command:
Find / etc/-type f-mtime-1 + 1 is greater than one day
The meaning above is and, it can also be:-o
Find /-type f-o-mtime-1-o-name "* .conf"
Find hard links to the same file: find /-inum 33583267
View files that have changed within an hour: find / root/-type f-mmin-60
View the files that have changed within an hour and list their details: find / root/-type f-mmin-60-exec ls-l {}\
Find the file and rename it: find / root/-type f-mmin-150-exec mv {}. Bak\
The first {} means the original name of the file {}. The second is the name to be changed.
Files larger than 10 megabytes and list details: find / root/-type f-size-10k-exec ls-lh {}\
Linux and Windows transmit to each other
Need to install lrzsz package: yum install-y lrzsz
Command: send sz to computer for example: sz 2.txt
Command: rz sends rz from the computer to Linux and enter directly.
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: 246
*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.