Happy play with the great Lord of Linux (i) environment variables and file types

Source: Internet
Author: User

Well, then start learning Linux.

Used to Windows, just started to learn Linux is a face, but I windows is not very useful. 650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0012.gif "alt=" J_0012.gif "/>

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/80/10/wKiom1c1nRTgVdDVAADV9gq90PI858.png "title=" spb]0} 0@f40on) @k]h45dc7.png "alt=" Wkiom1c1nrtgvddvaadv9gq90pi858.png "/>

First put a Huang photo, after all, the first blog post.

First of all, Linux is a multi-user operating system, which means that each user login to the system, have their own dedicated operating environment. So what is the operating environment of each user? It needs to be defined by environment variables .

Users can modify their environment variables to meet the requirements of the environment.

Linux Environment Variables view and modify the commands :

1.echo displays an environment variable value echo $PATH

2.export setting a new environment variable export hello= "HELLO" (can be without quotation marks)

3.ENV Show All environment variables

4.set show locally defined shell variables

5.unset Clear environment variable unset HELLO

6.readonly set read-only environment variable readonly HELLO

Environment variables are closely related to the shell and can be set by shell commands. Environment variables can also be used by all programs that are running by the current user. For bash, the variable name can be used to access the corresponding environment variable.

common environment variables in Linux :

1.PATH: Specify the search path for the command

2.HOME: Specify the user's main working directory (that is, the default directory when the user logs on to the Linux system)

3.HISTSIZE: Refers to the number of records saved by the history command.

4.LOGNAME: Refers to the login name of the current user.

5.HOSTNAME: Refers to the name of the host.

6.SHELL: What kind of SHELL is used by the current user.

7.lang/languge: Language-related environment variables.

8.MAIL: Refers to the current user's mail storage directory.

9.PS1: Command basic prompt, for root user is #, for normal user is $.

10.PS2: Secondary prompt, default is ">".

And then, in my established mind, the file is the file, the device is the device, the interface is the interface, what is what, but in Linux, everything is file .

This design is simple and complex , enables users to use a unified, universal access to resources style , really powerful.

Since everything is a document, the document must be classified. Files in Windows have extensions , Linux also, but it's easy for users to differentiate between file types, and you can use it as part of a file name, and it's useless .

So the Linux file is how to classify it???

Linux file Types :

1. Ordinary files (regular file) the first character is [-] includes:

① Plain text file (ASCII): This is the most common type of file in a Linux system, known as a plain text file. Content is data that users can read directly, such as numbers, letters, and so on.

② binary (binary): Your Linux executable (scripts, text-based batch file does not count) is in this format.

③ data Format file: Some programs read files in certain formats during operation, and those files in a particular format can be referred to as data files. Cat is generally used to see all garbled.

2. Catalogue (directory): The first character is [d]

3. Connection file (link: The first character is [l]

4. Equipment and equipment Files :

① block device files, that is, some storage files, such as hard disk, floppy disk, etc., the first character is [b]

② character device files, which are interface files for some serial ports, such as keyboards, mice, etc., the first character is [C]

5. Socket (sockets) The first character is [s] also known as a data interface file, this type of file is usually used for data connections on the network.

6. Pipeline (Fifo,pipe) The first character is [P] FIFO is also a special type of file, its main purpose is to solve the problem that multiple programs simultaneously access a file caused by the error, first-in-first-out.

Since everything is documented, then theoretically everything can be accessed, then there will be visitors.

There are three types of file visitors in Linux:

1. Owner of file and file directory : U--user

2. User of the group that owns the file and file directory : G--group

3. Other users : o--others

Typically, users are grouped into user groups, and one user is able to grant file access to other members of the user group in which they are located.

If the user also opens their own files to all users within the system, in this case, all users within the system can access the user's directory or file. In this sense, all other users within the system are other user classes.

There are a variety of file visitors, of course, there will be different file access rights.

Types of File access permissions

1. Basic Permissions :

① Read (R/4) : Read for a file, have permission to read the contents of the file, and for the directory to have permission to browse the directory information

② Write (W/2) : Write for a file, has the right to modify the contents of the file, and for the directory to delete files within the Mobile directory permissions

③ Execution (X/1) : Execute for a file, you have permission to execute the file, and for the directory, you have permission to enter the directory.

④ "-" indicates that the item does not have permission .

2. Special Permissions

①suid (S/4) can only be applied on executables, allowing arbitrary users to execute files as file owners when executing them

②sgid (S/2) can only be applied to an executable file, allowing any user to execute the executable as a member of the owning group

③ sticky bits (T/1) can only be applied to directory files, allowing users to delete only the objects they own when they perform a delete in the directory

stopped haha haha, next continue.


Happy play with the great Lord of Linux (i) environment variables and file types

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.