Linux Section Fifth essay

Source: Internet
Author: User

Stage three, lecture Iv.
1. querying file type and file location commands
File
Role: View the file type (the file type under Linux does not differentiate after the prefix name)
Syntax Examples:
[[Email protected] ~]# file passwd
Passwd:ascii Text Document--ASCII
[[Email protected] ~]# file 123
123:directory "--catalogue document
[Email protected] ~]# file/var/lib/mlocate/mlocate.db
/var/lib/mlocate/mlocate.db:data the--data documentation
[Email protected] ~]# File/bin/ls
/bin/ls:elf 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2. 6.18, stripped "-Executable document (including SUID settings, compatible CPU hardware platform, LIB library, Linux kernel, etc.)

2.vim
Role: Modifying files
Mode: Default comes in general mode, I edit mode, ESC exit edit, shift+: Bottom row mode
Parameter: w:write/q:quit/! Force
Edit mode:
A: Insert content after cursor
A: Cursor last inserted content
O: The current cursor under the new line insert content
O: New line inserted at current cursor
X: Remove Backward
X: Delete Forward
U: Undo Current Action
U: Undo All actions
Shift+d: Delete the character after the cursor

General mode:
^: Jump to the beginning of the line
$: Jump to end of line
NDD: Delete n rows from the cursor
Nyy: Copy n rows
P: Paste
GG: First line of the file
G: End of File line
G: Global Replacement 1, $s/root/root/g 1, $s #root#root#g
1, $s #\/#\\/#g: Remove the meaning of the special symbol
/: Find character, N: Find Next N: Find Previous
DW: Delete words

Bottom-line mode:
Set Number: Show line numbers
Set Nonu: Line numbers are not displayed
R file: Merging files
3. Whether the files in the directory can be modified to see the permissions of the parent directory

4, set special permissions SUID, Sgid detailed reference: http://www.cnblogs.com/fhefh/archive/2011/09/20/2182155.html
Suid:set User ID (Find/-perm-04000-type F-ls lookup program for setting SUID)
Role: Temporarily gives the owner of a user binary document permission (primarily for use by ordinary users for certain special commands)
Syntax 1:chmod u+s file (increase s permission)
Syntax 2:chmod u-s file (minus s permission)
Usage restrictions and environment:
1, only for the binary files valid;

2, the performer must have X permission to the file (otherwise, even if the suid is set, because you can not execute the file suid at this time also invalid, at this time the permission bit display s);

3, the permission is only in the execution process has.

4, the performer must have X permission to the file (otherwise, even if the suid is set, because you can not execute the file suid at this time also invalid, at this time the permission bit display s);

PS: For example passwd command, path/usr/bin/passwd, permission is "-rwsr-xr-x". (The passwd command modifies "/etc/shadow")
Ps:suid is available only for binary files and not for Shell script files.

5.sgid:set group ID: Inherit groups permissions from the previous level of directory
For file
Role: Temporarily gives users the right to have a group of binary documents (more for ordinary users to use certain special commands, similar to SUID)
Syntax 1:chmod g+s file (increase s permission)
Syntax 2:chmod g-s file (minus s permission)
Usage restrictions and environment:
1, only for the binary files valid;
2, the performer must have X permission to the file (otherwise it is impossible to execute the file, not to mention the Sgid grant permission, at this time the permission bit display s);
3, the permission is only in the execution process has.

4, the performer must have X permission to the file (otherwise it is impossible to execute the file, not to mention the Sgid grant permission, at this time the permission bit display s);

PS: For example locate command, path/usr/bin/locate, permission is "Rwx--s--x".
(The Locate command reads "/VAR/LIB/MLOCATE/MLOCATE.DB")
For directory
Role: Temporarily modify the user's effective group to a group of that directory
Syntax 1:chmod g+s dir (increase s permission)
Syntax 2:chmod g-s dir (minus s permission)
Usage restrictions and environment:

1, the file belongs to the group is the user's primary group, if the Sgid directory set up the file, the file belongs to the group is the inherited directory of the genus, and the newly established directory also inherit G+s permissions
2, if the user has the W permission to this directory, because the effective group is modified to the group of this directory, so the user creates any file in this directory, belong to the group of Users group of that directory.
3, in the group X display as S or s,s represents the X permission, S is not included in the X-right,
4, the user must have X permission to the directory (otherwise can not enter, not to mention the suid to give permission, at this time the permission bit display s);

6.SBIT Sticky Bit, valid only for directory, invalid file, prevent deletion of other user's data
Role: Restricts editing permissions for other user documents or directories between different users in the directory.
Syntax 1:chmod o+t dir (add t permission)
Syntax 2:chmod o-t dir (minus t permission)
Usage restrictions and environment
1, only for the directory;
2, must have X and W permissions (otherwise can not enter and edit, not to mention Sbit permissions, at this time the permission bit display T);
3, the user's own creation of documents and directories, only their own and root can be edited (rename, modify content, copy, delete, etc.)

4, must have X and W permissions (otherwise can not enter and edit, not to mention Sbit permissions, at this time the permission bit display T);

7. Granting Permissions

chmod 4777//is set SID
chmod 2777//is set GID
chmod 1777//is set sticky--t this bit can be understood as anti-delete bit. Whether a file can be deleted by a > user depends largely on
Whether the group to which the file belongs has write access to the user. If no write permission is available, all files in this directory are not
Can be deleted, and new files cannot be added at the same time. If you want users to be able to add files but cannot delete files at the same time,
You can use the sticky bit bit for the file

0: Do not set special permissions
1: Set Sticky only
2: Set Sgid only
3: Only set sgid and sticky
4: Set SUID only
5: Only set suid and sticky
6: Only set suid and Sgid
7: Set 3 kinds of permissions

Linux Section Fifth essay

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.