Linux environment variables and file lookups

Source: Internet
Author: User
Tags chmod

scripting language on Linux I'll choose Python, so I don't know much about bash.

In this part of the school to learn some very basic command and knowledge points

1. The beginning of any script file should be #! To declare what type of file you are.

For example: if it's bash, then #! /bin/bash; If it's python, then #! /usr/bin/python;

#! This is followed by the location of the Python interpreter, and if you are not sure where it is, you can use which Python to find it, and it is not recommended to use locate.

In Linux (STD is the abbreviation for standard)

Standard input: i.e. keyboard input stdin

Standard output: Directly to the screen stdout "1"

Standard error output: Also lost to the screen, stderr "2"

If you want your results to be entered in a file, not on the screen

For example, ls > Ls_result, which is the result of LS, is redirected to the Ls_result file.

LS >>ls_result;

The difference between > and >> is that the former will overwrite the contents of the rewrite, which is appended

In Linux, 1 is used to represent stdout,2 for stderr;

Example: If you want to put the wrong result in a certain location, how to write it?

(insert: Explain the use of a Find command using Find path-opt-action)

Find/home-name lost 2>err-result

(insert: Explains a command to change permissions chmod who-opt-mod file name

Who u file owner, G same group, o other, a All

-opt the meaning of the operation; + Add,-delete; = Give

-mod R W X

chmod g+rwx myfile

If you use numbers to represent simpler

chmod 755 myfile

Echo This command is to display a piece of text on the display

Echo $path

If you want to add a directory path to the path, how do you do it?

Path=path:/home/myname/mybin

Find generally have four commands

Whereis, which, locate, find

Linux environment variables and file lookups

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.