First knowledge of Linux

Source: Internet
Author: User
Tags clear screen

This article simply describes what you just started learning about Linux, so that I could review what I learned before


Linux Start-up process

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/75/4B/wKioL1Y1h0nRtyIcAAfDLBDFh4M020.jpg "title=" Boot.jpg "alt=" wkiol1y1h0nrtyicaafdlbdfh4m020.jpg "/>

Set the IP for Linux:

Use VI to open "/etc/sysconfig/netowrk-scripts/ifcfg-eth0", enter "I" to enable the editing mode;

Change "Onboot=no" to "Onboot=yes", which indicates whether the network adapter is activated;

Change "Bootproto=none" to "Bootproto=none", will automatically get the IP address closed, work is used to obtain the IP address manually;

Add the "ipaadr=192.168.0.212" here to add the IP address, the specific address in their own local network, depending on

"netmask=255.255.255.0"

"gareway=192.168.0.1"

"Dns1=" 8.8.8.8 "

"Dns2=" 114.114.114.114 "

Press ESC, enter ": Wq", Save and exit;

Enter "Service network restart" to restart the network card;


User mode:

0 Turn off the machine

1 Single-User mode

2 Multi-user mode, no NFS

3 Multi-user mode (this is typically used in this mode)

4 Graphics Mode

5 Spare

6 restart

Enter init [number] to toggle the corresponding mode;


To forget the root password, use single-user mode to modify:

Power on 3 seconds to press any key, select the second item Press "E" to enable edit entry, at the end with "1" or "s" or "s", enter OK, return to the interface select the second item Press "B" to enter the single user mode, use "passwd" to modify the root password


Common uses of CDs

CD: The user's home directory can be returned in that directory.

CD/directory: Go to a directory.

Cd. : Current directory.

Cd.. : Top level directory.

CD-: Go back to the last Open directory.

CD ~/: Here the "~" represents the user's home directory.

PWD: Prints the current directory.


Common uses of LS

LS: Displays the files and directories of the current directory (excluding hidden files and directories).

Ls-l: Displays the details of the files and directories in the current directory.

Ls-a: Displays files and directories (including hidden files and directories) in the current directory.

Ls-d: Displays the directory under the current directory.

Ls-i: Displays the inode number of the file and directory under the current directory.


CP Copy Command

CP [options] source files and directory destination files and directories

-R can copy directories and subdirectories


MV Move Command

MV [options] source files and directory destination files and directories move and rename

If the target file already exists, the target file will be overwritten, and if the target directory already exists, the directory will be placed under this directory.


View Documents

Cat Read File

-A

TAC view files from bottom to top

More view the file "space" "one screen page"; "Enter" the page of a row;

Less view file; Pgug Pgdown

J--ctrl+b Up

G The last row of the first line G

Head View Top 10 lines

-n Specifies the first few rows

Tail view after 10 lines

-n Specifies the following lines

-F Dynamic View


About file properties

crw-rw-rw-1 root root 1, 5 October 20:58 Zero

First place:

D Represents a directory

s process pass socket

-Representative documents

C represents the character

b -block devices, such as/DEV/SDA, are such files.

L represents the Software link record file path

P Pipeline file links between files

650) this.width=650; "src="/e/u261/themes/default/images/spacer.gif "style=" Background:url ("/e/u261/lang/zh-cn/ Images/localimage.png ") no-repeat center;border:1px solid #ddd;" alt= "Spacer.gif"/>

9 bits behind the file represent file permissions (rw-rw-rw-)


basic usage of chmod  

R Read W write x executable

r=4 w=2 x=1

chmod 644 1.txt

-rw-r--r--1 root root 0 October 15:07 1.txt

u=user g=group o =other a=all

chmod u-w 1.txt

chmod U=RW 1.txt

chmod-r [Name] permissions to modify directories and subdirectories and sub-files


The use of Chown

chown [group name] [file and directory name]

Chown [belongs to the Lord]. [Genus Group] [Files and directories]

chown-r modifying directories and subdirectories and files


The use of chattr

A---Non-modifiable files, can only append, cannot be deleted

I---Non-modifiable files, non-append files, non-deleted files, no duplicate names

Chattr +i 1.txt

+-=: increase, decrease, set, respectively


lsattr view File Hidden properties

Lsattr-r viewing files in directories and directories

lsattr-d View current Directory


Set_uid

chmod U+s 4

Temporary root privileges, only for executable binaries

Set_uid

chmod g+s 2

Add s permission to the directory, the file created in this directory belongs to the group root is not the current user

Sticky_bit

chmod o+t 1

You cannot delete subdirectories and files in this directory by adding T permission to the directory


View Files

which

only executable files within the environment variable directory

Whereis

You can only view the search in a partial directory, search for a file containing

Locate

You must update the search library every day, manually generate Datedb cannot search the TMP directory, as long as it is included .

Find

find [path] [type] [filename]

available wildcard pipes, etc.

find/tmp/-name "Yum.log"

Find/tmp/type F

find/tmp/-mtime

find/tmp/inum 141418 Search by inode number

- o indicates or

-maxdepth represents the largest extended directory

-perm XXX Indicates how many permissions the file and directory

Common shortcut keys for Linux

CTRL + L Clear Screen

Clear Clear Screen

Exit--logout Ctrl +d exit

CTRL + A cursor moves to the front

CTRL + E cursor moves to the last

CTRL + U clear the command in front of the cursor

CTRL + K clear the command behind the cursor

CTRL + C interrupt command interrupt program

CTRL + Z pauses current task FG recovery program

CTRL + S pause screen (no action is displayed)

CTRL + Q Recovery Screen


First knowledge of Linux

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.