Getting Started with Linux basics

Source: Internet
Author: User
Tags echo command touch command

First, Learning Goals

1. Ability to install Linux operating system independently

2. Basic commands to be proficient in using Linux systems

3. Proficient in using Linux User management commands/system-related commands/file directory related commands/packaging compression related commands/Compare merge related commands/network-related commands, etc.

4. Proficiency in "search" for extrapolate learning

Second, Learning Resources

1. Course Materials: https://www.shiyanlou.com/courses/413 experiment One, course invitation code: W7FQKW4Y

2. Getting Started with Linux Basics: https://www.shiyanlou.com/courses/1 (Focus, the first lesson review content all from here)

3. Linux command: En cn

Third, Learning Methods

1. Progress is important: you must keep up with weekly progress, readings, exercises, quizzes, and projects. I will take every student seriously, please don't give up because of difficulty.

2. Question and answer is very important: meet the knowledge difficulties, please ask a lot of questions, this is your right to be responsible for your own obligations. FAQ to Blog Park Discussion Group: http://group.cnblogs.com/103791/

3. Practice is important: solve the book exercises, practical examples, complete the weekly project, only to really digest this good book. Learn in practice with an experimental building environment or a virtual machine installed on your own

4. The lab report is important: Keep a detailed record of your ideas for completing project tasks, get teacher reviews and help yourself review. After the completion of the study in the blog Park (http://www.cnblogs.com/) The study process through the blog published, blog title "Information Security system Design Foundation first week study summary"

Four, Learning Tasks

1. Key Learning Cheat/find/locate/grep/man/whereis/which/apt-get

Find help documents, a variety of examples to practice, these commands will be throughout our learning, master these commands can be good to learn other commands.

2. The orders that need to be mastered this semester are Ac,apt-get,bzip2,cat,chgrp,chmod,chown,clear,compress,cp,dd,df,diff,du,dump,evn,find,finger,free, Grep,gzip,head,kill,less,ln,locate,l,gout,ls,man,mkdir,more,mount,mt,mv,netstat,nslookup,od,passwd,patch,ps, Pstop,pwd,rm,shell,sort,ssh,stty,tail,tar,telnet,touch,tree,uname,unzip,vi,vim,whereis,which,who,write, etc.

Five, Learning Process

1. Learn the basic differences between Linux and Windows and learn about Linux's purpose

(1) Linux development is more free

(2) using Linux can only use the keyboard operation, the novice needs to learn

(3) Linux can be better for network and server development

2. Basic concepts and operations of Linux

(1) familiar with the experimental environment (the system user name and password in the lab building are Shiyanlou)

(2) terminal (Terminal), Linux multi-user login is done by different/dev/tty devices, Linux default provides 6 pure command line interface "Terminal" (accurate, this should be 6 virtual consoles) to let the user login On the physical machine system, you can switch by using [CTRL]+[ALT]+[F1]~[F6]. When you switch to one of the terminals and want to switch back to the GUI, you can press [CTRL]+[ALT]+[F7] to finish.

Intermediate program (shell), which provides the user with the interface of the Software (command parser).

(3) command-line operation

1) Important shortcut keys:

Use the TAB key to complete the command, complete the directory, complete the command parameters are no problem;

Use the CTRL + C key to forcibly terminate the current program (it does not cause the terminal to exit);

You can use the arrow keys on your keyboard to restore the commands you've entered previously.

Figure 1: Input tial

Figure 2: Enter Find/

Keys

Role

Ctrl+d

Keyboard input end or exit terminal

Ctrl+s

Tentative current program, pause and press any key to resume operation

CTRL + Z

Put the current program in the background to run, restore to the foreground for command FG

CTRL + A

Move the cursor to the input outfit, which is equivalent to the home key

Ctrl+e

Moves the cursor to the end of the input line, equivalent to the END key

Ctrl+k

Remove from cursor position to end of line

Alt+backspace

Delete a word forward

Shift+pgup

Scroll the terminal display up

Shift+pgdn

Scroll down the terminal display

Figure 3: Common directives

2) Wildcards: There are mainly asterisks (*) and question marks (?), which are used for fuzzy matching of strings (such as file names, parameter names).

Figure 4: Create text file with find

Figure 5: Create multiple TXT files with find

Character

Meaning

*

Match 0 or more characters

?

Match any one character

[List]

Match any single character in the list

[!list]

Matches a character other than any single character in the list

[C1-C2]

Match any single word in c1-c2 such as: [0-9] [A-z]

{String1,string2,...}

Match sring1 or string2 (or more) one string

{c2.. C2}

Match all characters in c1-c2 such as {1..10}

Figure 6:shell Common wildcard characters

3) Help Instructions

You can use the Man command, which is the abbreviation for the manual page.

Figure 7: Viewing the man command

Figure 8: Instructions for viewing the corresponding section

Figure 9: Instruction "ls--help"

3. User and file operation rights

(1) View user instructions: Who am I (who mom likes);

Figure 10: Viewing users

directive: WhoAmI (remove space), print user name only

Figure 11: Display only the user name

-a

parameters /strong>

description

print all can print

-d

print dead process

-m

with AM I,mom likes

-q

print current number of logged in users and user name

-u

print current login user login information

-r

print run level

Figure 12:who Command Other common parameters

(2) Create a user: here to use sudo this command, the use of this command has two large premises, one is to know the current login user's password, and the second is the current user must be in the sudo user group.

"$ sudo adduser lilei" instruction to create a new account, the input password interface is not visible, other information hit the ENTER key to indicate the default.

Figure 13: Create a new account and view

(3) How to know which user groups you belong to in Linux

1) Use the Groups command: where the colon is preceded by the user, followed by the user group to which the user belongs.

2) To view the/etc/group file, the Cat command reads the contents of the specified file and prints it to the terminal output, followed by its use. Sort means that the read text is sorted in a dictionary and then output, and then you will see a bunch of output below, and you can see the Shiyanlou user group information at the bottom. The content of/etc/group includes the user group, user group password, GID, and the user that the user group contains, one record per user group. The format is as follows:

Group_name:password:GID:user_list

You see the password field above as an ' x ' does not mean that the password is it, but that the password is not visible.

Figure 14:groups Instructions

Figure 15: View/etc/group/file

(4) Adding users to the group, using the Usermod command to add user groups to the user, also use the command you must have root permissions, you can directly use the root user to add user groups for other users, or with other users already in the Sudo user group to use sudo command to get permission to execute the command.

Figure 16: Show user not in group

Figure 17:root User Lilei

(5) Delete User: Instruction "$ sudo deluser lilei--remove-home"

Figure 18: Deleting a user

(6) View file permissions: (Linux all files), a directory to have both read and Execute permissions to open, and a directory to have write permission to allow the creation of other files in it, because the directory file actually holds the list of files in the directory and other information owner permissions.

Figure 19: Simultaneous use of '-A ' and '-l ' parameters

Figure 20: Display File size

(7) Change of ownership of documents

Figure 21: Changing the location of a folder

(8) Modify file permissions

1) Binary representation

2) Add and subtract assignment, instruction "$ chmod go-rw iphone", ' G ' o ' and ' u ', respectively, for Group,others,user, ' + ', '-' to add and remove corresponding permissions respectively.

4. Linux directory structure and file basic operation

1) FHS Standard, this kind of file organization defines the use of each region in the system, the minimum required composition of the file and the directory at the same time, also gives the exception handling and contradictory processing. Instruction "Tree/":

2) directory path, use the CD command to switch directories, used in Linux. Represents the current directory,.. Indicates the previous level of the directory (* * Note, remember our previous section, as described in. The beginning of the file is hidden files, so the two directories must also be hidden, you can use the LS-A command to view the hidden file),-Indicates the last directory, ~ usually represents the current user's "home" directory. Use the PWD command to get the current path (absolute path).

3) The absolute path, simply speaking, is the complete path from the root "/" directory, with the directory you want to be the end point, the expression form, such as:/usr/local/bin, which represents the bin directory in the local directory in the USR directory under the root directory.

Relative path, which is the path relative to your current directory, relative to the current directory. As the starting point, you have to go to the directory as the end, the form of expression such as: Usr/local/bin.

4) Basic operation of Linux files

1) Create a new blank file, use the Touch command to make a blank file, mainly to change the time stamp of the existing file (for example, the last access time, last modified time), but it does not add any parameters, only specify a file name, You can create a blank file for the specified file name (without overwriting a file that already has the same name), or you can specify the timestamp of the file at the same time.

2) Create a new directory, use the mkdir (make Directories) command can be created an empty directory, you can also specify the permission properties to create a directory, use the-p parameter, and create the parent directory (if the parent directory does not exist), as follows we create a multi-level directory.

5) Copy the file and use the CP (copy) command to copy a file or directory to the specified directory.

To replicate the directory, a successful copy of the directory requires the-R or-R parameters to represent recursive replication.

6) Delete the file, use RM (remove files or directories) command, delete directory, same as copy directory, to delete a directory, you need to add the-R or-r parameter.

7) Move the file and move the file (cut) using the MV (move or rename files) command.

8) Rename, "mv old file name new filename"

Multiple renames:

# Rename the 5 text files with a. c suffix to a file

$ Rename ' s/\.txt/\.c/' *.txt

# Batch The 5 files, the file name to uppercase

$ Rename ' y/a-z/a-z/' *.c

9) View the file, Cat,tac both commands are used to print the file contents to standard output (terminal), where cat is the positive sequence display, TAC reverse display;

Use the more and less commands to view the files in pagination;

Use the head and tail commands to view the files;

(see only one row, plus the-n parameter, followed by the number of rows)

10) View file type, file command to view files type

11) Edit the file and use the Vim learning tutorial inside Linux directly and enter the following command to start.

5. Environment variables and file lookup

(1) Variable, use the DECLARE command to create a variable name;

The variable TMP is assigned a value of Shiyanlou using the = sign assignment operator;

Read the value of the variable, using the Echo command and the $ symbol (the $ symbol can represent a value that refers to a variable)

(2) Three kinds of environment variables:

The current shell process private user-defined variables, such as the TEMP variable we created above, are only valid in the current shell;

The built-in variables of the Shell itself;

An environment variable exported from a custom variable.

Command

Description

Set

Displays all environment variables for the current shell, including built-in environment variables (related to shell appearance, etc.), user-defined variables, and exported environment variables

Env

Displays the environment variables that are relevant to the current user, and lets the command run in the specified environment

Export

Displays variables that are exported from the Shell to an environment variable, and can also be exported to a custom variable as an environment variable

(3) Search path and Order of command

View the contents of the PATH environment variable, using the directive "$ echo $PATH"

Six, homework after class

2.

Operation Figure 1

Operation Figure 2

Operation Figure 3: After downloading the toilet package

3.

Create User: Instruction (sudo adduser), hit Enter with default value

Root User:

4.

5.

Seven, Experience

Understand the difference between Linux and Windows, understand the advantages and disadvantages of Linux, and learn basic operations, for the future more convenient use of Linux to lay the foundation.

Getting Started with Linux basics

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.