Linux Command 1 (learning Note 3) and linux Command learning note
Cainiao records.
1. Change the Host Name
The new hostname ln0491 changes the host name to ln0491 and then logs on to the new host name.
2. Create and delete folders
For example: create a data folder mkdir datals in the current path to view and delete the empty directory rmdir directory name rmdir data create a folder in the root directory/datamkdir/data to check whether the directory is successfully created ls-ld/data Delete non-empty directories rm-rf directory name r indicates deleting a directory, f stands for force. force deletion is not prompted. Recursively create the directory mkdir a/B/c-p to create a three-tier directory to create sub-directories. You can also create more directories, you only need to add-p to delete the multi-layer directory rm-rf a/B/c to view the directory structure tree a. If not, install yum install tree-y.
3. Create a file under the/data Directory
Touch/data/text.txt als/data view or enter the/data directory, then create cd/datatouch text.txt to create multiple files: touch 1.txt 2.txt 3.txt or touch later versions A, B, C, and D later. txt touch/data/later QPS, W, E, r,t, yearlier. txt later> c.txt redirection ehco> a.txt
4. Edit and view the File Content
Vi editor or vim
Vi test.txt write content in I edit mode Press ESC, enter: wq save and exit cat test.txt
Second
Echo "I am studying linux"> test.txt cat text.txt view one of the above numbers. The current file is cleared, and then echo "Hello linux"> test.txt 2 greater than numbers indicate appending content at the end of the file
Cat 3
Cat> test.txt clear file input content press Ctrl + c save cat> test.txt Append content at the end of the file press Ctrl + c save
Fourth
Cat> test.txt <EOF> ffffffffffffffds> fdsfsddddddddd> qqqqqqqqqqq> the EOF returns two big Yu numbers> if it is a big Yu number at the end of the hosts file, after it is cleared, write content between two EOF
The EOF can be any other flag character, which can be customized, but must appear in pairs.
cat >> test.txt <<FW> ++++++++++++++++++++> ===================> -----------------------> 111111111111> FW
Clear File Content
>test.txt
5. Clear Screen
Shortcut Key: Ctrl + L. you can skip the upper case or lower case.
6. View historical commands
Commands executed by history
VII. Copy (Copy command)
Copy test.txt to cp/data/test.txt/tmp/In the tmp directory/
Copy directory
Copy the data folder to the tmp directory cp/data/tmp/-ap parameters: -a or -- archive: the effect of this parameter is the same as that of the "-dpR" parameter specified at the same time.-p or -- preserve retains the attribute of the source file or directory, including the owner, group, permission, and time copy file cp filename1 filename2, copy filename1 and name it filename2. Add the parameter-f without any prompt when overwriting the renamed file. -R recursive processing: processes the files in the specified directory along with subdirectories. -R or -- recursive processing: All files in the specified directory are processed together with subdirectories.
Copying between different machines
The usage of the command scp between different machines is similar to that of the cp, but it is only executed between different machines. Copy a file to another machine: scp-rf filename1 username@bak.benxiaohai.com:/usr/local/apache/htdocs/bak the command above indicates to put the filename1 file (or folder) under the current directory) copy the username to the/usr/local/apache/htdocs/bak directory on the bak.benxiaohai.com machine.