1. Display the currently used Shell:echo ${shell}
Example: [[email protected] ~]# echo $SHELL
/bin/bash
2. Displays all shell:cat/etc/shells used by the current system
Example: [[email protected] ~]# Cat/etc/shells
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh
3. Enable internal command: Enable CMD
Example: [[email protected] ~]# enable PWD
Disable internal command: enable-n cmd
Example: [[email protected] ~]# enable-n pwd
To view all disabled internal commands: Enable-n
Example: [[email protected] ~]# enable-n
Enable-n Echo
Enable-n pwd
4. View Path: which-a | --skip-alias; Whereis
Example: [[email protected] ~]# Whereis bash
BASH:/bin/bash/usr/share/man/man1/bash.1.gz
6. Distinguish whether the command is an internal or external command: type
Example: [[email protected] ~]# type RM
RM is aliased to ' rm-i '
[[Email protected] ~]# type echo
Echo is a shell builtin
7. External command cache table: hash
Hash Display Hash Cache
Hash-l display hash cache, can be used as output
Hash-p path name alias the command full path from path to name
Hash-t name path in the print cache
hash-d name clears the name cache
Hash-r clearing the cache
8. Command aliases
Displays all available command aliases for the current shell process: Alias
Example: [[email protected]/]# alias
Alias cp= ' Cp-i '
Alias l.= ' ls-d. *--color=auto '
Alias ll= ' Ls-l--color=auto '
Alias ls= ' ls--color=auto '
Alias mv= ' Mv-i '
Alias rm= ' Rm-i '
Alias Which= ' Alias | /usr/bin/which--tty-only--read-alias--show-dot--show-tilde '
9. Define the alias name, which is equivalent to executing the command value
Alias Name= ' VALUE '
Example: [[email protected]/]# alias c= ' cd/etc/'
[[Email protected] etc]# C
Revoke alias: Unalas
Unalias [-A] name [name ...]
-A cancels all aliases
10. Date and Time
Display and set system time date
Example: [[email protected] etc]# Date
Fri Jul 22:30:04 CST 2018
-d< string: Displays the date and time that the string refers to. Double quotation marks must be added before and after strings;
-s< string;: Sets the date and time according to the string. Double quotation marks must be added before and after strings;
%c Date and time
11.hwclock, clock: Display hardware clock
Example: [[email protected] etc]# Hwclock
Sat Jul 2018 12:41:02 AM CST-1.017374 seconds
[Email protected] etc]# clock
Sat Jul 2018 12:41:07 AM CST-0.875766 seconds
-s,--hctosys with hardware clock, correct system clock
-w,--SYSTOHC Correct the hardware clock
Display calendar: Cal-y
12. Shutdown: Half, poweroff, init0
Restart: reboot, INIT6
-f: Force, do not call shutdown
-p: Disconnect the power supply
shut down or restart: Shutdown
shutdown [OPTION] ... Time [MESSAGE]
-r:reboot
-h:halt
-c:cancel
time: Unspecified, default equivalent to +1
now: Immediately, equivalent to +0
+m: Relative time notation, after a few minutes; for example, +3
hh:mm: Absolute time indication, specify time
13. Show active users who are currently logged on: WhoAmI
Example: [[email protected] etc]# WhoAmI
Root
14. All current logon sessions of the system: WHO
W: all current login sessions and actions done by the system
Example: [[email protected] etc]# who-w
Root + tty1 2018-07-27 13:12
Root + pts/0 2018-07-27 21:11 (192.168.180.1)
Root + pts/1 2018-07-27 21:58 (192.168.180.1)
15. Echo Function: Echoes
Syntax: Echo [-nee][string]
-E activating escape character
Example: [[email protected] etc]# echo-e ' Hello\tword '
Hello Word
16. Bracket extension: {}
{A, B} {c,d} AC ad BC BD
17 Command line history: Hitory
Example: [[email protected] etc]# history
1 ifconfig
-C: Clears the current History command;
-A: Writes the command in the history command buffer to the history command file;
-r: Reads commands from the history command file into the current History command buffer;
-W: Writes the current History command buffer command to the history command file.
18. Help command: Helper and man
Syntax Help (optional) (parameters)
Man (option) (parameter)
19. Show current working directory: PWD
Example: [[email protected] yum]# pwd
/etc/yum
-p Display True physical path
-L Show link path (default)
20. Change Directory CD
Example: [[email protected] yum]# cd/etc/
[[email protected] etc]#
switch to Parent directory: CD.
switch to the current user home directory: CD
Switch to the previous working directory: CD-
21. List contents: ls
Usage: LS [options] [Files_or_dirs]
-A contains hidden files
-L Display additional information
-R directory recursion through
-id Directory and Symbolic link information
-1 File Branch display
-s sort from large to small
-T Sort by mtime
-U with-t option, display and press atime new to old sort
-u display in directory store order
-x Sort by file suffix
Example: [[email protected]/]# ls
Bin etc lib64 Misc opt sbin sys var
22. View file status, three timestamps: stat
Example: [[email protected] etc]# stat passwd
Access:2018-07-27 14:06:51.178250316 +0800
Modify:2018-07-27 14:05:33.695243595 +0800
Change:2018-07-27 14:05:33.696243597 +0800
Access time: Atime, reading the contents of a file
Modify Time: Modified, Mtime, change file contents (data)
Change time: Changing times, ctime, meta data changes
23.touch command:
Touch [OPTION] ... FILE ...
-A changes only atime and CTime
-M only changes mtime and CTime
-T [[[CC]YY]MMDDHHMM[.SS] specifies timestamps for atime and Mtime
-C If the file does not exist, it is not created
24. Copying files and directories: CP
-I: Tips before overwriting
-N: Do not overwrite
-r,r: Recursively copy directories and all internal content
-A: Archive, equivalent to-DR--preserv=all
-d:--no-dereference--preserv=liks do not copy source files, only link names are copied
--preserv[=attr_list]
Example: [[email protected]/]# cp-r/etc/passwd/home
[Email protected]/]# ls/home/
passwd python test User6 Zhang
25. Moving and renaming files: MV
Common options:
-I: Interactive
-F: Mandatory
Example: [[email protected]/]# MV/HOME/PASSWD/HOME/PW
[Email protected]/]# Ls/home
PW python test User6 Zhang
26. Delete: RM
Common options:
-I: Interactive
-F: Force delete
-R: Recursive
Example: [[email protected]/]# RM/HOME/PW
Rm:remove regular file '/HOME/PW '? Y
27. Show Directory tree: Tree
-D: Show only directories
-L level Specifies the number of levels to display
-P Pattern: Displays only paths that are matched by the specified pattern
Example: [[email protected]/]# tree-l 1/etc
/etc
├──abrt
├──acpi
├──adjtime
28. Create Directory: mkdir
-P: exists in no error, but can automatically create the required directories
-V: Show more information
-M MODE: Specify permissions directly when creating a directory
Example: [[email protected] ~]# MKDIR-PV./a/b/c
mkdir:created directory './a '
mkdir:created directory './a/b '
mkdir:created directory './a/b/c '
29. Delete Empty directory: RmDir
-P: Recursive deletion of the parent empty directory
-V: Show more information
Example: [[email protected] ~]# RMDIR-PV./a/b/c
Rmdir:removing directory, './a/b/c '
Rmdir:removing directory, './a/b '
Rmdir:removing directory, './a '
Rmdir:removing directory, '. '
Rm-r recursively delete a directory tree
30. Hard Links: Different file paths point to the same inode
ln filename [linkname]
Example: [[email protected] ~]# ln abc.txt./test
31. Soft Connect: The link path does not point to the inode, but instead points to the original path (string)
ln-s filename [linkname]
Linux basic commands