Getting Started with basic Linux operations

Source: Internet
Author: User
Tags glob printable characters stdin uppercase letter

1. User Login

Root user

A Special Administrative account

Also known as Super User

Root is close to complete system control

Almost limitless capacity for system damage.

Do not log on as root unless necessary

Normal (non-privileged) user

Limited access

The ability to inflict damage is relatively limited

2. Terminal display

Device Terminal

Keyboard Mouse Monitor

Physical Terminal (/dev/console)

Consoles Console

Virtual Terminal (tty:teletypewriters,/dev/tty# #为 [1-6])

TTY can have n, ctrl+alt+f[1-6]

Graphics Terminal (/DEV/TTY7) startx, Xwindows

CentOS 6:ctrl + Alt + F7

CentOS 7: At which terminal to boot, which virtual terminal is located

Serial Terminal (/dev/ttys#)

TTYs

Pseudo Terminal (Pty:pseudo-tty,/dev/pts/#)

Pty, SSH remote connection

View current Terminal equipment: #tty

3.shell (shell is the user interface of a Linux system that provides an interface for users to interact with the kernel.) It receives the user input command and sends it to the kernel to execute it)


Display the currently used shell

Echo ${shell}

Displays all shells used by the current system

Cat/etc/shells

Display System support Shell Cat/etc/shells

4. Date and Time

Two types of clocks for Linux

System clock: Run by the Linux kernel through the CPU's operating frequency

Hardware clock: Motherboard

Related commands

Date display and set system time

Date +%s

Date-d @1509536033

Hwclock,clock: Display Hardware clock

-S,--hctosys to calibrate the system clock, whichever is the hardware clock

-W,--SYSTOHC to calibrate the hardware clock, whichever is the system clock

Time zone:/etc/localtime

Show Calendar: Cal–y

5.Linux File types

-: Normal file

D: Catalog file

B: Block device

C: Character device

L: Symbolic Link file

P: Piping File pipe

S: Socket file socket

6. File wildcard character man 7 Glob

Pre-defined character class: Man 7 glob

[:d Igit:]: Any number, equivalent to 0-9

[: Lower:]: Any lowercase letter

[: Upper:]: Any uppercase letter

[: Alpha:]: Any case letter

[: Alnum:]: Any number or letter

[: Blank:]: horizontal white space character

[: Space:]: Horizontal or vertical whitespace characters

[:p UNCT:]: Punctuation

[:p rint:]: Printable characters

[: Cntrl:]: Control (nonprinting) character

[: Graph:]: Graphic character

[: Xdigit:]: hexadecimal character

7. Delete


RM [OPTION] ... FILE ...

Common options:

-I: Interactive

-F: Force delete

-R: Recursive

--no-preserve-root

Example:

RM-RF/

Example: rm-rf/root/passwd (empty file with-R has content need to use-f-r)

8. Hard links and soft connections

Creating a hard link adds additional record entries to reference the file

A symbolic link points to another file

LS-L displays the name of the link and the referenced file

The content of a symbolic link is the name of the file it references

The directory can be

Can span partitions

A path to another file whose size is the length of the path string pointed to, and does not increase or decrease the reference count of the target file inode;

Grammar:

ln-s filename [linkname]

Corresponds to a physical file on the same file system

Each directory references the same inode number

Increase number of links at creation time

When deleting files:

Link for RM command decrement count

File to exist, with at least one link number

When the number of links is zero, the file is deleted

Cannot span drives or partitions

Grammar:

ln filename [linkname]

Redirection of 9.IO interfaces

Each interface has the corresponding input and output, when we use the keyboard input text, the system will input the text to the output interface, in general, the terminal (display).  For example: How is Cat? Terminal display: How is it? This is because we use the keyboard as the input source, the system detects that there is no corresponding output file matching, and then sent directly to the output terminal, so you can directly display the corresponding text.

In general, the location of the input and output interface is/dev/stdin,/dev/stout; But when we enter the error command, the system will prompt an error, this is because the system did not find the relevant files after the output of the wrong prompt, but the output location is dev/stout.

If an artificial interference display interface is required, the output interface can be changed through the redirection technology of IO interface. For example, to force output of the/root/etc/passwd file to a/ROOT/LBB file instead of a terminal display, you can enter cat/etc/passwd >/ROOT/LBB . Opening the LBB file will reveal that the contents of the file are overwritten in the LBB file.

The other representation is the forced append output, which preserves the full-text content and appends the relevant content at the end of the file. For example: /etc/issue >>/ROOT/LBB.

For the input we can also redirect the corresponding: "<" in general, the general form of input redirection, and cat [options]files meaning, "<<" means double input, that is, to create a document, In general we can work with this output redirection together. Cat >/etc/passwd<<eof indicates that the EOF content is entered and overwritten to the passwd display.

Of course, there is a wrong redirect, error redirection is also a form of output redirection, but he output is not normal information, the system cannot execute the command after the prompt error message will also output to display terminal for display. For example:

You can see from the hint that the/etc/lijiabin file does not exist at all, so it is an error command, and we can also consider the output of the intervention.

2> Overwrite redirect error output data stream

2>> chasing aggravated directional error output data stream

Standard output and error outputs are directed to different locations

COMMAND >/path/to/file.out 2>/path/to/error.out

Merge standard output and error output redirect for the same data stream

&> Overwrite redirects

&>> Chasing heavier orientation

COMMAND >/path/to/file.out 2>&1 (Order is important)

COMMAND >>/path/to/file.out 2>&1

(): Merging stdout of multiple programs

(Cal, Cal) > All.txt

9. Piping

Pipe (using the symbol "|" Used to connect commands

Command 1 | Command 2 | Command 3 | ...

Send stdout of command 1 to stdin of command 2, stdout of command 2 to stdin of command 3

StdErr cannot be piped forward by default and can be implemented with 2>&1 or |&

The last command executes in the child shell process of the current shell process to

The ability to combine multiple tools

ls | Tr ' A-Z ' A-Z

Less: View input page by page

Ls-l/etc | Less




Getting Started with basic Linux operations

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.