码迷,mamicode.com
首页 > 其他好文 > 详细

二周第二次课(12月19日)

时间:2017-12-19 15:06:02      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:/etc/   blog   选项参数   adk   bin   bsp   star   动态   空格   

二周第二次课(12月19日)
2.10 环境变量PATH
2.11 cp命令
2.12 mv命令
2.13 文档查看cat/more/less/head/tail

 

 


环境变量 :
#PATH (环境变量)
#CP (拷贝)
#which (查看命令别名和所在的路径)

[root@localhost ~]# which alias PATH ^C
[root@localhost ~]# PATH ^C
[root@localhost ~]# which rm
alias rm=‘rm -i‘
/usr/bin/rm

[root@localhost ~]# which rmdir
/usr/bin/rmdir

[root@localhost ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/

[root@localhost ~]# rm /usr/bin/rm ^C
[root@localhost ~]# adkee
-bash: adkee: 未找到命令
[root@localhost ~]# which ls
alias ls=‘ls --color=auto‘
/usr/bin/ls

[root@localhost ~]# ls /usr/bin/ls
/usr/bin/ls

[root@localhost ~]# cp /usr/bin/ls /tmp/ls2

[root@localhost ~]# /tmp/ls2
anaconda-ks.cfg

[root@localhost ~]# ls
anaconda-ks.cfg

[root@centos-02 ~]# PATH=$PATH:/tmp/

[root@centos-02 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/tmp/

[root@centos-02 ~]# ls
anaconda-ks.cfg

[root@centos-02 ~]# ls2
anaconda-ks.cfg

[root@centos-02 ~]# which ls2
/tmp/ls2

[root@centos-02 ~]# vi /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
- - - - -- -删除分割线------------
unset i
unset -f pathmunge
PATH=$PATH:/tmp/
[root@centos-02 ~]#

副本

[root@centos-02 ~]# ls2
-bash: ls2: 未找到命令

[root@centos-02 ~]# /tmp/ls2
anaconda-ks.cfg

[root@centos-02 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[root@centos-02 ~]# vi /etc/profile

[root@centos-02 ~]# cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
- - - - -- -删除分割线------------
unset i
unset -f pathmunge
PATH=$PATH:/tmp/
[root@centos-02 ~]#

副本

root@centos-02 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/tmp/:/root/bin

[root@centos-02 ~]# ls2
anaconda-ks.cfg
[root@centos-02 ~]#
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
[root@centos-02 ~]# ls2

-bash: ls2: 未找到命令

[root@centos-02 ~]# vi /etc/profile
[root@centos-02 ~]# cat /etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
- - - - -- -删除分割线------------
unset i
unset -f pathmunge
[root@centos-02 ~]#

命令:

#cp >>copy (拷贝)
#cp -r (拷贝目录参数)
#cp -i (安全选项参数)
#源文件》》目标文件
#源目录》》目标目录

[root@localhost ~]# cp r /tmp/adkee//tmp/admin1

[root@localhost ~]# tree /tmp/admin1/
/tmp/admin1/
└── 2
└── 1.txt

1 directory, 1 file

[root@localhost ~]# tree /tmp/admin/
/tmp/admin/
└── 2
└── 1.txt

1 directory, 1 file

[root@localhost ~]# which cp
alias cp=‘cp -i‘
/usr/bin/cp

[root@localhost ~]# cp /etc/passwd /tmp/1.txt
cp:是否覆盖"/tmp/1.txt"? ^C^C

[root@localhost ~]# /usr/bin/cp /etc/passwd /tmp/1.txt

[root@localhost ~]# tree /tmp/admin1/
/tmp/admin1/
└── 2
└── 1.txt

1 directory, 1 file

[root@localhost ~]# cp -r /tmp/adkee/ /tmp/admin1/

[root@localhost ~]# ls /tmp/admin1/
2 adkee

[root@localhost ~]# tree /tmp/admin1/
/tmp/admin1/
├── 2
│   └── 1.txt
└── adkee
└── 2
└── 1.txt

3 directories, 2 files

[root@localhost ~]# cp -r /tmp/adkee/ /tmp/admin1/
cp:是否覆盖"/tmp/admin1/adkee/2/1.txt"? n
[root@localhost ~]#


命令:
#mv >> move

#mv >>(在同一目录下是改名字参数)

#mv >>(目标文件已存在会提示是是否覆盖)

#mv >>(目标目录且源也是目录,目标目录不存在就会更改目录名字)

#mv >>(目标目录且源也是目录,目标目录已存在就会把源放到目标目录里面)


[root@localhost tmp]# ls
1.txt
adkee
admin
admin1
ls2
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2


[root@localhost tmp]# mv 1.txt /root/2.txt

[root@localhost tmp]# ls /root/
2.txt anaconda-ks.cfg.1

[root@localhost tmp]# ls
adkee
admin
admin1
ls2
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# mv ls2 admin/

[root@localhost tmp]# ls admin
2 ls2

[root@localhost tmp]# which mv
alias mv=‘mv -i‘
/usr/bin/mv

[root@localhost tmp]# mv ls2 admin/
mv: 无法获取"ls2" 的文件状态(stat): 没有那个文件或目录

[root@localhost tmp]# touch ls2

[root@localhost tmp]# mv ls2 admin/
mv:是否覆盖"admin/ls2"? n

[root@localhost tmp]# which mv
alias mv=‘mv -i‘
/usr/bin/mv

[root@localhost tmp]# /usr/bin/mv ls2 admin/

[root@localhost tmp]# ls
adkee
admin
admin1
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# ls admin
2 ls2

[root@localhost tmp]# ls
adkee
admin
admin1
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# mv admin1/ admin

[root@localhost tmp]# ls
adkee
admin
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# mv admin/ admin2/

[root@localhost tmp]# ls
adkee
admin2
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# mv admin2/ adkee/

[root@localhost tmp]# ls
adkee
systemd-private-ec35b47c3f9043809d70ccf6780ed722-vmtoolsd.service-sE1em2

[root@localhost tmp]# ls adkee/
2 admin2

[root@localhost tmp]# touch adkee/admin2/1.txt

[root@localhost tmp]# tree adkee/admin2/
adkee/admin2/
├── 1.txt
├── 2
│   └── 1.txt
├── admin1
│   ├── 2
│   │   └── 1.txt
│   └── adkee
│   └── 2
│   └── 1.txt
└── ls2

 

文档查看:

#cat 查看文件(-A显示所有,$文档结束符 ,-n显示行号)

#more(显示一屏,空格键显示剩余,看完直接退出,CTDL+B向上看)

#less(空格键一屏一屏向下显示,支持方向键。CTDL+B向上看,CTDL+F向下看。
字母“Q”退出,“/”向下搜索。“?”向上搜索。 g首页,G末尾。n向上看,N向下看 )

#head(查看文件开头10行)
(-n自定义行数)

#tail(查看文件末尾10行)
(-f 动态显示文件内容)

二周第二次课(12月19日)

标签:/etc/   blog   选项参数   adk   bin   bsp   star   动态   空格   

原文地址:http://www.cnblogs.com/yikebaicai/p/8064951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!