Linux Basics 2

Source: Internet
Author: User
Tags echo command sessions what date

The mode of running the program;

The Linux system divides itself into two parts, the core software, which is kernel, also known as kernel space, and the other part is a normal application, which is called user space.

Code in user space runs at a lower level of privilege, sees only some of the system resources that they are allowed to use, does not use certain system features, and does not have direct access to kernel space and hardware devices, as well as other specific usage restrictions.

User space: Space,us kernel space: System spaces

POS:P ortable Operating System Portable OS Specification

Posix

API; programming Interface

Run the program format;

Window;exe,dll (Dynamic library) dynamically linked library

Linux:elf, so (shared object)

Generally speaking, the program is divided into two parts

program; instruction + data

instruction, read-only

The instructions that can be run on the CPU, which are fixed on the CPU, cannot be changed or modified, are usually read-only

data, reading and writing

Data is the object of instruction processing, so it is usually read-write, readable and can be modified.

program, algorithm plus data structure, programmer write program is nothing more than call the CPU command some of the commands, the data it expects to process processing, the data is stored in memory.

A library call, a system call, a program that is allowed to be called

malloc (), Free ()

Programming languages, assembly language, microcode programming

Some specific hardware-related code, driver development in the system.

High-level language C C + + uses narrow faces

Primarily write system-level applications, drivers

Advanced application Java, Python php

Wide application area

Unix-like

Distribution of Linux;

Slackware

Secondary release SuSE

openSUSE

Debian:

Secondary release Ubuntu

Three-time release mint

Redhat: Red Hat

Rhel:redhat Enterprise Linux Business Edition every 18 months hairstyle a new version,

CentOS; The various versions released by Rhel are recompiled in a fully compatible RHEL format and are open for free on the internet

Fedora; release a new version of Personal Edition every 6 months

ArchLinux

Gentoo

Android; kernel (kernel) +busybox +java virtual machine for

Apache;apache

Bsd;bsd

Gnu;gplv2 version, GPLv3 version, pernicious influence Infinity concept

The GPL pernicious influence infinite agreement

LGPL (Lesser) loose

For example:

a:1000, GPL

b:20000, 20

A program wrote 1000 lines of code, followed the GPL agreement, and a B program, because a program is

Freely obtained, B program reference to a A, a, a program own 20000 lines of code, which it borrows

A of 20 lines, this is only a thousand points, but as long as a with a edge, B must put the remaining

Some code follows the GPL protocol

20000 lines of code only borrowed 20 lines and the remaining 19980 are open source.

Apache;apache

Bsd;bsd


The relationship between CentOS and Linux

CentOS is the operating system established by Basic Linux

Linux is a kernel system, only the terminal command interface, no graphical interface

CentOS also has a terminal command interface and graphical interface

Linux and CentOS are both open source systems


The relationship between CentOS and Rhel

Rhel releases are available in two ways, binary and source code. can be downloaded for free online, if you use an online upgrade including Patch Consulting services will be charged.

Rhel has always provided the source code for the distribution, and CentOS is the source of the Rhel release to recompile, to form a binary version that can be used. Since the source code for Linux is GNU, it is legal to get the source code from Ruel to the new binary. Knowledge Redhat is a trademark. So in the new release version of Redhat's trademark removed.

The GPL (general public License) is an unofficial Chinese translation of the GNU Common Authority. It is not a statutory release clause of the Free Software Foundation or the use of GNU General public Licensed software, which is only available in the English language of the gun general Public License.

Lgpl,gun Wide general Public License

The GNU,GNU program, also known as the slave program, was publicly launched by Richard Stallman in 27 in September 1983. Its goal is to create a set of completely free operating systems. GNU General Public License. That is, anti-copyright concepts

Apache, is the world's first Web server software to use. It can run on almost all widely used computer platforms and is one of the most popular Web server-side software due to its widespread use across platforms and security.

BSD (Berkeley software distribution, Berkeley Software suite) is a UNIX derivative system, and BSD today is not specifically a BSD derivative version, but a branch of Unix-like operating system.


Package Manager

RPM;RPM Package Manager, although the file format ranked Redhat logo, but its original design concept is open, now includes OpenLinux, Rhel,fedora,s,u,s,e, and Turbo Linux CentOS, and so on, can be regarded as a recognized industry standard

Dpt

Debian,ubuntu


Free software;

Free to use, free to learn and modify, free to distribute, free to create derivative versions,

The philosophical thought of Linux

1, all documents, almost all resources, including hardware equipment are the founder of the file format,

2, by a number of single-parent small program composition; A program only implements a function, and to do well, the combination of small programs to complete complex characters

3, try to avoid interacting with the user, the goal; Implement scripting to automate certain functions

4. Use plain text files to save configuration information; A text editor used to perform system configuration work


How to get the release of CentOS;

Http://mirrors.aliyun.com

Http://mirrors.souhu.com

Http://mirrors.163.com


The device that the user interacts with the host computer, which must be used;

Physical terminal; Direct access to the local display and keyboard devices;/dev/console (console)

Virtual terminal, a software-based terminal attached to a physical terminal, CentOS 6 launches 6 virtual terminals by default

CTRL+ALT+F1-F6 switching

The terminal of virtual reality, which is attached to the physical terminal, but provides the desktop environment, and the graphical terminal is also a kind of virtual terminal.

The path of the device file;/dev/tty# (0-... )

A command-line interface opened under the graphical interface. A remote-open interface based on SSH protocol or Telnet protocol

The path of the device file;/dev/pts/# (0 to infinity)

View your current terminal equipment commands; #tty

Interactive interface; After starting the terminal, attach an interactive application to the end device in two categories;

GUI; Image application Interface window Manager to manage

X protocol,window,manager,desktop x protocol

Desktop;

GNOME Desktop System (C language Development library GTK)

ked Desktop System (c + + development qt)

XFCE Embedded (lightweight desktop environment)

CLI: Text interface

Shell program: The shell itself means (shell, the shell of the entire system)

SH (Bourn)

CSH close to the C language style of csh, the difference is still very big

Upgraded version of Tcsh CSH

Ksh (Korn) commercial products powerful want to buy

Bash (Bourn again shell) follows the GPL protocol (set CSH, Ksh, a bit) the most popular open source sh

ZSH features Powerful

See what you like, the many versions default, or bash,

Displays the command #echo of the currently used SHELL $SHELL

Displays commands for all shells used by the current system, #cat/etc/shells

Command Prompt (prompt) only refers to the # number.

{ [email protected]  ~}: $PS 1          environment variable to define the

echo $PS 1 [\[email protected]\h \w]\$ follow this format to use


In fact, there are two types of Linux users prompt

If you log in with an administrator, display: #

If you are using a normal user, display: $


Command

Input command, (ebter) Enter

Tells or draws the shell program to find the executable program or code corresponding to the typed command, which is parsed and submitted to the kernel to allocate resources to run it. To represent one or more processes; A running program is called (a process).

There are two types of commands that can be executed in the shell.

The built-in command, which is brought by the shell and provided by a command;

external command; The executable program file is available under a file system path of the current system

Which,whereis, external command to see where the file is

The use of the format is which or Whereis followed by the name of the command.


Differentiate internal or external commands:

#type (command) command, for example, #type CD

Attention! Strictly case-sensitive


Run command: Type the command at the command prompt, and the command type format is usually as follows;

COMMAND [OPTIONS ...] [ARGUMENTS ...]

Command option Parameters

The leftmost must be a command, otherwise the error

The right side of the following can be an option, options can have more than one, plus the brackets mean that some commands are not used, this option is optional,

And then there is the parameter.


option to enable or disable some or all of the functions of a command;

short option;-C For example:-l-h

Short options generally include a horizontal line with a single character

In most cases, multiple short options can be used as commands, such as-l,h, which can be written-LH; can be merged, not merged using the middle must be separated by white space characters


A long option;--word, for example;--long--human-readable

Long options generally cannot be combined

The long option is usually guided by two horizontal lines.


The object of the command, which takes effect, for example, Ls/etc and Ls/var

The argument is to provide data to the command; Data is not a number. strings are actually data

Parameters can sometimes be multiple, and multiple parameters also need to be separated by white space characters

Again, the command itself must be unloaded to the left, and the command itself is an executable binary, or a built-in command from the shell.

Note

1, multiple options, as well as between the multi-parameter and the command should be separated by white space characters, white space characters can be a blank, or it can be two blank;

2. Cancel command execution; CTRL + C


File system;

C:\Program Files\office11\word\word.exe Actually, this is a path.

/etc/sysconfig/network-scripts/ifcfg-eth0 file path

The end of the catalogue is called a file (eth0)

For Linux all the starting range is called the root, which is the absolute top-level range, because all files on Linux can be accessed and must start from this location, called the filesystem.

The directory is just a path mapping method.


The file has two types of data, and the file access process is a path

Meta data; metadata

data;


File systems for Linux

1, the file name strictly distinguishes the character case; For example, File1,file1,file1 is a different file;

2, the file name can use any character except/unexpected, do not recommend the use of special characters;

The (/) character has two meanings, the first (/) it is the root directory, and the second (/it is the path delimiter)

3. The maximum length of the file name cannot exceed 255 characters;

4, all. The beginning of the file, are hidden files;


There are two types of paths;

1, absolute path, from the top of the beginning, from the root directory starting from the path;

2, relative path; the path to the beginning of the current position;

For example, the C-disk ABC folder has a 1 file, there is a Def folder, and Def file has a 2 file.

The 1 and 2 file paths are: (both absolute paths)

C:\ABC\1

C:\ABC\DEF\2

If you let the 1 file represent the path to the 2 file

Absolute path: C:\ABC\DEF\2

Relative path: def\2 (because the path of the C:\ABC in front of the 1 and 2 files does not have to be written out)

C:/website/img/photo.jpg We know that the Photo.jpg file is in the IMG subdirectory of the website directory in the C drive. The path to this complete description file location is the absolute path. We do not need to know any other information to determine the location of the file based on the absolute path.

The relative path is relative to the target position. Wherever these files are placed, they will not go wrong as long as their relative relationships have not changed.

.. : Represents the top level directory of the current directory

Current directory, also known as working directory;

Pwd:printing working Directory

If you can, you must not write it all.


Lsb:linux Standard Base Library

These paths are defined in terms of LSB.


Command termination:

LS: Displays the target list, which is a highly efficient command in Linux. The output information of the LS command can be colored and highlighted to partition different types of files.

CD: Switch working directory to dirname. Where dirname notation can be either an absolute path or a relative path. If the directory name is omitted, it is transformed to the user's home directory (that is, the directory that was just login). In addition, the meaning of home directory is also indicated,

The. Is the directory that is currently located,

Type: Displays the types of the specified command, judging whether the given instruction is an internal or external instruction

TTY: Print the file name of the terminal device connected to the standard input

Cat: Connect files and print to standard output devices, which cat often uses to display the contents of a file, similar to the type command

Which: Used to find and display the given absolute path, the environment variable path has a convenient directory where the Find command is saved. The which directive looks for eligible files in the directory where the environment variable $path is set. That is, using the which command, you can see whether a system command is a village head, and which command to perform exactly which location.

Whereis: The path of the We prohibit program, source code file, and Man manual page of the location directive.

PWD: Displays the user's current working directory as an absolute path. The command writes the full path name of the current directory (from the root directory) to the flag output. All directories are used/delimited. The first/represents the root directory, and the last directory is the current directory. The PWD command immediately learns the absolute path name of the working directory in which it is currently located.

Echo: Used to print the value of a shell variable in the shell, or to output the specified string directly. The echo command of Linux, which is very common in shell programming, is often used when printing variable value under the terminal, so it is necessary to understand the use of the echo command function is to display a paragraph of text on the display, generally play a hint of the role.


Command:

1, file system-related;

Directory Management

File Management

File View

File editing

2, System management related;


Access to Linux command help

external command; In fact, all external commands have an executable program located in a directory of the file system; using Which,whereis to get

The path of the shell program search executable program file is defined in the PATH environment variable;

#echo $PATH attention! From left to right, it's important, it's in order.

It's the first time it's been found, and if a command has execute program files under multiple paths, the order is critical, and that's the concept of the search path.


Format, COMMAND [OPTIONS ...] [ARGUMENTS ...]

Command option Parameters

Internal commands get help; The shell program comes with some basic management tools that come directly with you

#help COMMAND for example; Help CD


External command to get help; commands with separate external executable program files

1, # COMMAND--help #COMMAND-H

2. User manual (Manual) #man COMMAND

3. Information page #info COMMAND

4, the program's own Help document README INSTALL Changelog

5, the official documents of the program, the official site; documentation

6, the official documents of the release version

7. Google


Built-in command help;

#help COMMAND


Hash command:

The path result of the external command that the shell has searched for is cached into the KV (key-value) store;


History command; Manage command histories

In fact, the command history of Linux, after logging into the system, all the new commands are executed. will be placed in the buffer of memory, but once this login is introduced, these commands are recorded in the history file and the command history is numbered.

There are two places in the order history;

When you log in to the shell, the commands that are recorded in the command history file are read; cat.bash_history this historical file is in the user's home directory

The new command intelligence is recorded in the cache after logging into the shell, and these commands are "appended to the command history file" when the user exits.


History

-A; Append the new command history list for this session to the history file;

-D; Delete the command specified in the history;

-C; empty command history;

8

Quick operation; 1

! #; Can call the history of the # command; 6

! string; invokes the most recent command in history that starts with a string; 1 from bottom to top 5

!!; the previous order; 8


External commands help to obtain;

Each programmer usually develops major work in two parts, 1, write programs, 2, write programs help

Mans COMMAND

manual page; ls/usr/share/man1 CD. /man2

Man1...man8 called the first chapter

man1; user command man ls

man2; system call

MAN3;C Library Call

Man4; equipment files and special documents

MAN5; configuration file format

Man6; game-related

Man7; miscellaneous

man8; the command for the management class formats the disk partition as a management-tired command

Note: Some keywords exist in more than one section of the Help manual;

To view the manuals in the specified chapters; Man # command

The configuration file for the man command;/etc/man.config

Manpath/path/to/somewhere: Indicates the new manual file search location

#man-M/path/to/somewhere COMMAND: to the specified position

Search for the command name of the hand album and display it:


Paragraph descriptions in the Help manual

NAME

Synopsis

DESCRIPTION

OPTIONS

EXAMPLES

AUTHOR

REPORTING BUGS

See ALSO


Man less

The meaning of these symbols in synopsis;

{}; optional content

<>: Required Content

A|b: Two selected to

... : The same content can appear multiple times


The manipulation of the man command

SPACEBAR (space), ^,^f,^f,: Flip the screen to the end of the file ^ (Ctrl)

B,^B: Flip the screen to the file header

D,^d: Turn half screen at the end of the file

U,^u: Turn half screen to file header

Return:^n e ^e or ^j: Flip a line to the end of a file

Y or ^y or ^p or K or ^k: Flip a line to the file header

Q: Launch


#: Jump To Line #;

1 g: Back to File header

G: Turn to file header


Text Search

/keyword (keywords, keywords meaning):

Searches the end of the file from the current position with the string specified by keyword as the keyword;

N: Next

N: Previous

? KEYWORD:

The string specified by keyword is the keyword, and the file header is searched from the current position;

N: Same direction as search command, next

N: Follow the search command in the opposite direction, previous


Base command: Date

Date[option] ... [+format]: Display

Format: Formatting symbols

%d Displays the current system month-day year

%F Display current system month Day

%T Display current system time

Date + "%d-%f-%t"

DATE[MMDDHHMM[CC]YY[SS]]: Set

MM: Month

DD: what date

HH: Hours

MM: Minutes

YY: two-digit year

CCYY: four-bit year

. SS: Seconds

Example: date:1217073515.26


Two types of clocks for Linux;

system clock; The timing of the CPU's operating frequency by the Linux kernel;

hardware clocks; clock


Hwclock: Command

-S,--hctosys set the system time to be the same as the hardware time

-W,--SYSTOHC set the hardware time to be the same as the system time


Cal: Show Calendar


Directory-related commands

The CD is an built-in command that gets its help by helping out, for example: Helps CD


Current directory or working directory

or the home directory; home

Administrator Root:/root

Normal User:/home/username

Example:/home/tom


~: User's home directory

For Liunx bash, each user's home directory can be represented by a special character, which is a wavy line to display

CD is actually used to switch the current directory, for example: Cd/car CD

The PWD is used to display the current directory, and the CD is returned directly to the current user directory

Home directory has a ~, which is the feature of bash

Useradd; Add users, such as Useradd user1

CD ~user1

This privilege is only available to administrators

CD or cd~: The home directory of the current user

Cd:~username (username): Switch to the home directory of the specified user

CD-: Switch back and forth between the previous directory and the current directory

.; current Directory

.. ; Top level Directory

The relevant environment variables;

PWD; A variable that holds the current directory path; changing

echo $PWD Current user pwd is also the current user so the PWD command is in some sense. is actually reading this variable content and showing that this is another environment variable built in bash


Oldpwd; the last directory path; that's why CD-can switch back and forth, bash itself has a recording function, so CD-actually is CD$OLDPWD


PWD: Displays the current directory;

ls; (list) lists or lists, displays a list of files under the instruction path, note: LS does not display file contents, only the list of files in the directory can be displayed

ls [OPTION] ... [DIR] ...

-A--all, show all files, including hidden files

-L: Long format

-rw-r--r--1 root root 44800 14:32 Install.log

-rw-r--r--:

The first bit is: file type

-Normal file

D catalog File

L Link File

B-Block Equipment

C-Character device

P Pipe

S socket character

Note: As long as it is not a directory, link, block device, character device, pipe, and socket characters are all called ordinary files;

Regardless of the Web page, window file Word files are ordinary files, Linux does not rely on the suffix name to distinguish the file type, do not want to have a registry window like Windows to complete the system program, and applications like file type association, Linux does not have this function

The following 9-bit; represents access rights, perm file access rights,

Number, the number of times a file has been hard-linked, and the previous l have no relationship, are two different concepts

Left Root: The owner of the file

Right root: Array of files (group)

44800: Indicates the size of the file

14 14:32: The last time the file was modified

Each file has three timestamps

Last visited time

Last Modified Time

The last time changed

The difference between a modification and a change is a change in the content of a file, a change in the properties of a file, or a change in the properties of a file.

Note: Once a file has been modified, the content must be changed, but changes are not necessarily modified, and timestamps are attributes

Install.log: File name


-H--human-readable: automatic unit conversion

The default unit is byte, divided by 1024 is K, divided by 1024 is trillion, the conversion is too difficult, so there is a-h option,

-D displays the relevant properties of the directory itself; it is usually meaningful to use with-l;

For example, Ls-l-h/etc it puts all the list of etc files

Just want to see the details of etc, plus D will not list all the file related properties in/etc directory, but only show/etc own properties, for example, as mentioned above, a number of short options can be combined, so add a D can be written; ls-lhd/etc

-R--reverse; reverse display, reverse display

-R--recursive: recursion

When a directory is displayed, if the subdirectories are in its directory, the subdirectories are also listed, showing that the subdirectory has a bunch of content, and the subdirectory has a double directory so that the contents of each subdirectory can be displayed, which is called recursion, clean sweep


Stat/path/to/somefile: Gets the metadata of the specified file, the status information of the file, and the output information of the Stat command is more detailed than the output information of the LS command.

for example; stat/root


File View command; Cat,tac, indicates the connection file and displays it.

Cat [OPTION] ... [FILE] ...

For example, cat/etc/fstab/etc/issue two items are displayed together.

TAC: Reverse file display, reverse order display Tac/etc/fstab

-E: Display line terminator $

For example, Cat-e/etc/issue each row has a $ character, but the $ character is not the contents of the file, it is a newline character, $$: blank number

-N: Numbering each line displayed


File content Type view command: File

File/path/to/somewhere

For example, Cat/etc/fstab uses File/etc/fstab to tell us that this is a plain text file.


Echoing command; Echo, Echo is a built-in command of the shell.

echo what you give it, it will help you show what, call the return location

For example, echo "How is it?" “

Echo, for example, a variable echo $ "SHELL" can show the results

In fact, this is also echo, but echoes can now get the value stored in the variable and display it

Variables: A program running process often use memory to village data, save the data how to reference in memory to find a space, take a name, this is called variable name,

Variable: The address of a space in memory, we refer to the variable name is equivalent to reference the memory of a certain space, so variable substitution, that is, the variable name is clearly given to the variable name, it shows a variable point in the memory space of all stored data, which is called variable substitution.

-N: Prevents the automatic addition of newline symbols:

-e: Allow escape characters to be used

For example:

echo "How is it?" ”

Echo-n "How is it?" ”

echo "How \tare You"

Echo-e "How \tare You"

Echo-e "How \nare You"

\ n: Line break

\ t: Tab


echo "$VAR _name": Variables are replaced, double quotes indicate weak references

Echo ' $VAR _name ': variable does not replace, strong reference


Which: Displays the program file path for the command

which [OPTION] COMMAND

Example: Which cat

which LS

LS is an individual name, real file in/usr/bin/ls

--skip-alias: Disable alias display

Which--skip-alias LS This shows only the program path itself


Whatis: For example: Whatis read

Use the Mkwhatis command to create a database of all help manuals and their corresponding keywords on the current system;


System Management Class command;

shutdown; Halt, Poweroff, shutdown, init 0

Restart: reboot, shutdown, init 6

Associated with user login: Who, WhoAmI, W

Shutdown or restart:

Hait,poweroff reboot

-F: Mandatory, not recommended for this use shutdown

-P: Power off


Shutdown

shutdown [OPTION] ... Time [MESSAGE]

-R reboot Restart

-H Halt shutdown

-C Cancel to cancel shutdown or restart operation

Example: Shutdown-r 10 is automatically restarted after 10 minutes (root user)

Time:

Now: Immediately

+m: Relative time notation, how long after the order is submitted; For example, +3 is 3 minutes later.

HH:MM: Absolute time notation, specifying a specific time;


User login Information View command:

WHOAMI: Displays the current login valid user;

Who: All current logon sessions of the system;

W: all current login sessions and the operation of the system;

Linux Basics 2

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.