linux基础命令篇二

1.rmdir删除空目录

[root@andy ~]# ls
anaconda-ks.cfg
[root@andy ~]# mkdir test
[root@andy ~]# ls
anaconda-ks.cfg test
[root@andy ~]# rmdir test
[root@andy ~]# ls
anaconda-ks.cfg
[root@andy ~]#

2.cat查看文件内容(最少)

cat -n显示多少行

[root@andy ~]# ls
anaconda-ks.cfg
[root@andy ~]# touch test
[root@andy ~]# echo "hello" >> test
[root@andy ~]# cat test
hello
[root@andy ~]# cat -n test
1 hello
[root@andy ~]# echo -e "hello\nhello" >> test
[root@andy ~]# cat -n test
1 hello
2 hello
3 hello

3.more查看文件(更多内容以百分比显示查看进度)不能向后移动,q退出查看

4.less可以随意浏览文件(较少)

5.head查看前10行

[root@andy zabbix]# head zabbix_agentd.conf
# This is a configuration file for Zabbix agent daemon (Unix)
# To get more information about Zabbix, visit http://www.zabbix.com

############ GENERAL PARAMETERS #################

### Option: PidFile
# Name of PID file.
#
# Mandatory: no
# Default:

head -n 3 查看前三行文件

[root@andy zabbix]# head -n 3 zabbix_agentd.conf
# This is a configuration file for Zabbix agent daemon (Unix)
# To get more information about Zabbix, visit http://www.zabbix.com

[root@andy zabbix]#

6.tail查看后10行

[root@andy zabbix]# tail zabbix_agentd.conf
# Mandatory: no
# Default:
# TLSPSKIdentity=

### Option: TLSPSKFile
# Full pathname of a file containing the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKFile=
[root@andy zabbix]#

tail -f可以实时监控(一般用于监控日志)

[root@andy zabbix]# tail -f zabbix_agentd.conf
# Mandatory: no
# Default:
# TLSPSKIdentity=

### Option: TLSPSKFile
# Full pathname of a file containing the pre-shared key.
#
# Mandatory: no
# Default:
# TLSPSKFile=

7.clear清屏相当于crtl L(快捷键)

8.poweroff或shutdown -h now关机

9.reboot重启

10.alias查看设置别名

alias查看别名

[root@andy ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

alias设置别名

[root@andy ~]# alias rm='rm -rf'
[root@andy ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias rm='rm -rf'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@andy ~]# ls
anaconda-ks.cfg test
[root@andy ~]# rm test

unalias取消别名

[root@andy ~]# unalias rm
[root@andy ~]# alias
alias cp='cp -i'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias mv='mv -i'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

 

posted @ 2019-10-29 15:27  Y_Andy  阅读(105)  评论(0编辑  收藏  举报