Linux permission instances

Source: Internet
Author: User
Tags binary to decimal

Linux permission instances

Ii. linux Permissions

2.1 permission explanation

2.1.1 directory permission

D: Start with d, indicating directory

D: folder

-: Starts with-, indicating a normal binary file.

L: Start with l, indicating the soft connection file (link)

File rwx permissions:

R: You can perform catch, more, and other read operations.

W: Modify the file content and perform other write operations, but this does not mean you can delete the file.

X: perform operations on the file.

Directory rwx permission:

R: A readable operation that can list the contents of a directory, such as the ls command.

W: Permission to create or delete files in a directory.

X: indicates that you can enter this directory (basically, all directories have the rx permission ).

Therefore, the permission to delete files is the write permission for the directory where your current file is located.

Files in Linux, such as drwxr-xr-x, can be viewed as three parts (rwx r-x ),

Are the permissions of the file owner rwx (user,

Group r-x (group) Permission

Permissions of others r-x (others.

2.1.2 Change permissions

Chmod [{ugo} {+-=}{ rwx}] [file or directory]

Chmod number [file or directory]

U indicates user

G indicates group

O indicates other

Number is a binary to decimal Number. The value 775 indicates rwxrwxrw-Indicates 111111110.

2.1.3 switch users

Su-[user name]

2.1.4 change the file owner

Chown [new user name] [file name]

2.1.5 change the file group

Chgrp [group name] [file name]

2.1.6 help commands

Man [command or configuration file]

The Help Command is very useful.

Whatis [command]

View the command description.

-- Help

[Command] -- help

View Command Option usage.

2.1.7 compression and decompression

Command: gzip

Syntax: gzip [file name]

Description: The original file is not retained during compression, and the directory cannot be compressed.

Command: gunzip

Syntax: gunzip [compressed files]

Description: Decompress the file without retaining the source file.

Command: tar

Syntax: tar [zcvf] [zxvf] [package file name .tar.gz] [source file]

-C: generate a tar package file (required)

-Extract files generated by x (required)

-V: Show Details

-F: Specifies the compressed file name.

-Z package and compress

Description: The suffix .tar.gz generated by the package directory, or decompress the package.

Add "-C" to indicate the path to the file after decompression.

File command to view any file type

Command: zip

Syntax: zip option [-r] [compressed file name] [source file]

Description: The zip format is common for windows and linux. files and directories can be compressed. You need option-r to compress directories.

Command: unzip

Syntax: unzip [decompressed file]

Description: Decompress the package.

Add "-d" to the configuration to indicate the path to the file after decompression.

2.1.8 system commands

Ping

(Note: There are many reasons for ping failure to the peer network. You need to troubleshoot the problem step by step)

(1) ping the loopback address 127.0.0.1 to check whether the network protocol of the local machine is correct.

(2) ping the ip address of the Local Machine to check whether the network on the local machine is correct.

(3) Check the peer network settings, firewalls, plug-ins, and so on.

(4) If the packet loss rate is found, it may be caused by the network or network cable.

(5) ping the configuration option ping-c 6 192.168.80.100 (indicating that the IP address is disconnected after the ping is 6 times)

(6) ping the configuration option ping-s 60000 (max. 65507)

View Nic information: ifconfig

Shutdown: shutdown-h now

Restart: reboot

Ctrl + l clear screen.

Ctrl + c to exit the application.

Tab key to complete information.

2.1.9 MPs queue and filtering

Filter: grep. You can filter the specified content and output it.

MPs queue:

Send the output of one command to another as the input of another command. Pipeline can connect N commands.

Ls-l/etc | more (the output of ls-l/etc is used as the input of the more command, that is, the content browsed by the more command is the output result of the preceding command)

Ls-l/etc | grep init (indicating to filter the output results of ls-l/etc and display the results as init)

Ls-l/etc | grep init | wc-l (the number of the last statistics is displayed)

2.1.10 logical command Operator

Logic and (&&)

Such as ls & pwd (if the first command is successfully executed. The second command will be executed)

Logic or (|)

Such as ls | pwd (if the first command is successfully executed, the second command is not executed. If the First Command fails, the second command is executed)

2.1.11 input/output redirection

Shell predefines three file descriptions (0, 1, 2) for each process)

0 (stdin) standard input 1 (stdout) standard output 2 (stderr) standard error output

Output redirection: displays the output result to a file (> indicates output redirection)

If you want to append the result, use ">"

Input redirection: redirects the input information, such as sending the content in a file

Error redirection: Generally, the error log information of program execution is stored in the specified log.

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.