二、在linux命令行执行命令

【例1】显示当前使用的shell
 [root@centos7 ~]# echo ${SHELL} /bin/bash
 
【例2】显示当前系统使用的所有shell
 [root@centos7 ~]# cat /etc/shells /bin/sh
/bin/bash
/sbin/nologin
/usr/bin/sh
/usr/bin/bash
/usr/sbin/nologin
/bin/tcsh
/bin/csh

【例3】查看/etc/passwd文件最后1行内容
 [root@centos7 ~]# tail -n 1 /etc/passwd linux:x:1004:1004::/home/linux:/bin/bash

【例4】type查看内部显示的结果
 [root@centos7 ~]# type cd cd is a shell builtin

【例5】type查看外部命令显示的结果
 [root@centos7 ~]# type top
top is /usr/bin/top

【例6】设置命令别名为bkmysql,实现拷贝/etc/my.cnf为/home/back/my.cnf.bak,设置后查看别名
 [root@centos7 ~]# alias bkmysql='cp /etc/my.cnf /home/my.cnf.bak'
[root@centos7 ~]# alias
alias bkmysql='cp /etc/my.cnf /hoem/my.cnf.bak'
alias cman='man -M /usr//share/man/zh_CN'
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'

【例7】把上例中别名设置写在配置文件里,永久生效。有两个文件可以写,~/.bashrc文件仅当对当前用 户,/etc/bashrc文件是对所有用户有效。
[root@Magedu ~]# echo "alias bkmysql='cp /etc/my.cnf /hoem/my.cnf.bak'" >>~/.bashrc 
[root@Magedu ~]# tail -1 ~/.bashrc
alias bkmysql='cp /etc/my.cnf /hoem/my.cnf.bak'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值