Necessary common commands for Linux (embedded development)

1. Open the terminal and exit the terminal

Ctrl+shift+‘n’ :打开一个同路径的终端;
Ctrl+alt+‘t’ :打开一个以主目录为路径的新终端;
Ctrl+‘d’ :关闭终端;
Exit命令也可以退出终端。

2. Qingping

Shortcut key: ctrl+'l'
terminal command: clear screen command.

3. Vi editor

3.1 vi (vim) vi (vim) file name enters the command line mode
three modes : command line mode, edit mode, bottom line mode
Vi opens the file and enters the command line mode;
in the command line mode, use i/a/o to enter Edit mode;
use shift+ in the bottom line mode: you can enter the bottom line mode;
in edit mode, use esc to enter and exit to the command line mode, and shift+: switch to the bottom line mode.
Command line mode: copy, paste, cut, delete, cursor movement.

Copy:
yy: copy one line; nyy: copy n lines;
delete or cut:
dd: delete or cut one line; ndd: delete or cut n lines;
paste, undo:
p: paste; u: undo; ctrl+'r ': Undo;
Cursor positioning gg:
Cursor positioning at the beginning of the file; G: Cursor positioning at the beginning of the last line.
Edit mode: i/I a/A o/O to enter edit mode.
Bottom row modes: save, quit, replace, copy
save : w; quit : q; save and quit : wq, :x;
force quit : !q; split screen : vsp;
highlight : /world; remove highlight : noh;
replace all world1 in the file with world2: %s/world/world/g
%: full text; s: replace all; g: all in one line.

4. View files ls: list the files in the current path

Ls-i: check the inode number of the file;
ls-a: list all the files under the current path;
Ls-lh: check the detailed information of the file, the file size has a unit;
Ls-l: check the detailed information of the file.

5. Change the path cd directory name: switch to the specified directory

Cd : switch to the user's home directory; cd/home/hq: switch to the user's home directory;
Cd ~: switch to the user's home directory;
Cd/: switch to the root directory; cd -: switch to the path of the last operation;
Cd. :Switch to the current path; cd...:Switch to the previous directory.

6. Create files and folders

  1. Create a directory file
    mkdir: Create a directory file
    Mkdir -p directory 1/directory 2/directory 3... Create a multi-level directory
  2. Create common file
    3.touch file name (need to specify suffix): create normal file
    touch file 1 file 3 file 3... create multiple normal files.

7. Delete the file rm

rm file name: delete an ordinary file
rm directory name -p: delete the directory file.

8. copy cp

cp file name new file name: copy the file under the current path;
cp file name path: copy the file to the specified path
Note: If the folder is copied, the -r option needs to be added.

7. Move or rename mv

mv filename path: move the file to the specified path;
mv filename new filename: rename the file.
Note: mv does not need to add -r to the operation of the folder.

Guess you like

Origin blog.csdn.net/qq_47023150/article/details/123294641