Some of the basic commands under Linux

Source: Internet
Author: User

Some of the basic commands under---------------------------------------------------------VI-----------

I is the beginning of the line and editing

A is to the end of the line and edited;

KJHL to move commands for up and down cursors, respectively

DD to delete the contents of the line, the cursor remains in the bank;

DD to delete a row, the cursor jumps directly to the previous line;

U to undo just the action

J to merge the upper and lower lines

R replaces the file currently executed by the cursor

R to enter the Replace command, the input text will replace the character of the cursor. ESC will not exit the replacement state

X is the character where the cursor is deleted.

CW modifies the word at the cursor location, which is deleted from the starting position and immediately enters the insertion mode;

DW is to delete a word according to the cursor does not go into the insert;

o Insert a blank line after the cursor line

o To insert a blank line before the cursor is in the row

FS See the first S character after the cursor is located at the beginning of the search cursor

/BCA Quick Find BCA n down is continue to find the next bca,n return to the previous

: Set NU Displays line number

: Set Nonu does not display line numbers

: 7 is jumping to line 7th

G Fast to the end of the line, plus o can be quickly to the end of the document and continue to edit.

Nyy to copy n rows starting from the cursor. If n is not filled in, a row is copied by default

p to paste the contents of the current copy

:%s @[email protected]@g Replace all ACCD with abc,@ as delimiter;

:%s @[email protected]@[email protected] Replace all ACCD case-insensitive with ABC;

DF Check the file system for disk space usage

ZZ Save exit; Zq do not save exit: X Save exit: q! force quit.


------------------------------------------------------Some of the other basic commands---------------

Use these two to create a new user

[Email protected]/]# Useradd test01

[Email protected]/]# passwd test01

When I change the password of the test01 user under root privileges can be modified directly, other users cannot modify other user rights

[Email protected] ~]$ passwd test02

Passwd:only root can specify a user name.

Delete a user under an administrator user

Userdel test02


Mkdir/u02 creating the U02 folder under the root directory

Mkdir-p/u02/test1 cascading add-on directory

DF checks the disk space consumption of the file system.

Cal Calendar

Date Dates

Du-sh/home View Home This directory size


ln file2 test_dir/file5 Hard connection under the current file under File2 and test_dir/file5, hard connection modification 5 after 2 has also been modified, but delete 2 will not delete 5, delete 5 will not delete 2

Ln-s file2 test_dir/file5 Soft Connect is similar to a Windows shortcut, deleting 2 will not be 5.

CD ~ Return home Directory

Rm-r means delete directory rm-rf force delete directory


Related Uses of tar

[Email protected] u02]# TAR-CF test.tar./TEST01/TEST02/1 Pack 1 files under test01 under test02 current path

[[email protected] u02]# tar-cf Test.tar./TEST01/TEST02/1 2 Pack 1 and 2 files under test01 under test02 under current path

[[email protected] u02]# TAR-TVF Test.tar view u02 written Test.tar file specific content

[[email protected] u02]# tar-xf Test.tar Export the contents of the Test.tar, including the path, if the path itself does not exist will be created

[Email protected] u02]# tar czvf test.tar.gz./TEST01/TEST02/1 Package 1 files under test01 under test02 under current path and compress

[[Email protected] u02]# tar xzvf test.tar.gz restore and decompress test.tar.gz

[Email protected] u02]# tar TVF Test.tar | More

RPM command

Rpm-i (rpm-install) installation mode

Rpm-u (Rpm-upgrade) Upgrade mode

RPM-E (rpm-unstall) Uninstall installation mode

Rpm-q (rpm-query) query mode

RPM-V Test mode


chmod chgrp chown Command usage

Chgrp Modifying a group to which a file belongs

Chown Modifying file Owners

chmod modifying file properties


Chgrp [-cfhrv][belongs to group] [file or directory ...]

-C is similar to-V, but v means that the result should be displayed anyway, c means that only after the group is changed.

-h only modifies the symbol-connected files without altering any other related files.

-R means recursive processing

Chgrp-r Test Test.txt


Chown usage is similar to CHGRP

Change the group of test.txt files to test


Chmod is to modify the file properties

U user's current permissions

Current permissions for Group G

o Other users ' current permissions

$ chmod u+x file adds execute permission to the owner of file

$ chmod 751 file assigns read, write, execute (7) permissions to the owner of file, assigns read, execute (5) permissions to the group where the file resides, and assigns permissions to other users to execute (1)

$ chmod Another form of the example on U=rwx,g=rx,o=x file

$ chmod =r file to assign Read permissions to all users

$ chmod 444 File above example

$ chmod a-wx,a+r File above example A=all

$ chmod-r u+r Directory recursively reads permissions for the owner of all files and subdirectories in directory directory

$ chmod 4755 Sets the ID to assign read, write, and execute permissions to the owner, assigning read and Execute permissions to the group and other users.


Some specific meanings of the number of permissions are as follows

R W X

0 0 0 0

0 0 1 1

0 1 0 2

0 1 1 3

1 0 0 4

1 0 1 5

1 1 0 6

1 1 1 7


A|b is a pipe character, I execute B on the basis of a after I finish executing a.


Which view the location of the executable file. For example which ifconfig find the location of Ifconfig


grep shows the number of rows that match the criteria

$ grep ' test ' d*

Displays all rows that contain test in a file that begins with D.

$ grep ' test ' AA bb cc

Displays the line that matches test in the aa,bb,cc file.


WC [Options] File ...

-C Count bytes.

-L counts the number of rows.

[Email protected] u02]# Wc-l 1

7 1

[Email protected] u02]# wc-c 1

267 1

Respectively in 1 This file has 7th numbers and 267 bytes


Diff report Text Differences in content

Vimdiff Visual Report text differences, display more clearly. After entering Vimdiff, you can enter: qa! do not change the exit


>file2 emptying File2

Find/home-name file1-exec rm-rf{}\;

Find/home-name file1-ctime 2-exec rm-rf{}\; Find the file name File1 in the home directory delete data two days ago

Find/home-name file1-ctime-2-exec rm-rf{}\; In the home directory, look for files with the name file1 to delete data for the previous two days


ECHO ABC >file2 insert ABC to File2

Echo ABC >>file2 insert 2 lines ABC to File2


Alias setting aliases


Set view Global environment variables

ENV View Current Environment variables

--Global settings file

/etc/profile

/etc/bashrc

--User settings file

~/.BASHRC--can be used directly

~/.bashrc_profile--come in and have source read the relative file


Some of the basic commands under 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.