Linux instructions (1) file/directory operations

1. Create a directory

mkdir
Format mkdir [OPTION]... DIRECTORY...
Options
    -p create recursively
    -v prompt when creating
example:
root@ubuntu:/home/eko/x# mkdir -pv a/b/c
mkdir: created directory 'a'
mkdir: created directory 'a/b'
mkdir: created directory 'a/b/c'

2. Create the file

touch originally meant to change the file time
touch [OPTION]... FILE...
例:
root@ubuntu:/home/eko/x# touch abc.txt

3. Delete files/directories

rm
rm [OPTION]... [FILE]...
Options:
    -f ignore nonexistent files and arguments
    -r delete recursively
example:
root@ubuntu:/home/eko# rm -rf x

4. Copy the file

cp (only allows copying one file to another or multiple files to a directory)
       cp [OPTION]... [-T] SOURCE DEST
       cp [OPTION]... SOURCE... DIRECTORY
       cp [OPTION]... -t DIRECTORY SOURCE...
Options
       -r recursive copy
       -f If the target file exists forcibly overwrite 
    -p keep the file owner 
    -a archive copy, often used for backup    example: Copy a file to another location # cp /etc/passwd /home/eko/x/passwd Copy multiple files to one directory # cp /etc/passwd /etc/issue /home/eko/x/

5. Move files/rename

mv       
       mv [OPTION]... [-T] SOURCE DEST
       mv [OPTION]... SOURCE... DIRECTORY
       mv [OPTION]... -t DIRECTORY SOURCE...
Options:
      -f force overwrite if target exists
example:
move files
# mv ./a.txt ../y/
Rename
# mv a.txt abc.txt

6. View the directory structure 

tree DICTORY
例:
# tree /home/eko

7. View text files

1. cat connect and display (multiple files can be connected)
     cat [OPTION]... [FILE]...    
Options:
    -n show line numbers
    -e show line terminators for each line

2. tac flashback display

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325112122&siteId=291194637