Linux (3) _ File Permission, system search, text editor, and linux Text Editor

Source: Internet
Author: User
Tags linux text editor

Linux (3) _ File Permission, system search, text editor, and linux Text Editor

1. Understand file permissions and their allocation

2. Have the permission to view files and directories.

3. Master the permission text representation and Numerical Representation

4. Learn to use the chmod command to set permissions

5. Learn to use the chown command to modify the owner and group

 

File Permission

View Details: ls-l fileName (LInux Standard) or ll fileName

-Rw-r -- r indicates that the current user can be read and written, the current user group can be read only, and other users can only read. This is the default permission.

 

Use the chmod command to set permissions

 

The number indicates that three groups of permissions can be processed at the same time, and the characters can only be modified one by one. Chmod 777 fileName can open all permissions.

 

Use the chown command to modify the owner and group

Chown root: root test/

 

SUID:

[Xiangkejin @ localhost tmp] $ ll/usr/bin/passwd
-Rwsr-xr-x. 1 root 27832 2014/usr/bin/passwd

The owner of passwd is root, and the column in which the owner permission should be x is displayed as s. This indicates that this command has SUID permission.

When a common user executes this command, after the system generates the corresponding process, the process has the root permission of the owner of the/usr/bin/passwd file,Just by usingIf it is changed to rwx, it cannot be executed by common users.

 

SGID:

New user: useradd user

Create a group:Groupadd share

Add a user to a group:

Usermod-G groupA user
This will allow you to leave other user groups and act only as members of the group.
The-a option should be added:
Usermod-a-G groupA user
-A indicates append, that is, adding yourself to the user group groupA without leaving the original user group.

Change the directory group: chgrp share/

Account A creates A new file. The owner and user group of the new file are both! It is important that other users cannot access this file!
Therefore, we need to add the SGID permission to this directory. The file user group created by any user will be the user group of this directory.

Chmod 770 share/change permission settings

 

SBIT:

Drwxrwxrwt. 16 root 4096 November 22 19:52 tmp

If you have SBIT permission for a directory and you have wx permission for the directory, only the files or directories created by the user and the root user can be deleted.

 

The common ls command is used to view special permissions:
SUID will display s where the user permission is supposed to be x
SGID will display s where the user group permission is supposed to be x
SBIT displays t where other user permissions are supposed to be x.

 

Search for Linux systems

Which searches for files, whereis searches for specified files, locate searches, find searches, and find finds instances

Which can only findExecutable filesAnd can only beUser Environment VariablesFind the information in the specified path.

View environment variable settings env

Vim/root/. bash_profile modify Environment Variables

Whereis is used to find its ownDatabaseData is written to the database in advance. Help documentation and configuration files.

Search for locate:FuzzyFind all relevant information.

Find: the search is slow. find the hard disk.

Search by Time:

#-Atime #-mtime #-ctime #-amin #-mmin #-cmin

Here, atime, mtime, and ctime are the corresponding "last access time", "Last content modification time", and "last attribute modification time ", here, atime refers to "days", and amin refers to minutes.

If the specific number find/-atime 10 is followed, it indicates the file to be accessed on the tenth day (/indicates searching from the root directory), indicating that +-

# Find/tmp-atime + 5 // indicates to search for the files accessed five days ago

# Find/tmp-atime-5 // indicates searching for files that have been accessed within five days

 

AccordingFile NameSearch:

#-Name // search by file name (exact search)

#-Iname // search by file name, but case insensitive

AccordingFile TypeTo find files:

-Type f // common file

D // directory file

L // link file

B // block Device File

C // character Device File

P // MPs queue File

S // socket File

PressFile SizeSearch:

Find/-size + 1000 k find files larger than 1 MB

Wildcard matchFile Name:

Find/-name '* pass *' contains only the pass keyword

SearchSpecial PermissionsFile:

-Perm

# Find/tmp-perm 755 // find the file whose permission is 755 in the/tmp directory

# Find/tmp-perm + 222 // indicates that only the write permission of a user (owner, group, or other) can be matched.

# Find/tmp-perm-222 // indicates that all types of users must have the write permission.

 

Text Editor

Normal Mode: In this mode, all characters on the keyboard represent special operations.

 JumpSpecified row

Ctrl + g lists the row numbers of the cursor.

"# G": for example, "15G" indicates moving the cursor to the first row of the article.

RecallLast operation

"U": If you mistakenly execute a command, you can immediately press "u" to return to the previous operation. You can perform multiple replies Based on Multiple "u" requests.

[Ctrl + r]: restores the Undo operation using the u command.

Copy

"Yw": copy the character at the end of the cursor to the buffer zone.

# Yw: Copy # words to the buffer zone

"Yy": copy the row where the cursor is located to the buffer zone.

"# Yy": for example, "6yy" indicates copying 6 lines of text from the row where the cursor is located "down.

P: place the characters in the buffer to the cursor position. Note: All copy commands related to "y" must work with "p" to complete the copy and paste function.

Delete

"X": deletes the "Next" character at the cursor position every time you press it.

"# X": for example, "6x" indicates deleting the "Next" to the cursor position.

"X": uppercase X. Each time you press it, the "front" character of the cursor is deleted.

"# X": for example, "20X" indicates to delete the "front" of the cursor.

Dd: Delete the row where the cursor is located.

「 # Dd 」: delete from the row where the cursor is located # Row

Insert mode: press I in normal mode to enter insert mode, and Press Esc to exit normal mode.

Command mode:Press: In normal mode to enter insert mode, and Press Esc to exit normal mode.

Q! Force exit

Wq save and exit

List row numbers

"Set nu": After "set nu" is entered, the row number is listed before each row in the file.

Jump to a row in the file

"#": "#" Indicates a number. Enter a number after the colon and press enter to jump to the row. For example, enter the number 15 and press Enter, this will jump to the second line of the article.

Vi supports opening multiple files at the same time:

Vi file1 file2 file3

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.