Linux some basic command one (study note three)

Source: Internet
Author: User

Rookie record.

First, change the host name
hostname   the new hostname hostname  ln0491 changes the hostname to ln0491 log out and then log in, and it becomes the new host name
Second, create new folder and delete
For example: Create a new Data folder on the current pathmkdirdatals View Delete empty directoryrmdirDirectory namermdirdata creates a folder in the root directory/Datamkdir/data to see if the directory was created successfullyls-LD/Data Delete non-empty directoryRM-RF Directory name R means to delete the directory, f means the abbreviation for force, forcing the deletion, without prompting. To create a directory recursivelymkdirA/B/C-p Create a 3-level directory to create subdirectories, you can also create more layer directories, just add-p Delete Multi -level catalogsRM-RF a/b/C View directory structure tree A If it does not exist please installYum InstallTree-y
Third, create the file in the/data directory
Touch /data/text.txtals /Data View or enter //dataTouch Text.txt Creating multiple Files Touch 1 2 3 . txt or Touch {a,b,c,d}.txt Touch /data/{q,w, E,r,t,y}.txt greater than sign creation >> A.txt
Iv. editing files and viewing file contents

VI Editor or VIM

VI Test.txt Press I to edit mode write content Finish Press ESC, enter: Wq Save to exit Cat Test.txt

The second Kind

Echo " I am studying Linux  > test.txtcat  text.txt View one of the greater than sign will empty the current file and write echo" Hello Linux " >> test.txt 2 greater than sign to append content at the end of a file

The third type of cat

cat >+c save cat >>+c Save

Fourth type

Cat >> test.txt <<eof> ffffffffffffffffffds> fdsfsddddddddd> qqqqqqqqqqq> EOF back to is 2 greater than sign >> means to put 2 eof between the content regardless of how many lines are appended to the end of the Test.txt file if it is a greater than sign > indicates that the content is written to 2 EOF     

Where EOF can be any of the other flag characters, custom can be, but to appear in pairs

cat >> test.txt <<FW111111111111> FW

Empty file contents

Five, clear screen
Shortcut keys: Ctrl+l case can be written in the unfinished capital L or clear
Vi. Viewing history commands
The command that history has executed
Vii. copy (Copy command)
Copy the Test.txt to the TMP directory CP /data/test.txt/tmp/

Copy Directory

CP /data//tmp/-AP Parameters:     -A or--archive the     effect of this parameter and also specify "-dpr"  The parameters      are the same-p or--preserve    cp  filename1 filename2, copy the filename1 and name it filename2.    -f do not make any hints when overwriting the renamed file. -R  recursive processing, the files under the specified directory and subdirectories are processed together. -    R or--recursive  recursively handles all files in the specified directory with subdirectories.

Copy between different machines

SCP     The use of SCP is similar to that of CP, but it is run between different machines.    SCP -rf filename1 [email protected]:/usr/local/apache/htdocs/bak    above command indicates the Filename1 file (or folder) under the current directory Copy it as username to the/usr/local/apache/htdocs/bak directory on the bak.benxiaohai.com machine.

Linux some basic command one (study note three)

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.