Day1 first knowledge of Linux

Source: Internet
Author: User

Linux Basics

1. about Linux
1) Mastering the definition of Linux: Linux is a free-to-use and free-spread UNIX-like operating system, a POSIX and Unix-based multiuser, multitasking, multi-threaded and multi-CPU operating system.
2) Master The main purpose of Linux operating system: Mainly used for servers, especially network servers.
3) Master Two common desktop environments: KDE and GNOME.

2. Login and Exit Linux
1) Init 0: command to shut down Linux system
2) Linux terminal: Linux terminal is also called Virtual Console. The Linux terminal uses the character command line method to work, the user through the keyboard input command, through the Linux terminal to control the system.
3) Switch the virtual Terminal method: Ctrl+alt+f[1~6], if you want to switch to the second virtual terminal, you also press CTRL+ALT+F2
4) $: Prompt after normal user login
5) Prompt for root user login system
6) Exit: Exit command

3. linux commands and get help

The format of the Linux command
Syntax format for commands
Specific meanings of commands, options, and parameters in command format
1 "whoami command
1) Functions of the WhoAmI command
Who command: View users
Functions of the WHO command
Results of the WHO command output
2 "date, Cal, and clear commands and commands with parameters
1) Date: View datetime: Edit date in the format of "Month Day year"
2) Cal: displays a month's calendar
3) Clear: Clear screen
4) Clear Screen shortcut key Ctrl +l
Su and passwd commands
1) SU: switch from the current user to another specified user
Example of use of the SU command:su–root
2) passwd: Modify the password of the user (either a normal user or the root user) to view the user's password status, etc. Useradd
passwd Usage Example: The command to modify who's user password: passwd who's
Use the man command to get help information
Man command function
1) Man Command usage example

The command to view the use instructions for the SU command is: Man su
2) Get help with "command name--help"

Example: The command to view the LS command Help is: (Do not use the man method)
Ls–-help

4. Browse, manage and maintain directory files (1)

Some of the important directories in the Linux system
1) Bin directory: the command required by the underlying system is located in this directory and is required for the smallest system, such as LS, CP, mkdir, etc. the files in this directory are executable and can be used by the average user
2) Sbin directory: Most of the commands involved in system Management, is the super-user root executable command to store
3) Home directory: The host directory, the normal user's data storage place, each user will build a folder below
4) Dev directory: Device files
5) Etc directory: The configuration file that holds the system program or the general tool
6) Mount directory/media or/mnt/opt/tmp
7> Absolute and relative paths
1) Absolute path: must start with a forward slash (/). An absolute path consists of the name of each directory that must be traversed from the root node of the file system to the object (directory or file) to look for, which is the complete signpost to the file location, so you can use an absolute path to find the desired file in any case.
2) relative path: instead of starting with a forward slash (/), a relative path can contain the name of each directory that must be traversed from the current eye to the object (directory or file) to find.

5. Browse, manage and maintain directory files (2)

1. Use the PWD and CD commands to identify and switch directories
1) function of the PWD command: determine the current working directory
2) function of the CD command: toggle the current directory
3) CD. : go to the top level directory
4) CD ~: switch to the user's home directory
5) cd–: working directory before switching to user

6)"CD directory Name" command: Switch to the specified directory
2. Use the LS command to list the contents of the directory
1) The function of the LS command: lists the current directory (the default is the current directory) or the contents of the specified directory
2) Ls–a: list all files in the directory, including "." The implied file at the beginning

a) Example: Lists all files in the/home/dog directory, Commands that include hidden files: ls-a/home/dog
3) ls–all:
4) Ls–l: Listing the details of each file in a directory
example: a command that lists details of all non-hidden files in the/home/dog directory:
A) Ls–l/home/dog
3, Copy files and directories using the CP command
1) functions of the CP command: copies files (can be multiple) to a specified destination file or to a specified destination directory. Cp source file target file
2) –r (recursive, recursive): replicates the directory recursively. When copying a directory, copy all of the contents of the directory, including the entire contents of the subdirectory.
i) For example: Copy the contents of the/home/dog directory to all the commands in the directory/home/cat:
Cp–r/home/dog/home/cat
3)-F (Force, Mandatory): Do not ask to directly force copy
4, use MV command to move and modify file and directory name
1) The function of MV command:
2) The usage example of the MV command:

A) Examples of moving files and directories:
Move the lists file in the current directory to the command in its subdirectory Babydog:
MV Lists Babydog
b) Examples of renaming files and directories:
Change the BigDog directory name to Babydog command:
MV BigDog Babydog
5. Create a directory using the mkdir command
1) function of the mkdir command: Create a new directory
2) Examples of MKDIR commands: Creating a directory Daddog command: mkdir Dadgog
6. Create a file using the Touch command
1) Touch Command function: You can create an empty file, or you can create multiple files at the same time.
2) Example of the use of touch commands:

A command to create a file named Babydog1 in the current directory:
Touch Babydog1
7. Delete files using RM command
1) RM command function: Permanently delete files or directories in the file system.
2) –r option: Delete the directory recursively. When a directory is deleted, all content in that directory is deleted, including all content in the subdirectory.
3) –f option: The system does not ask but force Delete, that is, delete the original file directly.
4) Examples of the use of RM commands:

command to delete the Babydog1 file in the current directory: RM babydog1
8. Delete the directory using the rmdir or RM–R command
1) Function of rmdir command: Delete empty directory
2) Examples of the use of RMDIR commands:

To remove the empty directory Mumdog/girldog/babydog command:
3) function of the rm–r command: Delete the directory containing the files and subdirectories.
4) Examples of the use of RM–R commands:

To delete a non-empty directory Mumdog command:
Rm–r Mumdog
9. Use the Cat command to browse the contents of the body file

1) Master the function of the cat command: To display the contents of one or more files on the screen, the command will continue to display the contents of the entire file in a read-only manner.
2) Examples of how to master the use of CAT commands:
A) The command to browse the entire contents of the Game.txt file:
Cat Game.txt
10, use the Head command to browse the contents of the file (see Linux System Management P75)
1) Master the function of the head command: the first 10 lines of a file are displayed by default.
2) Common options for mastering the head command:
-N Change the number of rows displayed
3) The use of the Master Head Command example:
A) command to view the details of the first 10 lines in the/etc/passwd file:
head/etc/passwd
b) command to view the details of the first 5 lines in the/etc/passwd file:
Head–n 5/etc/passwd
11. Use the tail command to browse the contents of the file (see Linux system Administration P76)
1) Master the function of the tail command: the content of the last 10 lines of the file is displayed by default.
2) Master the common options for tail commands:
-N Displays the nth rows from the end of the file
3) Use examples of mastering tail commands:
A) The command to view the details of the last 10 lines in the/etc/passwd file:
tail/etc/passwd
b) The command to view the details of the last 5 lines in the/etc/passwd file:
Tail–n 5/etc/passwd
12. Browse the file using the more command (see Linux System Management P78)
1) Master the more command function: After using the more command, each time a screen (one page) of the file content is displayed, and at the end of the screen will appear "-more--(n%)" Information, where n% is already showing the content of the file percentage.
2) Flexible application of MORE commands
A) paging through the command of the contents of the Learning.txt file:
More Learning.txt

Day1 first knowledge of Linux

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.