In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The first experience of DAY01 Linux system
Linux introduction
Linux system installation (CentOS 7.4)
The operation interface of Linux system
1) graphical desktop
2) Command line operating environment
Configure the network
DAY02 plays the Linux command line
Manage directories and files
Use the vim editor to create and modify files
Manage user and group accounts
1. Command line foundation
1. Command format
Basic usage
Command word [option]... [parameter 1] [parameter 2]...
[] indicates that the content inside is optional.
When executing a command, the command word must exist, and options and parameters are optional
There must be spaces between command word option parameters
Analysis of each component
Option: used to regulate the mode of execution
A single character is usually used-
The word is commonly used--
Eg:
# ls-l
# ls-help
Parameter: the operation object of the command, such as the storage path of the document, user name, etc.
two。 Command line editing skills
Tab key
Function: the completion of a command or path. If the input uniquely identifies a command or path, tab will automatically complete it at one time. If it is not unique, tab2 displays all commands or paths that begin with the input
Take a wrong picture
3. Shortcut key
Ctrl + l: clear the entire screen
Ctrl + c: discard the command line of the current edit
Esc+.: pastes the parameters of the previous command
Second, browse directories and files
1.ls command
Format: ls [options]... [directory or file path]
Common command options
-A: including the name. Hidden document at the beginning
-l: display in long format
-h: must be used with-l to provide readable units of capacity (K, M, etc.)
-d: displays the properties of the directory
Eg:
# ls / root
# ls-l / root
# ls-A / root
# ls-lh / root
Add:
Absolute path: path that begins with /
Relative paths: paths that do not begin with /
Wildcard characters * and?
* match any 0-multiple characters
? Match any single character
Eg:
# ls / dev/tty*
# ls / dev/tty?
# ls / dev/tty??
2.cat command
View the contents of the file
# cat / etc/resolv.conf / / View the DNS address
# cat / etc/redhat-release / / View the mini version of the system
Third, create directories and files
1.mkdir command
Create a directory
-p Recursive create directory
Eg:
[root@localhost /] # cd / opt/
[root@localhost opt] # ls
[root@localhost opt] # mkdir ntd1711
[root@localhost opt] # ls
[root@localhost opt] # mkdir ntd1712
[root@localhost opt] # ls
[root@localhost opt] # mkdir ntd1801/group1/huangsir
[root@localhost opt] # mkdir-p ntd1801/group1/huangsir
[root@localhost opt] # ls
[root@localhost opt] # ls ntd1801/
[root@localhost opt] # ls ntd1801/group1/
[root@localhost opt] # ls-R ntd1801/
Question and answer question
a. How many directories have been created by the following command?
b. Where are these directories created?
# mkdir-p ntd1802/ group2 / xushuai excuse me
2.touch command
Create a file
Touch file name...
Eg:
# cd / vod/movie/cartoon
# mkdir-p / vod/movie/cartoon
# cd / vod/movie/cartoon/
# touch Mulan.mp4 NeZhaNaoHai.mp4
# ls-lh * .mp4
Copy, move, delete
1.cp command
Format: cp [options]... The original document... Target path
Common command options
-r: recursive, this option is required when copying directories
-p: keep the permissions, modification time and other attributes of the original file unchanged
Eg:
[root@localhost ~] # ls-ld / backup
[root@localhost ~] # mkdir / backup
[root@localhost ~] # ls-ld / backup
[root@localhost] # cp-r / boot/grub2 / etc/host.conf / backup/
[root@localhost ~] # ls-ld / backup/*
[root@localhost ~] # cp / boot/ / backup/
[root@localhost ~] # ls-ld / backup/*
[root@localhost] # cp-r / boot/ / backup/
[root@localhost ~] # ls-ld / backup/*
2.rm deletion
Format: rm [options]... File or directory...
Common command options
-r,-f: recursive deletion (including directories), forced deletion
Eg:
[root@localhost ~] # ls-ld / backup/*
[root@localhost ~] # rm / backup/host.conf
[root@localhost] # rm-f / backup/grub2/
[root@localhost ~] # rm-rf / backup/grub2/
[root@localhost ~] # rm-rf / backup/boot/
[root@localhost ~] # ls-ld / backup/*
3.mv move or rename
Format: mv [options]... The original document... Target path
Eg:
[root@localhost ~] # ls-l / vod/movie/cartoon/Mulan.mp4
[root@localhost ~] # mv / vod/movie/cartoon/Mulan.mp4 / backup/
[root@localhost ~] # ls-l / backup/
[root@localhost ~] # mv / backup/Mulan.mp4 / backup/HuaMulan.mp4
[root@localhost ~] # ls-l / backup/
IV. Vim text Editor
1. Three modes
Command mode: the default mode after the file is opened. You can only view the contents of the file and cannot modify it.
Input mode: can be edited and modified
Last line mode: save exit
two。 Handover
Command mode-- > input mode press I key
Command mode-- > last line mode press: key
Input mode and last line mode-- > command mode press ESC
Note: input mode and last line mode cannot be switched directly, but need to go through command mode
3. Vim filename
Open this file if filename exists
Create this file if filename does not exist
Experiment
1. Create a new file hello.sh in the / root/ directory
1) enter the content "Hello World!!"
2) use the cat command to confirm the contents of the file after saving
two。 Modify the system file / etc/hosts
1) add a line of "127.0.0.1 www.baidu.com" at the end
2) use the ping command to test connectivity to www.baidu.com, and observe the results
# ls / root/hello.sh
# vim / root/hello.sh
Press the I key
Enter Hello WorldCraft entries!
Press the ESC key
Press:
Wq!
# ls / root/hello.sh
# cat / root/hello.sh
4. Command mode operation
Cursor inline adjustment
^ = Home key move the cursor to the beginning of the line
$= End key move the cursor to the end of the line
Adjustment between lines of cursor
Gg jumps to the first line of the file
G jumps to the last line of the file
Copy, paste, delete
Yy copies the current line
# yy copy is currently down # lines
P paste under the current cursor
Delete deletes the single character where the current cursor is located
Dd deletes (cuts) the current line
# dd Delete (cut) the current cursor down to # line
Find
/ world the current cursor looks down for world
N next
Eg:
[root@ntd1711 ~] # rm-rf / tmp/*
[root@ntd1711 ~] # mkdir / tmp/test01
[root@ntd1711 ~] # cp / etc/mail.rc / tmp/test01/
[root@ntd1711 ~] # ls / tmp/test01/mail.rc
[root@ntd1711 ~] # vim / tmp/test01/mail.rc
5. Last line mode operation
W save
Q exit
Wq saves and exits
: wq! Force save and exit
W / root/xxx.file saves the current file as / root/xxx.file
R / root/xxx.file loads the / root/xxx.file file into the current file
6. Find and replace
: s/old/new replaces the current line with new as the first old
: s/old/new/g replaces all old in the current line with new
: n s/old/new/g m s/old/new/g replaces all old in line n-m to new
:% s/old/new/g replaces all old in the file as new
U undo
Eg:
[root@ntd1711 test01] # ls / etc/passwd / tmp/test01/passwd
[root@ntd1711 test01] # cp / etc/passwd / tmp/test01/
[root@ntd1711 test01] # ls / etc/passwd / tmp/test01/passwd
[root@ntd1711 test01] # vim / tmp/test01/passwd
Enter in the last line mode
/ root
: s/root/feige
U
: s/root/feige/g
U
: 1,10s/root/feige/g
U
:% s/root/feige/g
U
: q!
Show and close line number
: set nu | nonu
Managing users and groups
1. User management
a. User classification
Super user: administrator account root uid is 0
System users: system services generate uid ranges from 1 to 999
Ordinary user: the account created by the administrator himself, uid range: 1000-60000
b. Create a user
# id account name to verify whether this account exists in the system
# useradd account name create account
c. Set password
# setting password for passwd account
d. Modify account information
# usermod
-l change the login name of the new account and the old account
e. Delete an account
# userdel account Delete account
-r delete along with the home directory
Summary:
When a normal user is created by default, a folder with the same name is created under / home.
This folder is the home directory where the user was created.
Eg:
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # useradd nvshen
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # passwd nvshen
[root@ntd1711 ~] # id miaodt
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # usermod-l miaodt nvshen
[root@ntd1711 ~] # id miaodt
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # usermod-l nvshen miaodt
[root@ntd1711 ~] # id miaodt
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # userdel nvshen
Experiment:
1. Create a new user account named nvshen and set the password to 1234567
Test remote login to the local system as user nvshen
two。 Migrate this user's home directory to the / opt/nvshen directory
Log in to the local system remotely as user nvshen to confirm the location of the current pwd working directory
3. Completely delete the user account named nvshen
Check its ID information and view the results of the prompt. Check whether the home directory is available
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # useradd nvshen
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # passwd nvshen
[root@ntd1711 ~] # ssh nvshen@127.0.0.1
[nvshen@ntd1711 ~] $pwd
[nvshen@ntd1711 ~] $whoami
[nvshen@ntd1711 ~] $exit
[root@ntd1711 ~] # ls-ld / opt/nvshen
[root@ntd1711 ~] # ls-ld / home/nvshen/
[root@ntd1711] # usermod-d / opt/nvshen nvshen
[root@ntd1711 ~] # ls-ld / opt/nvshen
[root@ntd1711 ~] # mv / home/nvshen/ / opt/
[root@ntd1711 ~] # ls-ld / opt/nvshen
[root@ntd1711 ~] # ssh nvshen@127.0.0.1
[nvshen@ntd1711 ~] $pwd
[nvshen@ntd1711 ~] $exit
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # ls-ld / opt/nvshen/
[root@ntd1711 ~] # userdel nvshen
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # ls-ld / opt/nvshen/
two。 Group management
a. Create a group
# groupadd group name
-g gid specifies gid when creating a group
b. Add delete members to the group (users)
# gpasswd
-a: add the specified user as a group member
-d: removes the specified member user from the group
c. Delete a group
# groupdel
Eg:
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # useradd nvshen
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # groupadd-g 600 stugrp
[root@ntd1711 ~] # gpasswd-a nvshen stugrp
[root@ntd1711 ~] # id nvshen
[root@ntd1711 ~] # groupdel stugrp
[root@ntd1711 ~] # id nvshen
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.