"Linux Basics" linux basic command line learning notes

Source: Internet
Author: User
Tags chmod clear screen

Absolute path: Cd/home/python
Relative path: CD Downloads

. Expression: Current that path
.. Represents: The previous layer of the current path
.. /.. Represents: The top two level of the current path

No... or more of


Is_
LS View the file under the current path and the name of the folder
Ls/bin: See what's Under the Bin folder in the root directory
LS Documents: View everything under the Documents folder under the current path

LS *: * denotes any number of characters, or can not

? Represents a character, there must be 1, cannot have no

[xn] means: any one of the characters in brackets
[ABCdef] can be written as [A-f]: represents any one character from a to F

-A hidden file
-l list Display style
-H Mate-L displays a reasonable size unit

Cd:
CD desktop into the Desktop folder

The name of the CD folder

Cd.. Jumps to the previous level of the current path

CD-Jump to the last path (similar to the one seen in the TV remote)

CD ~ Jump to the current user's home directory (/home/python)

PWD: Shows the path of the current operation (absolute path/AAA/BB/CC)

Clear: Clear Screen

TAB key: Used to auto-complete

Touch: Create a file that does not have a suffix in Linux, all filenames are custom

Redirect:

ls > Test.txt: Writes the information that was originally displayed on the terminal to the Test.txt file

The difference between >> and > is that:>> is added at the end of the source file, and > is emptied before adding

Gedit haha.txt Open haha.txt file with Gedit Editor

More

More Test.txt If the contents of the Test.txt file are many, then display it in Split-screen mode

Ls-alh | More first put the contents of the LS-ALH display into the pipeline |, and then more from the pipeline to go to the data, and then split the screen display


mkdir: Creating a Folder

mkdir a creates a folder under the current path
mkdir a/b/c cannot be created,,, need to add-p

Tree: Displaying the folder structure as a directory tree

RmDir: Delete Empty folders

Rm:
RM haha.txt Delete a normal file
The RM folder will be prompted to delete something that is a folder,,, if really want to delete can add-r (recursively delete everything inside the folder)

Ln-s source File Link file means: Soft connection
The ln source file link file means: Hard link,, note that the number of hard links is 1 o'clock to actually delete the data, otherwise it will not


Cat 1. View the contents of a file
2. Merging multiple file needs and redirects > mates

Cat 1.txt 2.txt > 3.txt

grep: Search for required content from the specified file

-N: Show line numbers
-I: Case insensitive
-V: Inverse, that is, the row that does not contain the required content

Homework:
There is a file (content Custom), now you need to put all the content beginning with the letter A and the letter B end of all the content into a new file Result.txt

For example:
The source file is Test.txt and the contents are as follows:
sdfisdbbbb
Abcdefksjdfkjskdfksdj
akksjdfkjskdfj0000
Kjskdfjaaksjdfkjsdkfaaa
Ijijsdfjsdbbbbbb12
Bksjdkfjsdja
Kajsdkfjaksb
ksjdkfkasdbbbbb

The result after execution is:
Abcdefksjdfkjskdfksdj
akksjdfkjskdfj0000
sdfisdbbbb
Kajsdkfjaksb
ksjdkfkasdbbbbb


To find a file:
Find path-name ' *.t?t '


Wildcard characters, note points:
[A-za-z0-9]*.txt

To copy a file:
CP A B copies the A folder as a whole to the B folder
CP a/* B assigns all content under the A folder to the B folder

Cut files:
MV A B moves the A folder as a whole (cut) to the B folder


B----bytes
K----> Kbytes 1024B
M----> MBytes 1024K
G
T
P


TAR-CVF Xxx.tar * Packing
Gzip Xxx.tar Compression

Gzip-d xxx.tar.gz
TAR-XVF Xxx.tar

Common Compression Decompression methods:

TAR-ZCVF xxx.tar.gz *
TAR-ZXVF xxx.tar.gz

TAR-JCVF xxx.tar.bz2 *
TAR-JXVF xxx.tar.bz2

Linux: Multi-user multitasking OS

Ifconfig: View IP Address

Using ipconfig in Windows

Ping:

Ping 192.168.17.76 Test network connection is healthy


SSH: Telnet

SSH [email protected]
SSH User name @ip

WhoAmI: View Current user name

Who: View current logged in user information

Exit: Log Out


Useradd New user name-m-d/home/new user name-G group name

passwd User Name

The user name that SU needs to switch
Su-the user name that needs to be toggled, after switching the user, will also actively jump to the user's home directory

Python---->laowang----->python

sudo needs to be added when a super administrator is required, and at the front of the command line, spaces are required
sudo passwd Laowang

Sudo-s switch directly to the root user

Groupadd YYY Add a YYY user group
Groupdel YYY Delete a group,,, note that sudo is required

Cat/etc/group

Groups Laowang: View all user groups that Laowang belongs to

Usermod-g YYY Laowang Add the old king to the YYY group

Usermod-a-G xxx Laowang add Lao wang to XXX group

-G and-g,-g specify the default group

Useradd create a new user without sudo, or switch to root, need to add this user to ADM, sudo group inside can


chmod permissions to modify files

U: Owner
G: Same group
O: Others
A: all, i.e. U, G, O

+ Add Permissions
-Remove Permissions
= Set Permissions

R: Read------> corresponding number is 4
W: Write------> corresponding number is 2
x: Execution------> corresponding number is 1

chmod 777 folder, only modify the folder permissions to 777, will not modify the permissions of the file inside

-R modifies permissions for all files and folders within the folder (recursive)

Understanding: Mount Mount Commands

Vi
From command mode---Edit mode: I, A, O, I, A, O
----from edit mode command mode: ESC
From the command mode----the last line mode: Enter a colon, that is, shit+;

Last-line mode:
W Save
Q exit
! Forced

Commonly used for:
Wq save exit, equivalent to X (lowercase x),,, also equivalent to shit+2 z in command mode
q! Do not save exit

Command mode:
HJKL control up and down function
M Middle Position
L The last line of the current screen
YY Copy, 8yy: Indicates copying 8 rows from the line where the current cursor is located
P Paste
DD Cut, 8DD: Cuts 8 lines from the line where the current cursor is located

U undo
Ctl+r Anti-Revocation

G to the last 1 lines
15G means jump to line 15th
1G means jump to line 1th

GG Jump To line 1th

Cloud disk information:http://pan.baidu.com/s/1jIR2ir0

"Linux Basics" linux basic command line learning notes

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.