Basic command Experiment

Source: Internet
Author: User
Basic command experiment-general Linux technology-Linux technology and application information. For more information, see the following. Basic commands in Linux

Tutorial purpose: to understand basic Linux operating system operations, just like using the mouse in Windows. Because the communication between Linux and users is based on Shell, as a beginner, we should start with basic commands.

Lab environment: one device in Lan, independent

Task 1> understand the syntax of basic commands in Linux

1. There are two types of commands in Linux: shell internal commands, external application commands

2. command Format: command [option] [argument]

Command name option Parameter

Eg: ls

Ls? L

Ls? L.

3. Understand the parameter list of specific commands in Linux and related help

Man eg: man pwd | less

Info

Help

4. Understand system file and directory operations

A. Name composition: letters, numbers, underscores, dots

B. File Type

Common file-

Directory file D

Link file L

Special file character Device C

Fast Device B

C. Some special files

1./The root directory is the parent directory, and all other directories are under

2./sub-directory:

The bin directory is a executable command. The blue directory indicates that files can be executed, and the blue directory indicates that files can be executed. The light blue directory indicates a link file, that is, a shortcut.

Commands executed by the sbin System Administrator

Directory of the dev Device

All configuration files in etc are stored

Main directory of the usr Application

Home any user in home has a home directory with the same name as the user name

Root Super administrator's home directory, which is not in the home directory.

Lib library file storage location

The image of the proc kernel in the memory can view the system hardware information here.

Var log file storage location

Src System Kernel File

Task 2> each user has a home directory. You can directly press cd to enter the home directory of the user. And

Each user has a directory with the same name as the user name, that is, its home directory.

Path: absolute path and relative path. The path starting with/directory indicates absolute path,

The path relative to the current directory is relative path ,... /...

[User name @ host name current directory name] # superuser

[User name @ host name current directory name] $ normal user

1. display the current directory pwd command (show absolute path)

2. Run the cd command eg: cd/root in another directory.

3. Go to the upper-level directory cd ..

4. Go to the last directory cd?

5. display the files and sub-files in the directory ls to view the Directory and hide the file ll-

6. Create a directory mkdir file name

7. Create multiple directories at the same time. mkdir file name 1 file name 2 ......

8. recursively create the directory tree mkdir? P 111/11/1

9. Delete the empty file rmdir file name

10. Delete non-empty files rm? Rf file name

11. find the target file? Name file (wildcards can be used)

12. display the file content cat filename on one screen. You can view the less filename in the upper and lower positions.

More filename multi-screen display content

13. head: displays the first n rows of head? N file name

14. tail: The last n rows of tail? N file name

15. cp: copy the cp file path to the new file path

16. mv: target address of the mobile file mv source address

17. ln: Create a symbolic link file

Hardware link eg: ln abc.txt abc

Symbolic Link eg: ln? N abc.txt a (equivalent to creating a shortcut)

18. sort: Sorting command, eg: sort/etc/passwd

19. grep: Find the file. For example: grep 'zhao'/etc/passwd

20. wc: collects statistics on text files and obtains the number of characters, number of lines, and other information.

21. view the file size with the du file name

22. format the hard disk as the ext3 File System mkfs. ext3/dev/sda (sdb \ sdc)

21. mount after formatting? T ext3/dev/sda/home/directory name

22. view the id of the current user

23. Check which user is currently logged on.

24. Check who you are. who am I/who

25. View IP ifconfig

26. view the file name in the file format (such as text format and directory format)

Task 3> add and delete users and groups

User and group management

1. Create a user: Method 1: # useradd username? P password

For example, add user kk and password kk # useradd kk? P kk

Method 2: # useradd Username

Passwd User Name

Prompt for Password

Confirm Password

Or directly modify the/etc/passwd file, and then manually create the corresponding user's main directory.

2. Create group groupadd group name

Passwd? D. Generally, no password is set.

3. Set this user as the Group Administrator gpasswd? A username group name

4. Set the user's UID (the super administrator's uid is 0, 0) <系统用户的<500、

500 <= external users (manually created) <= 65535)

Useradd? UUID User Name

5. set UID groupadd? G uid group name

6. Add this user to this group gpasswd? A username group name

7. view the grep username of the user group/etc/group

8. Delete the groupdel group name of the empty group.

9. Change the group name groupmod? N new name

10. Rename usermod for the user? L new name, formerly known

2. Modify the user: # usermod? L newusername? C "comment "? D/home/newusername oldusername

For example, change the test user name to test2 and the main directory to/home/test2.

Usermod? L test2/home/test2 test (the test2 directory must be created manually)

-P: Change Password

-E: Set the Account expiration time

-S: Set shell

-P: Set the password.

3. Change Password: passwd username

Change root Password

In the grup state, connect E to the kernel editing mode, add spaces, and write single

Then press B to start.

Enter the shall status.

Passwd root Change Password



4. delete a user: userdel username or userdel? R

5. Restrict the users who can execute the su command: normal users who know the root user

You can use the su command to obtain the root user's permissions. Hackers may also obtain super permissions through brute-force cracking. Therefore, it is necessary to restrict users who can execute su commands. The specific method is as follows:

# Vi/etc/pam. d/su, modify one line:

# Auth required/lib/security/$ ISA/pam_wheel.so use_uid

Remove the first line # so that only users in the wheel group can use the su command. Then, add the selected user to the wheel user group.

Experiment problems and gains: understanding memory. Basic things: exercise more.

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.