Linux shell commands
- mkdir
mkdir test : create a test directory (folder) in the current directory (folder)
mkdir –p test/aa/bb/cc/dd : create multiple folders at once - rmdir
rmdir test: delete the test directory (folder)
rmdir –p test/aa/bb/cc/dd: delete dd recursively, if cc is empty at this time, delete it, and so on - pwd
pwd: show the current path - cd
cd: go back to the home directory
cd /test: enter the test directory - ls
ls: View files and other information in a directory - cp
cp file1 file2: Copy the file file1 to file2
cp file1 dir1: Copy the file file1 to the directory dir1, the file name is still file1
cp /tmp/file1: Copy the file file1 under the directory /tmp to the current directory, the file The name is still file1
cp /tmp/file1 file2: Copy the file file1 under the directory /tmp to the current directory, the file name is file2
cp –r dir1 dir2: Copy the entire directory - mv
mv file1 file2: rename file file1 to file2
mv file1 dir1: move filename file1 to directory dir1, filename still asks file1
mv dir1 dir2: change directory dir1 to directory dir2 - rm
rm file1: delete file
rm file with filename file1? : delete all files with 5 characters in the file and the first 4 characters are file
rm f*: delete all files whose file name starts with f - cat
cat file1.txt: view file1.txt in the current directory
cat file1.txt file2.txt>file3.txt: merge the contents of files file1.txt and file2.txt, and transfer the contents to file3.txt to save
using tail - f filename can track file changes in real time
cat file1.txt file2.txt>"file3.txt: merge the contents of file1.txt and file2.txt, and transfer the contents to file3.txt to save, the contents of file3.txt are not overwritten - help
cat --help: get branch of cat command - clear
clear:清屏 - chmod
is used to modify file permissions
Edit text files using vim
vi file: open the file, if there is no file, create it
in the vim editor:
i: change the mode to edit mode
esc: change the mode
: wq: save and exit