RHCE path-Linux user permissions, attributes, and shell Variables

Source: Internet
Author: User
In Linux, the following three types of users u = user, g = group, and o = other have three permissions: rwx, which are readable and writable. executable for files: r: you can view the file content w: You can modify the file content x: You can execute the file for the Directory r: You can use the ls command to view the file information in this directory w: indicates that you can create or delete files in this directory. If you have the write permission, you can create

In Linux, there are three types of users:

U = user, g = group, o = other
Three permissions are available: rwx, which are readable, writable, and executable.
For files:
R: You can view the file content.
W: The file content can be modified.
X: Executable File
For the directory:
R: You can use the ls command to view the file information in this directory.
W: indicates that you can create or delete files in this directory. If you have the write permission, you can
Everything. Therefore, be very careful when opening the directory write permission
X: indicates that the user can enter the cd directory and use the ls-l command to view the file information in this directory.
The directory usually requires the x permission.

Rwx,
R = 4, w = 2, x = 1
Have these three Permissions
Rwx 111 7
Rw-110 6
R-X 101 5
R-- 100 4
-Wx 011 3
-W-010 2
-- X 001 1
--- 000 0

As shown in figure 664, we can see from the above that rw-r --

How to change File Permissions
Chmod, chown, chgrp
 
Chmod changes File Permissions
-R recursively change the sub-directory permissions in the directory

1. Change permissions by number for all categories of users
2. Use a type of user change, such as u, g, o = rwx, rw-, u = rwx, go = r --, a = rw-
3. + and. U, g, o + r

For example, a.txt
Chmod 700 a.txt
Chmod u = rwx, go = --- a.txt
For example,/home/fred, ensure that the permissions of the owner remain unchanged, and other users do not have permissions
Chmod-R 700/home/fred is incorrect because all files in the directory cannot be
Executable. Therefore, use the following method.
Chmod-R go = ---/home/fred

One of the three methods is certainly the most suitable

Chown changes the file owner and chgrp changes the file group
All support an option-R, recursively changing
Chwon [options] user file or dir
Chgrp [options] group file or dir

Chown -- reference = B c (change the permission of the c directory to the same as that of B, that is, refer to the permission of B)

Default permission umask
Normal files do not have the execution permission by default.
Directory 777-umask
File 666-umask
The umask setting is only valid for the current system. After the system is restarted, it becomes invalid.


Chapter 2, shell
Shell is equivalent to a translator. It is a software and an interface used
Dealing with users and kernels, man-machine interface.

The language style is similar to the C language.
Shell Classification
Sh-> csh-> ksd
Bash complies with the GPL specification and has extremely powerful functions. By default, almost all linux systems use bash.
Shell is interpreted as running. It is a script language.

Bash Variables
1. Local variable: valid only for this shell and invalid for sub-shell. If you want to use the sub-shell,
It must be declared as an environment variable. Use export var.

2. Environment Variables
3. Pre-Defined variables (usually location variables)
4. Special Variables


How to declare a variable, directly variable name = value.
For example, abc = 123
How to reference a variable,
For example, echo $ abc

Environment variables of the history command

Number of commands in the history of HISTSIZE
HISTFILE stores historical files
HISTCONTROL has the following parameters:
Ignorespace
Erasedups
Ignoredups
Ignorespale


Command completion
$ Path environment variable
File Name completion
Find the corresponding file or directory under the specified directory prefix as the starting directory

History number: displays the commands that have been executed recently.
!! Indicates the last command in the command history.
! Ec indicates the latest command starting with ec in the command history.
! 56 indicates 56th commands in the command execution history
!? Abc indicates the command containing abc.
! -3 indicates the last three commands.
! $ Reference the last parameter of the previous Parameter
Duplicate commands are retained in the command history. How can this problem be changed? You can use the following command


Shell

Development language
1. compilation language
2. Explanation languages: bash, perl, python, php, and ruby


Bash variable type:
1. Local variable: valid only for this shell and invalid for sub-shell. If you want to use the sub-shell,
It must be declared as an environment variable. Use export var.

2. Environment Variables
3. Pre-Defined variables: (usually location variables ),
4. Special Variables


Sample script
#! /Bin/bash
Cd/etc
Pwd
Cp-a/etc/skel/home/jack
Chmod-R go = ---/home/jack
Ls-ld/home/jack
Useradd wendy
Chown-R wendy/home/jack
Id wendy

Related Article

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.