Getting Started with Linux basics (20135207 Wang Gui)

Source: Internet
Author: User
Tags touch command

Introduction to the Experiment one Linux system

First, the experimental experience

The first experiment was a brief introduction to the Linux system and the history and development of the Linux system. Benefited me.

Experiment two basic concepts and operation

I. Learning Objectives

1, experimental building environment introduction

2. Common shell commands and shortcut keys

3, Linux use tips

4. Linux Desktop Environment Introduction compared to the current Windows system, Unix/linux itself is not a graphical interface, we usually see the unix/linux distribution of the graphical interface is actually just run on the Linux system on the software, similar to Windows95 The previous Windows graphical interface was actually just a set of software running in a DOS environment. The software on Linux was previously XFree86, and now is xorg (x.org), and the software is implemented through the X Window System (also known as X11 or X), and x itself is just a toolkit and architecture protocol, and Xorg is the X architecture specification An implementation body, which means that it is a server that implements the X protocol specification to provide a graphical user interface service, just like Apache, which implements the HTTP protocol to provide Web services. If only the server is not able to implement a full desktop environment, of course, we also need a client, we call the X-client, like the following several well-known also the most popular implementation of the client-side desktop environment Kde,gnome,xfce,lxde, which you see, Lab building is currently used in the XFCE desktop environment, some old users may recall that the experimental building before the environment used is LXDE. This also means that on Linux you can choose to install different desktop environments and even customize your own desktop.

5, the experimental building environment all the default system user name is Shiyanlou, password is Shiyanlou

Ii. Learning Tasks

1.Terminal (terminal)

Usually when we use Linux, we do not deal directly with the system, but through a middle program called Shell, in order to achieve in the graphical interface let us in a window to accept user input and display output, Linux The system also provides a program called Terminal Emulator (Terminal), the following several more common terminal simulators, such as Gnome-terminal,kconsole,xterm,rxvt,kvt,nxterm and Eterm, At present, the terminal program in our experiment is the xfce-terminal that comes with XFCE desktop environment. It is important to note, however, that there is a difference between the terminal (Terminal) and the console (consoles).

2.Shell

Usually in the graphical interface to the actual experience is not the difference between the different versions of the terminal emulator, and most of the shell (shell), there is the core of the shell, where the kernel refers to the unix/linux core, the shell refers to "provide users with the interface" software (command parser), Similar to DOS commands (command line) and later Cmd.exe. A shell in the ordinary sense is a program that can accept user input commands. It is called a Shell because it hides the underlying details of the operating system. The graphical user interface under the same Unix/linux GNOME and KDE are sometimes referred to as "virtual shells" or "graphic shells."

The Shell under the Unix/linux operating system is both an interface for user interaction and a scripting language for control systems. This, of course, differs from the command line under Windows, although it also provides a very simple control statement. Under the Windows operating system, some users may never use the shell directly, but under the UNIX family operating system, the shell is still a scripting interpreter that controls system startup, X11 startup, and many other utilities.

In the unix/linux of the popular common Shell has bash,zsh,ksh,csh and so on, Ubuntu terminal default is to use bash, the default desktop environment is GNOME or Unity (based on GNOME), but our environment is used in the zsh and Xfce.

3. Command- line operation Experience

, double-click the Xface terminal icon on the desktop, open the terminal, open the terminal will automatically run the shell program, and then we can enter the command to let the system to execute:

1). important shortcut keys:

Before you can really learn the command line, you need to master a few very useful and necessary tips:[Tab]

Using the TAB key to complete the command, the TAB key is next to the letter Q, the greatest benefit to you is that when you forget the full name of a command, you can simply enter a portion of its beginning and press TAB to get a hint or help:

Of course, not only complete the command, complete the directory, complete the command parameters are no problem:

[Ctrl + C]

Think you have not encountered this situation, when you inadvertently entered a command in the Linux command, or the wrong use of a command, resulting in the terminal you can not expect, for example, only the cursor in the blink can not continue to enter the command, or constantly in the output of a lot of you do not want results. What should you do if you want to stop immediately and return to your controllable state? At this point you can use CTRL + C to forcibly terminate the current program (you can rest assured that it does not cause the terminal to exit).

Try entering the following command:

Some other common shortcut keys

button

function

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

2). Learn to use historical input commands

Use the arrow keys on your keyboard to restore the commands you've entered previously

3). Learn to use wildcard characters

A wildcard is a special statement that has an asterisk (*) and a question mark (?), which is used to make a fuzzy match to a string (such as a file name, parameter name). When you look for a folder, you can use it instead of one or more real characters, and you often use wildcards instead of one or more real characters when you don't know the real characters or are too lazy to enter the full name.

The wildcard character entered in the terminal is handled by the shell, not by the command statement involved, it will only appear in the command "parameter value" (it does not have in the command name, the command does not remember, then use the Tab completion). When the shell encounters a wildcard character in the parameter value, the shell treats it as a path or file name to search for a possible match on disk: If a matching match exists, the substitution (path extension) is performed, otherwise the wildcard character is passed as a normal to "command" and then processed by the command. In short, a wildcard is actually a kind of path extension that the Shell implements. After the wildcard is processed, the shell completes the reorganization of the command before continuing with the reorganized command until the command is executed.

Use the Touch command first to create 2 files with the suffix txt:

You can give the file a random name, if after a long time, you have forgotten the file name of the two files, and now you want to find the two text files in your large heap of other files, you can use wildcard characters:

When creating a file, if you need to create multiple files at once, for example:"Love_1_linux.txt,love_2_linux.txt,... love_ 10_linux.txt ". Very handy in Linux:

Shell Common wildcard characters:

character

/td>

meaning

*

matches 0 or more characters

?

matches any one character

[List]

matches any single character in the list

[!list]

Matches a character other than any single character in the list

[C1-C2]

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

{string1,string2,...}

matches sring1 or string2 (or more) one of the strings

{C2. C2}

match all words in c1-c2 such as {1..10}

4). Learn to get help in the command line

In a Linux environment, if you encounter difficulties, you can use the Man command, which is the abbreviation for the manual page.

Manual pages is a common form of online software documentation on UNIX or UNIX-like operating systems. The content includes computer programs (including libraries and system calls), formal standards and conventions, and even abstract concepts. The user can invoke the man page by executing the man command.

You can get a detailed description of a command and how to use it in the following ways:

Normally, the contents of the Man Handbook are in English, which requires you to have a certain foundation in English. The man manual is a lot of content, involving all aspects of the Linux use process, in order to facilitate the search, is to do a fascicle (sub-section) processing, in the UNIX, BSD, OS X and Linux, the manual is usually divided into 8 sections, arranged as follows:

Section

Description

1

General Command

2

System calls

3

Library functions, covering the C standard function library

4

Special files (usually devices in/dev) and drivers

5

File formats and conventions

6

Games and Screensavers

7

Miscellaneous

8

System administration Commands and Daemons

To view the contents of the corresponding section, add a number to the corresponding section after the man, as follows:

All hand albums follow a common layout, which is optimized for simple ASCII text display, which may not have any form of highlighting or font control in this case. The following sections are generally included:

NAME (name)

The name of the command or function followed by an introduction to the line.

Synopsis (summary)

For the command, formally describe how it runs, and what command line parameters are required. For a function, describe the parameters required for the function, and which header file contains the definition of the function.

DESCRIPTION (description)

A textual description of the function of the command or function.

EXAMPLES (example)

Some examples are commonly used.

See ALSO (see also)

A list of related commands or functions.

There may also be other parts of the content, but these parts are not standardized across manual pages. Common examples include options (option), exit status (Exit State), Environment (Environment), BUGS (Program Vulnerability), files (file), AUTHOR (author), REPORTING BUGS (known vulnerability), History and Copyright (copyrights).

There are usually a lot of things in the Man Handbook, and you may not be able to find the results you want, but fortunately you can use the search,/< in man to find the keyword you want to search for, and then you can use the N key to switch to the next keyword, shift+n where the previous keyword is located. Use space (SPACEBAR) to page, enter to scroll down one line, or use J,k (the VIM Editor's move key) to scroll backward one line forward. Press the H key to show use Help (because man uses less as the reader, which is actually the help of the less tool), press Q to exit.

For more detailed help, you can also use the Info command, but it's usually enough to use man. If you know the purpose of a command, just want to quickly see some of its specific parameters, then you can use the--help parameter, most of the commands will have this parameter, such as:

Third, the operation

This course introduces an interesting Linux command at the end of each section of the experiment, which describes a command that can output graphical characters banner

You can use the following command to install it first:

And then:

or use the installed command directly:

There are also two similar command toilet,figlet that are installed as a job to try out.

Experiment three user and file Rights management

I. Learning Objectives

1, the creation of Linux, delete users, and user groups and other operations.

2, the file permissions in Linux settings.

Ii. Learning Tasks

First, Linux user management

Through the first lesson, you should already know that Linux is a multi-user login operating system, such as "Li Lei" and "Han Meimei" can both log on the same host, they share some of the resources of the host, but they also have their own user space, for storing their own files. But in fact their files are placed on the same physical disk or even the same logical partition or directory, but due to the Linux user management and permissions mechanism , different users can not easily view, modify each other's files.

Let's take a look at the basics of account management under Linux.

1. View the user

Please open the terminal and enter the command:

The first column of the input indicates the user name of the user who opened the current pseudo-terminal (to see the user name of the currently logged-in user, to remove the space to use directly whoami ), the second column pts/0 represents a pts pseudo-terminal, the so-called pseudo-is relative to the /dev/tty device, remember the last section of the terminal when the seven use c4/>+ [Alt] + [F1] [F7] to switch the /dev/tty device, this is the "real terminal", pseudo-terminal is when you use in the graphical user interface /dev/tty7 every time you open a terminal will produce a pseudo terminal, pts/0 The next number represents the open pseudo-terminal number, you can try to open a terminal, and then enter in the inside who am i , see if the second column becomes pts/1 , and the third column represents the start time of the current pseudo-terminal.

whocommand other common parameters

Parameters

Description

-a

Print all that you can print

-d

Print the Dead process

-m

Same am i ,mom likes

-q

Print the current number of logged-in users and user names

-u

Print current logged in user login information

-r

Print Run level

2. Create a user

In a Linux system, the root account has the supremacy of the entire system, such as new/added users.

Root privileges, one of system permissions, and the systems permissions can be understood as a concept, but higher than Administrator permissions, Root is the Linux and UNIX system in the Super Administrator user account, the account has the entire system supremacy of power, all objects he can operate, So many hackers in the intrusion system, you have to elevate permissions to root permissions, using the method of Windows to understand that is to add their own illegal account to the Administrators user group. More like the Android operating system (based on the Linux kernel) to gain root privileges, it means that the phone has been given the highest rights, this time you can do any files on the phone (including system files) to perform all the add, delete, change, check the operation.

We generally log on to the system as a regular account of the login, to create a user needs root permission, this command is used here sudo . However, the use of this command has two large premises, one is that you want to know the current login user's password, and the second is that the current user must be in the sudo user group. The password for the Shiyanlou user is "Shiyanlou" and it also belongs to the Sudo user group (which will show you how to view and add the user group later). Now let's create a new user named Lilei:

This command not only adds the user to the system, but also creates the home directory for the new user by default:

Now that you have created the good one user, and you can log in using the user you created, use the following command to switch the logged in User:

Exit Current user You can use exit commands or use shortcut keys as you would exit a terminal Ctrl+d .

3. User groups

In Linux each user has a attribution (user group), the user group simply understand is a set of users, they share some resources and permissions, and have private resources, and the form of home, your siblings (different users) belong to the same home (user group), You can have this family together (shared resources), Mom and dad treat you all the same (share permissions), you occasionally write a diary, others without permission can not view (private resources and permissions). Of course, a user can belong to more than one user group, as you belong to the family, but also belong to the school or company.

How do you know which user groups you belong to in Linux?

Method One: Use the groups command

Where the colon is preceded by the user, followed by the user group that the user belongs to. Here you can see that Shiyanlou users belong to both the Shiyanlou and sudo user groups, and each time a new user does not specify a user group, the default is to automatically create a user group with the same user name (almost the same as the parent's meaning, or mister). By default in the sudo user group, you can use the sudo command to get root privileges.

Method Two: View /etc/groupFile

This cat command is used to read the contents of the specified file and print it to the terminal output, which will be used in detail later. | sortindicates that the text to be read is sorted in a dictionary and then output, and then you will see the following heap of output, you can see the Shiyanlou user group information at the bottom:

etc/groupFile Format description

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.

Add other users to the sudo user group

By default, the newly created user is not rooted, or the sudo user group can be added to the sudo user group to gain root privileges.

Then you switch to lilei the user, and now you can use sudo to get root privileges.

4. Delete a user

Deleting a user is a simple matter:

Ii. Linux file permissions 1. view File permissions

We have used the command many times before, ls as you can see, we use it to list and display the files in the current directory, of course, without any parameters, it will do more than that, and now we need to use it to view the file permissions.

To list files in a longer format:

File type

About the file type, here's one thing you must always keep in mind that Linux is all files , because this is the device files ( /dev directory has a variety of device files, mostly with specific hardware equipment related) This said, there is socket (network sockets , specifically what, interested users can themselves to understand or look forward to the experiment building follow-up related courses), and pipe (pipeline, this thing is very important, we will discuss later, here you first know that there is the existence of it). Soft link files, linked files are divided into two, the other is of course "hard link" (hard links are not commonly used, the specific content is not the focus of this course discussion, and soft link is equivalent to the shortcut on Windows, you remember this is enough)

File permissions

Read permission, indicating that you can use cat <file name> such commands to read the contents of a file, write permissions, that you can edit and modify a file, execute permissions, usually refers to the executable binaries or script files can be run, like the ' exe ' suffix on Windows files, but the Linux The type of file is not distinguished by the file suffix name. One thing you should be aware of is that a directory must have both read and Execute permissions to open, and a directory with write permission to allow other files to be created, because the directory file actually holds information such as a list of files in that directory

Owner permissions, which you should understand, as to the user group permissions, refers to all other users in your user group to the file permissions, for example, you have a pobman, then this user group permissions determine whether your siblings have the authority to use it to destroy it and take possession of it.

Number of links

The number of file names linked to the Inode node where the file is located (for the concept of Linux file system related concepts, not in the scope of this course, interested users can understand themselves).

File size

With the Inode node size as the size of the file, you can give LS plus the-LH parameter to see the size of the file more visually.

Understanding some of the concepts of file permissions, let's add ls some other common uses of commands:

Where small S is the size of the display file, big S is sorted by file size, and if you need to know how to sort by other means, use the "man" command to query.

2. Change the file owner

Assuming that the Lilei user is currently logged in, create a new file named "Iphone6"

Now, change the file owner to Shiyanlou using the following command

View now, find the file owner successfully modified to Shiyanlou

If you have a file that you do not want to be read, written, or executed by another user, then you need to modify the permissions of the file, there are two ways:

1. Binary digit representation

Three sets of permissions for each file (owner, owning user group, other user, remember this order is certain ) corresponds to this "rwx", that is, a ' 7 ', so if I want to change the file "Iphone6" permission to only I can use it then:

2, add and subtract assignment operation

Third, the operation

Getting Started with Linux basics (20135207 Wang Gui)

Related Article

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.