Linux中提权操做sudo和文件传输操做

1.提权 : sudo

        visudo(将用户添加到可提权用户里面去)

实际操做演示

1)普通帐户和root帐户区别

[xiaokang@192 ~]$ yum install vim (在普通帐户下进行vim安装操做)html

Loaded plugins: fastestmirrorshell

You need to be root to perform this command. (提示须要使用root操做此命令,说明普通帐vim

户没有该权限)服务器

2)直接在命令前添加sudo进行提权操做

[xiaokang@192 ~]$ sudo yum install vimcurl

We trust you have received the usual lecture from the local Systemide

Administrator. It usually boils down to these three things:this

#1) Respect the privacy of others.url

#2) Think before you type.code

#3) With great power comes great responsibility.orm

[sudo] password for xiaokang:

xiaokang is not in the sudoers file. This incident will be reported.

(提示xiaokang没有在sudoers文件中,须要使用在root帐户下经过visuodo命令添加

xiaokang帐户进去)

3)在root帐户下经过visudo命令添加帐户,使普通帐户有部分root帐户权限

[root@192 home]# visudo

进去和vim操做同样在如下位置添加信息

## Allows people in group wheel to run all commands

%wheel ALL=(ALL) ALL

%xiaokang ALL=(ALL) ALL (仿照上面的添加用户信息)

2.文件下载

wget、curl

1)使用wget下载百度首页

[root@192 tmp]# wget http://www.baidu.com

--2019-04-03 22:44:58-- http://www.baidu.com/

Resolving www.baidu.com (www.baidu.com)... 111.13.100.92, 111.13.100.91

Connecting to www.baidu.com (www.baidu.com)|111.13.100.92|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 2381 (2.3K) [text/html]

Saving to: ‘index.html’

100%[==========================================>] 2,381 --.-K/s in

0.001s

2019-04-03 22:44:58 (2.67 MB/s) - ‘index.html’ saved [2381/2381]

[root@192 tmp]# ls

index.html test1 test1.tar test1.tar.gz (能够看到多了个index.html文件)

2)使用curl下载百度首页

[root@192 tmp]# curl -o baidu.html http://baidu.com (-o能够指定文件的名字baidu.html)

% Total % Received % Xferd Average Speed Time Time Time Current

Dload Upload Total Spent Left Speed

100 81 100 81 0 0 22 0 0:00:03 0:00:03 --:--:-- 22

[root@192 tmp]# ls

baidu.html index.html test1 test1.tar test1.tar.gz (能够看到多了个daidu.html文件)

3.文件下载

      scp

(一)MAC本中操做

1)将本地xiaokang.txt上传到服务器tmp目录中

$ scp xiaokang.txt xiaokang@192.168.0.108:/tmp/

2)将服务器中tmp目录下的xiaokang.txt文件下载到本地

$ scp xiaokang@192.168.0.108:/tmp/xiaokang.txt ./

(二)Windows下xshell中的操做

须要经过Xshell链接到服务器

1)首先须要在服务器安装 lrzsz

[xiaokang@192 ~]$ sudo yum install lrzsz

[sudo] password for xiaokang:

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

2)经过rz命令回车会弹出选择文件上传到服务器的弹窗

[xiaokang@192 ~]$ rz

z waiting to receive.**B0100000023be50

[xiaokang@192 ~]$ ls (能够看到已经上传到本目录文件xiaokang.txt)

xiaokang.txt

3)经过sz命令下载服务器中文件

[xiaokang@192 tmp]$ sz xiaokang.txt (下载本路径下xiaokang.txt文件回车,会弹出文件

存放位置选择框)