Linux Basics and Common commands

Source: Internet
Author: User
Tags clear screen echo command

First of all, what is a shell first?
The Shell is the user interface of the Linux system and provides an interface for users to interact with the kernel. It receives the command entered by the user and sends it to the kernel to execute. The shell is also known as the Linux command interpreter, and the shell is a high-level programming language.
[[email protected] ~]# echo $SHELL View the current SHELL type
/bin/bash
[[email protected] ~]# Cat/etc/shells View current system-installed shell
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh
There are two types of commands that can be executed in the shell: internal commands and external commands.
I. Internal commands and external commands
Internal command
Provided by the shell, and in some form of command, when the system is booted into the memory, is resident memory, so the execution is high efficiency.
External command
There are executable program files under the file system path that are read into memory from the hard disk when the user needs them.
The type command can distinguish between internal commands and external commands

Enable to view internal commands, as well as to determine whether internal commands

Lookup order when executing a command: alias > Internal Command > External command: Hash
PATH
Which means that when a command executes,
1. First to determine if it is an alias
2. Whether the order is an internal command
? 3. See if the hash is empty, if not empty, go to the path specified in the hash table
?? If none of the above three steps are performed, search by path path.
Two. Common Simple commands
Screen command:
Screen-s session name to create a new screen session
Screen-x Session name Join the created screen session
Screen-ls Show all screen sessions that are already open
Exit and close the screen session
echo Command:
$ () or ' parameters to print the output of one command to another
$ (()) or $[] for operation
Use ${} or "$ variable name" to delimit the starting and ending range of a variable name
History command: Displays the current terminal's historical record
Bash shortcut keys:
Ctrl+l clear screen, equivalent to clear command
Ctrl+o executes the current command and displays the command again
Ctrl+s blocks screen output, locks, but can still run commands.
Ctrl+q Allow screen output
CTRL + C Force end
Ctrl+d normal termination
CTRL + Z suspend (pause) command
The chapters in Man
?? ??? ? 1. User commands
?? ??? ? 2. System call
?? ??? ? 3.C Library Call
?? ??? ? 4. Device files
?? ??? ? 5. configuration file format
?? ??? ? 6. Games
?? ??? ? 7. Miscellaneous
?? ??? ? 8. Managing commands for Classes
?? ??? ? 9.Linux Kernel API
?? The chapters 1,5,8 above are the most commonly used chapters.

Man-w ls view file path?
Man 5 passwd show the content of chapter five??
Three File Management
Linux file system is a tree structure, in order to manage those files in an orderly manner, people are accustomed to these files as an ordered tree structure on the hard disk, as we are familiar with the ' MS-DOS ' (Disk operating system) is an example. The larger branches include more branches, the branches of which are the leaves of the tree or the regular files.

File has two types of data: metadata (metadata)
(data)
File name rules: Blue-to-directory
Red--Zip file
Green--Executable file
Light blue--linked files
Gray--Other files
LS usage
Ls-a Show All Files
LS-A displays all files except. 、..
Ls-l long list
-rw-r--r--. 1 root root 2193 Jul 17:28 passwd
File type |owner Permissions group permissions other Permissions | Hard link number |owner|group| file size (bytes) |mtime| filename
(The file type can be seen in long lists)
-: Normal file
D: Catalog file
B: Block device
C: Character device
L: Soft Link
P: Pipeline File
S: Socket file
Ls-r recursion
LS-LD displays detailed information for the specified directory.
Ls-1 Vertical Display
Ls-s by file size in descending order
Ls-t by modification Time (Mtime) from new to old
Ls-ut by Access Time (Atime) from new to old
Ls-u the order in which the files are stored
Ls-x Sort by file suffix
Ls-i Display Inode number
Time stamp:
Atime Access Time
Mtime File Data modification time
CTime File Metadata Modification time
Four Hard links and soft links
Hard Links
Creating a hard link adds additional record entries to reference the file
Corresponds to a physical file on the same file system
Each directory references the same inode number
Increase number of links at creation time
Cannot span drives or partitions
Syntax: ln filename linkname (cannot span partitions)
Soft connection
A symbolic link points to another file
LS-L displays the name of the link and the referenced file
The link content of a symbol is the name of the file it refers to
The directory can be
Can span partitions
The path to another file is pointed to
Syntax: ln-s filename linkname (can cross partition, source is deleted, link is not available)
Five Redirects and pipelines
redirect Output and errors to file: Command action Symbol file name
Supported operational symbols include:

REDIRECT standard output to a file

2> redirecting standard errors to a file

&> Redirect all output to file

The file does not exist when both,> and >> can create a new file, the file already exists > represents an overlay,>> the Append
2>&1 turns the wrong result into the right result
1>&2 turn the right result into the wrong result

Linux Basics and Common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.