Under Linux, many of our operations are implemented by commands, and we'll explain the use of commands under Linux in the next step. The first thing to do is to use the command first to know his format:
The syntax format for linux commands is command options arguments, where options and parameters can be omitted. There are a variety of commands for Linux, with commands for the system itself, application commands installed, and commands for script execution.
Ls:list directory contents is used to list the contents of the directory,
ls/path/to/dir|file[Path] dir is the directory name file file name
[Email protected]_basic ~] #ls
Anaconda-ks.cfg Blank Gldt1210.png install.log.syslog tcpestd.sh
bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm Blankdir Install.log tcpestd1.sh vbird_server
Does not use a path, it displays the contents of the current directory
[[Email protected]_basic ~] #ls anaconda-ks.cfg where anaconda-ks.cfg is a file
Anaconda-ks.cfg
View the shell that is currently in use
[Email protected]_basic ~] #echo $BASH
/bin/bash
We operate the shell under the command line, we enter the command shell to submit the command to the kernel if the command is executable, then the kernel will return the execution results to us, in fact the shell itself has built-in commands, you can use the type command to see whether the command is a built-in command or an external command.
Built-in command: is a command provided by the shell program itself
External command: It is itself a separate executable program file, the command name is its program file name
How did the system find the command after we entered the command?
For built-in commands, you can find them directly inside the shell;
For external commands, it is found through the path specified in the environment variable path.
An environment variable is a global variable that, once defined, takes effect in the next operation (without changing the terminal), and is written to the configuration file (not explained here) for permanent entry.
Use the type command to see whether the command you are using is built-in or external
[[Email protected]_basic ~] #type CD
CD is a shell builtin
[[Email protected]_basic ~] #type Echo
Echo is a shell builtin
[[Email protected]_basic ~] #type type
Type is a shell builtin
[Email protected]_basic ~] #type Cat
Cat is hashed (/BIN/CAT)
In the format of the command, options are used to adjust how the command functions.
There are two formats: Long options and short options
The long option is not combined, and the short option can
Short options like:-L,-A,-H use multiple short options separated by spaces
Long option shapes such as:--list,--all,--help
Here you need the main, some options are required with parameters, such as Useradd-u UID
CD: Changes the current working directory, when you do not specify options and parameters, is transferred to the current user home directory.
[Email protected]_basic boot] #cd
[Email protected]_basic ~] #pwd
/root
can also be transferred to the specified user home directory via CD ~ Current home directory under CD ~username
CD-Switch back and forth between the previous directory and your current directory
[[Email protected]_basic ~] #ls-a
. .bash_history .bashrc blankdir Install.log .mysql_history tcpestd1.sh vbird_server
.. .bash_logout bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm .cshrc install.log.syslog .rnd tcpestd.sh . Viminfo
anaconda-ks.cfg .bash_profile blank
There are two unique paths. Refers to the current directory: Table of contents at the top level
Under the Linux command line, you can also use the up and down keys to see the commands you have used, in fact, Linux is a command history, command history view through the
If you enter information on the command line, you can use CTRL + C to terminate the execution of the current command
[Email protected]_basic ~] #cd/etc/init.d/jdf^c
[[Email Protected]_basic ~]#
Commands saved in the command history are restricted and can be viewed by histsize
[Email protected]_basic ~] #echo $HISTSIZE
1000
Command history saves files for the user home directory in the. bash_history, the command save is not saved until the user exits.
The command history file is also saved by an environment variable that is Histfile
[Email protected]_basic ~] #echo $HISTFILE
/root/.bash_history
[[Email Protected]_basic ~] #type History
History is a shell builtin
Displays the most recently used n commands, including the current command itself
[[Email protected]_basic ~] #history 10
1047 CD
1048 PWD
1049 LS
1050 LS-A
1051 history
1052 Echo $HISTORY
1053 Echo $HISTSIZE
1054 Echo $HISTFILE
1055 Type History
1056 History 10
To keep the system secure, don't let others see the command history
You can use History-c to clear all the command history
You can also delete the history command at the specified location by using the option-D
1055 History 10
1056 Man
1057 Whatis History
1058 Mans 1 History
1059 History-d 159
1060 History 5
1061 history-d 1059
1062 History
[[Email Protected]_basic ~] #history-D 1059
[[Email protected]_basic ~] #history 10
1054 Type History
1055 History 10
1056 Man
1057 Whatis History
1058 Mans 1 History
1059 History 5
1060 history-d 1059
1061 history
1062 history-d 1059
1063 History 10
History-a [/path/to/some_history_file]: Manually writes the history of a command in the current session to the specified file
[-W is written to the command history file and appended to the list of command history]
The history of the command is automatically saved to the. bash_history file only when the user exits
Bash invokes commands in the command history:
!#: Execute the # command in the history of the command
1064 ls
1065 cd/boot/
1066 Hitory
1067 History
1068 ls
1069 CD
1070 History
[[Email Protected]_basic ~]#!1068
Ls
Anaconda-ks.cfg Blank Gldt1210.png install.log.syslog tcpestd.sh
bind-utils-9.8.2-0.17.rc1.el6_4.6.x86_64.rpm Blankdir Install.log tcpestd1.sh vbird_server
!: Executes the last command that was executed correctly
!string: Executes the last command in the command history that begins with string;
[[Email Protected]_basic ~]#!s
Su-cactiuser
[[Email Protected]_basic ~]$
!$: Call the last parameter of the previous command
[Email protected]_basic ~] #ls/boot/grub/
Device.map fat_stage1_5 grub.conf jfs_stage1_5 minix_stage1_5 splash.xpm.gz stage2 vstafs_stage 1_5
E2fs_stage1_5 ffs_stage1_5 iso9660_stage1_5 menu.lst reiserfs_stage1_5 stage1 ufs2_stage1_5 xfs_stage1_5
[Email protected]_basic ~] #ls!$
ls/boot/grub/
Device.map fat_stage1_5 grub.conf jfs_stage1_5 minix_stage1_5 splash.xpm.gz stage2 vstafs_stage 1_5
E2fs_stage1_5 ffs_stage1_5 iso9660_stage1_5 menu.lst reiserfs_stage1_5 stage1 ufs2_stage1_5
ESC,.: function above press ESC and add '. ' No.
From using the above command we know that Linux has so many commands and so many parameters and options, how can we remember?
So let's use the help to get a quick idea of what options and parameters are used by the command.
The Help information for the built-in commands can be viewed by:
[[Email protected]_basic ~] #help CD
CD:CD [-l|-p] [dir]
Change the shell working directory.
External command:
1, command--help Most of the commands are supported, get command brief help information
[Email protected]_basic ~] #cat--help
Usage:cat [OPTION] ... [FILE] ...
Concatenate FILE (s), or standard input, to standard output.
-A,--show-all equivalent To-vet
-B,--number-nonblank number nonempty output lines
-e equivalent To-ve
The Help information file for the command on Linux is located in one of the/usr/share/man/locations
[Email protected]_basic ~] #ls/usr/share/man/
BG da El es fr hu it ko man1 man1x man2x man3p man4 man5 man6 man7 man8 man9 Mann overrides PT RO SK SV Zh_cn
CS de en fi hr id ja man0p man1p man2 man3 man3x man4x man5x man6x man7x man8x man9x NL Pl PT_BR RU SL TR ZH_TW
Linux command displays the location of language storage
[Email protected]_basic ~] #cat/etc/sysconfig/i18n
Lang= "en_US. UTF-8 "
Sysfont= "Latarcyrheb-sun16"
When viewing help information, there is garbled display, you can modify the displayed language
[Email protected]_basic ~] #echo $LANG
en_US. UTF-8
# export lang=en LANG, here is the modification after the current is in effect
The Linux help file has the man, in fact, is the abbreviation of manual, the same Linux is to follow the rules can be abbreviated shorthand.
View Help information with man
[Email protected]_basic ~] #man TTY
TTY (1) User Commands TTY (1)
NAME
Tty-print the file name of the terminal connected to standard input
Synopsis
TTY [OPTION] ...
DESCRIPTION
Print the file name of the terminal connected to standard input.
-S,--silent,--quiet
Print nothing, only return a exit status
--help Display this Help and exit
--version
Output version information and exit
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report TTY bugs to [email protected]
GNU coreutils Home page: General help using GNU software: Report TTY translation bugs to
COPYRIGHT
Copyright? Free Software Foundation, Inc. License gplv3+: GNU GPL version 3 or later This was free software:you was free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
See ALSO
The full documentation-TTY is maintained as a Texinfo manual. If the info and TTY programs is properly installed at your site, the
Command
Info coreutils ' TTY invocation '
Should give you access to the complete manual.
The Man manual is a section of chapters that can be viewed through the Whatis command chapter, which is from 1-9
[[Email protected]_basic ~] #whatis TTY
TTY (1p)-return user ' s terminal name
TTY (1)-Print the file name of the terminal connected to standard input
TTY (4)-controlling terminal
TTY IOCTL [TTY_IOCTL] (4)-IOCTLs for terminals and serial lines
Note: Whatis performs a lookup operation based on the database, which is updated periodically for the system, and can be updated manually using Makewhatis;
Man view the information in the manual
section of the Manual:
Name: Command names
DESCRIPTION: A detailed description of the command function
Options: All option
Synopsis: Using formats
EXAMPLES: Using the example
Files: Configuration files related to the current command
See ALSO: Other manuals available
Format string in Help: Indicates the format that should be installed when the command is written
[]: Can be omitted
<>: not omitted
|: Two select one or more, cannot appear at the same time
...: homogeneous content can appear multiple
When there is a lot of information in man, for easy viewing, you can use
Flip screen up and down
SPACEBAR: Flip a screen to the end of a file
B: Flip a screen to the file header
J, enter: Flip a line to the end of the file
K: Flip a line to the file header
Ctrl+d: Turn half screen at the end of the file
Ctrl+u: Flip the screen to the file header
You can also search by string:
/string: Search from the file header to the tail
? string: Search from the end of the file to the header
N: Displays the next occurrence of the found display where the search character appears next
N: Displays the last display found where the search character was last seen
To exit the man manual use:
Q
Note: Man can provide help manuals for configuration files, system calls, library calls, and so on, except for commands, which are in separate chapters; you can use man man to view
[[Email Protected]_basic ~] #man man
Mans (1) man (1)
NAME
Man-format and display the on-line manual pages
Synopsis
Man [-ACDDFFHKKTWW] [--path] [-M system] [-p string] [-C Config_file] [-M pathlist] [-P pager] [-b browser] [-H htm Lpager] [-S sec-
Tion_list] [section] name ...
DESCRIPTION
Man formats and displays the on-line manual pages. If you specify sections, man is only looks in the the manual. Name is nor-
Mally the name of the manual page, which is typically the name of a command, function, or file. However, if name contains a slash (/)
Then mans interprets it as a file specification, so the can do man./foo.5 or even man/cd/foo/bar.1.gz.
See below for a description in where man looks for the manual page files.
1: User command users Commands
2: System Calls is called
3:C library function C Libraries Functions
4: Devices and special files Devices and special files
5: Files and conventions file Formats and conventions
6: Game Description Games et. Al.
7: Miscellaneous Miscellanea
8: SysAdmin tools system Administration tools and Deamons
Many applications come with help documentation:/usr/share/doc/
ChangeLog: Changes in program version upgrades
Install: Installation Method description
README: Program Description Information
When we learn Linux, we can read more and correspond to the official documents of the hairstyle edition.
Have not seen the command to go gfsoso.com search, remember to search, because a lot of problems have been met by others
You are welcome to point out bug fixes
This article is from the "Happy is good" blog, please be sure to keep this source http://6625958.blog.51cto.com/6615958/1591874
3.Linux Command Basics and explanations