Linux Reference Note 3

Source: Internet
Author: User

Four, vim text editor 1. Three mode command mode: The default mode after opening the file, can only view the contents of the file cannot modify the input mode: can edit and modify the last line mode: Save Exit 2. Toggle Command mode--input mode press the i key command mode--and last row mode press: Key input mode and last row mode--command mode press ESC NOTE: Input mode and last line mode cannot be switched directly, need to pass command mode 3. VIM filename If filename exists then open this file if filename does not exist then create the new file Experiment 1. New file in/root/directory hello.sh1) input content "Hello World!!!" 2) After saving, use the Cat command to confirm the file contents 2. Modify system files/etc/hosts 1) Add a line at the end "127.0.0.1 www.baidu.com" 2) Use the ping command to test connectivity to www.baidu.com, observe the results # ls/root/hello.sh# Vim/ro OT/HELLO.SH press the I key to enter Hello world!!! Press ESC to press: wq!# ls/root/hello.sh# cat/root/hello.sh4. Command mode operation cursor Inline adjustment ^ = Home key Move cursor to beginning $ = END key move cursor to line end cursor adjustment GG jumps to the first line of the file G jump to file The last line copy, paste, delete yy copy the current line #yy copy current down # line p current cursor Paste Delete Delete the current cursor is located in the single character DD Delete (cut) The current line #dd Delete (cut) The current cursor down to the # line find/world the current cursor down to find WORLDN Next eg:[[email protected] ~]# rm-rf/tmp/*[[email protected] ~]# mkdir/tmp/test01[[email protected] ~] # cp/etc/mail.rc/tmp/test01/[[email protected] ~]# ls/tmp/test01/mail.rc [[email protected] ~]# vim/tmp/ Test01/mail.rc5. Last line mode operation: W Save: Q exit: Wq Save and exit: wq! Force save and exit: W/root/xxx.file Save the current fileLoad the/root/xxx.file file into the current file for/root/xxx.file:r/root/xxx.file 6. Find Replacement: S/old/new Replace the current line the first old is new:s/old/new/g Replace the current line all old is new:n,m s/old/new/g replace the n-m line all old is new:% s/old/new/g replace all old in the file is Newu undo eg:[[email protected] Test01 ]# ls/etc/passwd/tmp/test01/passwd[[email protected] test01]# cp/etc/passwd/tmp/test01/[[email  Protected] test01]# ls/etc/passwd/tmp/test01/passwd[[email protected] test01]# vim/tmp/test01/passwd in the last line mode input/ Root:s/root/feige u:s/root/feige/g u:1,10s/root/feige/g u:%s/root/feige/g u:q! display and close line numbers: Set Nu|nonu five, Manage users and Groups 1. User management A. User category Super User: Admin account root UID is 0 System User: System service generated UID range 1 ~ 999 Normal User: Administrator created account, UID range of 60000b. Create user # ID account name Verify that the system exists for this Account # Useradd account name create account C. Set Password #passwd account Setup Password D. Modify account information #usermod-l new account old account change login name E. Delete account #userdel account Delete account-R together with home directory Delete Summary: When default creates a In general, a folder with the same name will be created under/home. This folder is to create the user's home directory eg:[[email protected] ~]# ID nvshen[[email protected] ~]# useradd nvshen[[email  Protected] ~]# ID nvshen[[email protected] ~]# passwd Nvshen[[emaiL protected] ~]# ID miaodt[[email protected] ~]# ID nvshen[[email protected] ~]# usermod-l miaodt nvshen[ [email protected] ~]# ID miaodt[[email protected] ~]# ID nvshen[[email protected] ~]# usermod-l nvshen mi Aodt[[email protected] ~]# ID miaodt[[email protected] ~]# ID nvshen[[email protected] ~]# userdel Nvshen Experiment: 1. Create a new user account named Nvshen, set the password to 1234567 to test with the user Nvshen telnet to the native System 2. Migrate this user's home directory to the/opt/nvshen directory and re-login the native system with user Nvshen to confirm the current PWD working directory location 3. Completely remove the user account named Nvshen to check its ID information and view the prompt results. Check if its home directory is available [[email protected] ~]# ID nvshen[[email protected] ~]# useradd nvshen[[email protected] ~]# ID nvshen[[email protected] ~]# passwd nvshen[[email protected] ~]# ssh [email protected][[email  Protected] ~]$ pwd[[email protected] ~]$ whoami [[email protected] ~]$ exit[[email protected] ~]# ls-ld/ Opt/nvshen[[email protected] ~]# ls-ld/home/nvshen/[[email protected] ~]# usermod-d/opt/nvshen nvshen[[ email&Nbsp;protected] ~]# ls-ld/opt/nvshen[[email protected] ~]# mv/home/nvshen//opt/[[email protected] ~]# ls-l D/opt/nvshen[[email protected] ~]# ssh [email protected][[email protected] ~]$ pwd[[email  Protected] ~]$ exit[[email protected] ~]# ID nvshen[[email protected] ~]# ls-ld/opt/nvshen/[[email  Protected] ~]# Userdel nvshen[[email protected] ~]# ID nvshen[[email protected] ~]# ls-ld/opt/nvshen/2. Group Management A. Create group #groupadd group name-G GID When you create a group, specify GIDB. Add Delete Member (user) to group #gpasswd-A: Add the specified user as group member-D: Removes the specified member user from the Group C. Delete Group #groupdeleg:[[email  protected] ~]# ID nvshen[[email protected] ~]# useradd nvshen[[email protected] ~]# ID nvshen[[email& Nbsp;protected] ~]# groupadd-g stugrp[[email protected] ~]# gpasswd-a nvshen stugrp[[email protected] ~]# ID nvshen[[email protected] ~]# groupdel stugrp[[email protected] ~]# ID nvshen

Linux Reference Note 3

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.