Linux basic Command 1
Echo command: echo
Built-in command
Echo "How are you"
Echo "$SHELL" weak application, displaying values in variables
/ bin/bash
Echo'$SHELL' strong reference type, does not display values in variables
$SHELL
-n: newline characters are prohibited. Newline characters are automatically added by default.
-e: escape characters are allowed
\ n: line break
\ t: tabs
Echo-e "\ n"
Show the path to the file: which
Which [OPTION] COMMAND
-- skip-alias does not display aliases
Whereis:locate the binary,source,and manual page files for a COMMAND
Whatis
Use the mkwhatis command to change all the help manuals and corresponding keywords on the current system
Create a database
Linux will automatically run and create this database
System management class commands:
Power off:
Halt,poweroff,shutdown,init 0
Shutdown is a safe shutdown mode.
Reboot: reboot,init 6 show who is logged on and what they are doing shutdown related to user login: whalt,poweroff,reboot whowhoami whoami: see who the current user is who: show which users are currently logged in to the system w: shutdown or restart command: forced shutdown of the system, not recommended. Do not save. -p cut off the power supply. Shutdown shutdown [OPTION]... TIME [MESSAGE]-r reboot-h halt cut off the power supply. -c cancel cancels shutdown TIME: now 0 is now + m: indicates the hh:mm absolute time m minutes after the command was submitted. MESSAGE: content of warning
File system of Linux
Root file system (rootfs):
Root filesystem
LSB:FHS (FileSystem Heirache Standard) / etc,/usr,/var,/root,/home,/dev / boot: boot files are stored in the directory, kernel files (vmlinuz), boot loader (bootloader,grub) are stored in this directory / bin: basic commands for all users: cannot be associated to a separate partition, programs used for OS startup are placed here / sbin: basic commands for managing classes Cannot be associated with a separate partition, the program used to start OS is placed here. / lib: basic shared libraries and kernel modules, and kernel module files (/ lib/modules); / lib64: dedicated to x86664 basic shared libraries and kernel modules, and kernel module files; / etc: configuration file directory (plain text files) / home/USERNAME: home directory / root: administrator's home directory / media:Mount point for removeable media / mnt:Mount point for temporarily media / dev:Device files Device files and special files b:block Device-- randomly accessible c:character device-- must sequentially access the installation location of / opt Add-on application software packages third-party applications. / srv: data used by services running on the system / tmp: temporary file storage location / usr: general independent partition universal shareable read-only data must have the following directory bin: the program that stores the basic functions of the system, not the header file storage location of the sbin lib lib64 include:c program at startup share: structured independent data For example, src such as doc,man: location of source code local:Local hierachy Installation location of third-party applications, currently the most common You can also mount to a stand-alone file system bin,sbin,lib Lib64 / var: Hierarchy frequently changing data file storage location cache: application cache data directory lib: application state data local: dedicated to storing variable data for applications under / usr/local lock: application lock files log: log files opt: dedicated to / opt Variable data run: process-related data in operation Commonly used to store PID files for processes spool: buffer pool tmp: temporary file storage location during the second restart of the system / proc: pseudo file system, used to output the kernel virtual file system related to process information. / sys: pseudo file system, a virtual file system used to output information about hardware devices on the current system. The storage location of information such as security policies related to selinux:security enhanced Linux,selinux. Components of the application on Linux binary program: / bin,/sbin,/usr/bin,/usr/sbin,/usr/local/bin,/usr/local/sbin library file: / lib,/lib64,/usr/lib,/usr/lib64,/usr/local/lib configuration file: / etc,/etc/directory,/etc/local/etc help file: / usr/share/man,/usr/share/doc, / usr/local/share/man File type under / usr/local/share/docLinux:-(f): normal file d: directory file b: block device: C: character device l: symbolic link file, soft connection file p: pipe file S: socket file; socket file
Basic features of bash:
(1) order History
History
Environment variables:
HISTSIZE: number of command history entries:
HISFILE: ~ / .bash_history
The number of entries recorded in the HISFILESIZE; command history file
History-d OFFSET deletes the history of the specified entry-c empties history #: displays the most recent number history-ahistory append; manually appends the command history of the current session buffer to the history file. Call the last command in history:!!: the last command! #: command #! string: the last parameter of the last command called by a recently established history command at the beginning of a string! $: previous command: cat / etc/fstab current command: ls-l! $# is equivalent to ls-l / etc/fstab ESC . Controls how command history is recorded: environment variable: HISTCONTROL ignoredups: ignore duplicate commands Consecutive and same ignorespace: ignore all commands that begin with white space ignoreboth: both of the above take effect to modify environment variables: (valid only for current shell and child processes) export variable name =. (2) Command complements bash execution command: internal command: build in external command : search the path defined by the $PATH environment variable From left to right, search each path for a file named by the user's given name, and the first thing you find is the command to be executed. (3) path completion (4) Command line expansion ~: expand to user's home directory ~ USERNAME: expand to USERNAME home directory {}: can carry a comma-separated list and expand it into multiple paths. / tmp/ {aforme b} = / tmp/a,/tmp/b example: (1): how to create / tmp/x/y1,/tmp/x/y2,/tmp/x/y1/a, / tmp/x/y1/b,/tmp/x/y2/a,/tmp/x/y2/b mkdir-p / tmp/x/ {y1 Magi y2} / {aforme b} (2): how to create Xonomer How to create / tmp/bin,/tmp/sbin,/tmp/usr,/tmp/usr/bin, / tmp/usr/sbin mkdir-p / tmp/ {bin,sbin,usr/ {bin,sbin}} (5) the execution result status of the command bash uses the special variable $? Saves the execution status results of the most recent command. 0: successful 1-255: failed
Directory management class commands:
Cd pwd,ls
Mkdir rmdir, tree
Mkdir [option] / path/to/somewhere / path/to/somewhere2
You can create more than one directory at a time with spaces.
-p: even if it exists, it does not report an error. Create a parent directory automatically, if necessary.
-m mode, which specifies permissions directly when creating a directory.
Rmdir [option] / path
Only empty directories can be deleted
-p: delete the directory and trace it back to the parent directory that is not empty
Tree: tree structure displays-d displays only directories-L: how many levels are displayed at most.
File View Class Command
Cat,tac
More,less,tail,head
More [option] [file] less [option] [file] head [option] [file]-c #: specify the first # bytes-n #: specify the first # lines; the default is that the first ten lines tail [option] [file] are similar to head-f to continue tracking new appends to file. Viewing log files is particularly useful
Timestamp management tool for files
Touch
File: metadata,data
View file status: stat
Three timestamps:
Access time,atime: access time, which is updated as long as it has been accessed by an executable program
Modify time,mtime: modify the time, change the contents of the file, update this data
Change time ctime: change the time, change the metadata, update the data, and the metadata contains these three timestamps
So, if atime and mtime change. So ctime has changed.
Touch [option] [file]
The default touch changes the atime, mtime, ctime of the file.
-a: only change the visit time
-m: only change the modification timestamp
-t: specifies the timestamp
Touch-m-t 201909011234666 / etc/fstab
-c: if the file does not exist, the file is not created.