Linux commands:
An instruction or program used to implement a certain type of function.
The execution of the command depends on the interpreter
Shell (interpreter) system default interpreter for/bin/bash
Execution process:
User Send command-interpreter-kernel-hardware
Mount Command:
Mount is to install/CD/DVD/partition/NAS/u disk and other network devices installed under a Linux directory, the various command tools to access the Linux directory to operate these devices.
Format: Mount device path mount point directory
Example: Mount/dev/cdrom/opt to mount the optical drive device to the/OPT
Ls/opt viewing content as CD-ROM contents
Uninstall command:
Format: Umount mount point Directory
Example: umount/opt
Ls/opt no content after viewing because the optical drive device has been uninstalled.
Common tips:
[Email protected] opt]# umount/opt
Umount:/opt: Target busy.
(In some cases, by lsof (8) or fuser (1), you can
Find useful information about processes that use this device)
Reason: Because you are now in a position under the/OPT, the system will think that someone is using. So the uninstallation is unsuccessful.
Output of the redirect command:
Overwrite redirects >
Append redirect >>
For example:
[[email protected]/]# hostname >/opt/1.txt output host name to 1.txt
[Email protected]/]#
[[email protected]/]# cat/opt/1.txt view 1.txt content
Localhost.localdomain
[Email protected]/]# ifconfig >>/opt/1.txt
Outputs the contents of the ifconfig to 1.txt, but does not overwrite the original content in 1.txt
Use wildcard characters:
For indeterminate document names, represented by special symbols
* Any number of characters
? Single character
[A-z] multiple characters or one in a continuous range, if none is omitted,
{x, y, Z} multiple sets of different strings, full match
For example:
ls/etc/*.conf etc under the document ending with. conf
Documents starting with TTY under ls/dev/tty* Dev
Ls/dev/tty? A document that starts with a TTY and has only one character behind the TTY.
Ls/dev/tty[0-7] Dev starts with a TTY and the next character is a number within 0-7
ls/dev/tty{3,7,14} dev under Tty3, Tty7, TTY14
Case:
List/dev/tty20 to/dev/tty30
[[email protected] opt]# ls/dev/tty{2[0-9],30}
/dev/tty20/dev/tty22/dev/tty24/dev/tty26/dev/tty28/dev/tty30
/dev/tty21/dev/tty23/dev/tty25/dev/tty27/dev/tty29
To create a directory:
Format: mkdir-p/path/directory Name
For example
[[email protected]/]# mkdir-p/opt/a/b/c/d-p is created together with the parent directory
[[email protected]/]# ls-r/opt-r means recursive display
/OPT:
A
/OPT/A:
B
/opt/a/b:
C
/OPT/A/B/C:
D
/OPT/A/B/C/D:
To create an empty file:
Touch/opt/1.txt create 1.txt under opt
echo Command: Echo content
For example:
[[email protected]/]# echo Daskjfkjsad output the content directly on the command line
Daskjfkjsad
[[email protected]/]# echo 123 >/opt/2.txt 123 output to 2.txt and create 2.txt
[Email protected]/]#
[Email protected]/]#
[Email protected]/]# ls/opt/
1.txt 2.txt A
[[email protected]/]# Cat/opt/2.txt View the contents of/opt under 2.txt
123
Home directory:
~ Indicates home directory
~user represents the user's home directory
/root Administrator's Home directory
/Home Store user's house directory
For example
[Email protected]/]# Ls/home
Lisi Zhangsan
[[email protected]/]# useradd WANGWU Create Wangwu user
[[Email protected]/]# CD ~wangwu go to Wangwu home directory
[Email protected] wangwu]# Ls/home
Lisi Wangwu Zhangsan
cp-replication
Format: CP [option] source file destination Path
Common Command options:
-R Recursive replication directory must have this option
-P Keep the permissions modification time of source files and other properties unchanged
For example:
[[email protected]/]# cp-r/boot//opt/copy/boot to/opt
[Email protected]/]# ls/opt/
1.txt 2.txt a Boot
rm-Delete
Format: RM [options] File or directory
-R Recursive Delete
-F Force Delete
[Email protected]/]# ls/opt/
1.txt 2.txt a Boot
[[email protected]/]# rm-rf/opt/boot Force Delete/opt/boot
[Email protected]/]# ls/opt/
1.txt 2.txt A
mv-Move/Rename
Format MV source file destination Path
For example:
[Email protected]/]# ls/opt/
1.txt 2.txt A
[[email protected]/]# mv/opt/1.txt/opt/a move 1.txt to opt/a
[Email protected]/]# ls/opt/
2.txt A
[Email protected]st/]# ls/opt/a
1.txt
Renaming
For example:
[[email protected]/]# mv/opt/a/opt/c renamed a C to opt
[Email protected]/]#
[Email protected]/]# ls/opt/
2.txt C
Dahne-linux Foundation-day02