Some common basic Linux operation instructions

Source: Internet
Author: User
Tags chmod

Review of the way to share my knowledge, although not what the technical sharing of cattle, just some foundation, the foundation of the technology slowly improved! Together to encourage together!

The specific VI and VIM command set too much, after the essay I will share, there is no need to remember all, remember the usual good, the great God will not be all can remember. Don't worry about it.

1. Directory Switching commands

A graphical interface and mouse can be used in window to arbitrarily switch directories that need to be entered, but Linux must switch directories via the CD command.

command:the CD directory name switches to the specified directory

command:CD. /switch to the previous level directory

command:CD ~ Switch to user home directory

command:CD-Switch to the previous directory

2. Order of operation of the catalogue (add and revise)

(1) View catalogue (check)

command: ls [-al] can see all directories and files in this directory

Example:

command: ls-a can see all the files and directories in that directory, including hidden

Example:

command: Ls-l can see the details of all directories and files under this directory

Example:

Note:Ls-l can be abbreviated as LL

(2) Add directory operation (Increase)

Command:mkdir the name of the directory to be created

Example:

(3) Search catalogue (check)

command: Find Directory Parameters

Example: Find/-name ' test ' finds directories with directory name test under all directories

   Find/-name ' *test* ' finds all directories that contain the test keyword

(4) Modify the directory name (change)

command: MV Directory name new directory name

Example: use the test directory created above to modify with the MV Test newtest Command

(5) position of moving target--shear (change)

Command:MV Directory name directory new location

Example: cut the Newtest directory to/usr and use the mv newtest/usr

Note:the MV syntax can not only cut the directory, but also perform cutting operations on files and compressed packets.

(6) Copy directory (change)

command:cp-r directory name directory copy target location-----R for recursive copy

Example: Copy the newtest in the USR directory to the Games directory, Use cp-r/usr/newtest/games

Note:the CP command can not only copy directories but also copy files, compress packages and so on, copy files and compress packages without writing -R recursion

(7) Deleting a directory (delete)

command:RM [-RF] Directory

Example: Delete the newtest under/usr and enter/usr to use rm-r newtest

Example: Delete newtest under/games without asking for forced deletion, use rm-rf newtest under/games

Note:RM can not only delete directories, but also delete other files or compressed packages, in order to enhance the memory of everyone, regardless of the deletion of any directory or files, directly using the RM-RF directory/File/compression Package

(Updated again tomorrow)

2. Operation Order of the file (add and revise)

(1) Creation of files (increase)

command: Touch File name-----empty file

Example:

(2) Viewing of files

command: cat/more/less/tail File

Example: use cat to view the/etc/sudo.conf file to display only the last screen of content

Example: use more to view the/etc/sudo.conf file, you can display the percentage, the carriage return can be one line down, the space can be a page down,Q can exit view

Example: using less to view the/etc/sudo.conf file, you can use the PgUp and PgDn on your keyboard to page up and down,Q to end the view

Example: use tail-10 to view the following 10 lines of the/etc/sudo.conf file, CTRL + C ends

Note: The command tail-f file can be dynamically monitored for a file, such as a tomcat log file , which will change as the program runs and the log can be used tail-f The change of catalina-2016-11-11.log monitoring text

(3) Modify the contents of the file (change)

command: Vim file

Example: Edit The Aaa.txt file under/test, using Vim aaa.txt

but it is not editable at this time, because in command mode, click the keyboard i/a/o into the editing mode, you can edit the file

when the edits are complete, press the ESC, return command mode

At this point, although the file has been edited, but not saved, you need to enter a colon: Enter the bottom line mode, the bottom row of the input WQ representative write content and exit, that is, save; the input q! represents force exit is not saved.

Summarize:

Vim Editor is a powerful component of Linux, is a strong version of the VI editor, VIM Editor commands and shortcuts have a lot of, but here do not elaborate, we do not have to study very thorough, using VIM to edit the way the file is basically used.

about vim use process:

in practical development, the main function of using the VIM editor is to modify the configuration file

vim file------> enter file-----> Command mode------> Press I to enter edit mode-----> Edit File -------> Press ESC to enter the bottom line mode-----> Input: wq/q!

(4) Deletion of files (deleted)

same directory Delete: Memorize rm-rf files can

4. Action commands for compressing files (1) packaging and compressing files

Packaged files in Linux generally end in. tar, and compressed commands typically end in. gz.

In general, packaging and compression are carried out together, packaged and compressed files with the suffix name . tar.gz.

command:TAR-ZCVF Package Compressed file name to package compressed files

Where:z: call the gzip compression command to compress

C: Packaging files

V: Show the running process

F: Specify file name

Example: Package and compress all files under/test compressed package with the specified name xxx.tar.gz

TAR-ZCVF xxx.tar.gz aaa.txt bbb.txt ccc.txt

or:TAR-ZCVF xxx.tar.gz/test/*

(2) Unzip the package (Focus)

command: tar [-XVF] Compressed file

Where:x: Representative Decompression

Example:

Extract the xxx.tar.gz under/test to the current directory TAR-XVF xxx.tar.gz

Example: extract the xxx.tar.gz under/test to the root directory/usr

5. Other commands (1) Show current location pwd

(2) Search command

command:grep to search for a string of files to search for

Example: Search for the line in the/usr/sudu.conf file that contains the string to

Example: search The/usr/sudu.conf file that contains the string to the line to highlight

(3) Piping command

Command:| Enter the output of the previous command as the current directory

Example: view A process that includes the system string in all processes in the current system

(4) View process

command:ps-ef

Example: viewing a process running in the current system

(5) Kill process

command:pid of the kill-9 process

(6) network communication command

View network card information for the current system:ifconfig

to view a connection to a machine:ping

to view the port usage of the current system:Netstat-an

6. Permissions command for Linux

permissions are Important concepts in Linux, each file/directory and so on have permissions, through the ls-l command we can view the file or directory under a directory permissions

Example: Ls-l in a random directory

The information for the first column is explained as follows:

Type of File:

D: Representative Directory

-: Representative file

L: Represents a link (can be considered a shortcut in window)

the following 9 bits are divided into 3 groups, each with 3 positions, each representing the owner's rights, the permissions of the user in the same group as the current user, and the permissions of the other users.

R: The delegate permission is readable, R can also be represented by the number 4

W: Delegate permission is writable, W can also be represented by the number 2

X: The delegate permission is executable, X can also be represented by the number 1

Owner (user)

Groups (group)

Other users

R

W

X

R

W

X

R

W

X

4

2

1

4

2

1

4

2

1

command to modify permissions for a file /directory: chmod

Example: Modify the permissions of the Aaa.txt under/test to have all permissions for the owner, the group that belongs to the host has read and write permissions,

Other users have read-only permissions

chmod u=rwx,g=rw,o=r Aaa.txt

The above example can also be represented using a number:

chmod 764 Aaa.txt

Some common basic Linux operation instructions

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.