目录
[root@localhost ~]# echo $shell /bin/bash
[root@localhost ~]# ip a 1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state unknown group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up group default qlen 1000 link/ether 00:0c:29:ec:6b:40 brd ff:ff:ff:ff:ff:ff inet 192.168.234.129/24 brd 192.168.234.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::bce1:f5a5:d3b0:55a8/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@localhost ~]# ip addr 1: lo: <loopback,up,lower_up> mtu 65536 qdisc noqueue state unknown group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens33: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up group default qlen 1000 link/ether 00:0c:29:ec:6b:40 brd ff:ff:ff:ff:ff:ff inet 192.168.234.129/24 brd 192.168.234.255 scope global noprefixroute ens33 valid_lft forever preferred_lft forever inet6 fe80::bce1:f5a5:d3b0:55a8/64 scope link noprefixroute valid_lft forever preferred_lft forever
bash是linux系统的用户界面,提供了用户和操作系统之间的交互,它接收用户的输入,让它送给操作系统执行(命令行操作)
[root@localhost ~]# echo $shell /bin/bash
[root@localhost ~]# cat /etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin
echo "usedns no" >> /etc/ssh/sshd_config systemctl restart sshd
[root@localhost ~]# 管理员是# (命令提示符) 普通用户时$
[root@localhost ~]# echo $ps1 [\u@\h \w]\$ \u 代表当前登录的用户 \h 代表当前主机的主机名 \w 代表当前的目录 0表示默认字体,1表示加粗,4在字体下方加下划线 5 闪烁 7 代表突出显示 31-37 字体颜色 40-47 表示背景颜色 echo 'ps1="\[\e[1;35mm\][\u@\h \w]\\$\[\e[0m\]"' >> /etc/profile.d/ps.sh #永久生效
执行命令: 输入命令回车
内部命令:shell 自带的命令
外部命令:第三方提供的命令
查看命令的类型: type
[root@localhost ~]#type echo echo is a shell builtin [root@localhost ~]#type top top is /usr/bin/top
[root@localhost ~]# 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'
command [options.....] [args...]
command 命令本身
options:启动或者关闭命令里面的某些功能
args:命令的作用体,一般情况下是目录或者文件,用户名等等
注意:
内部命令:
[root@localhost ~]# help command command: command [-pvv] command [arg ...] execute a simple command or display information about commands. runs command with args suppressing shell function lookup, or display information about the specified commands. can be used to invoke commands on disk when a function with the same name exists. options: -p use a default value for path that is guaranteed to find all of the standard utilities -v print a description of command similar to the `type' builtin -v print a more verbose description of each command exit status: returns exit status of command, or failure if command is not found.
linux系统中的命令可分为内部命令和外部命令。内部命令,又称为内建命令(builtin)。怎么区分内部命令和外部命令了? 输入man bash命令,就可查看所有的内部命令 bash(1) general commands manual bash(1) name bash - gnu bourne-again shell synopsis bash [options] [file] copyright bash is copyright (c) 1989-2011 by the free software foundation, inc. description bash is an sh-compatible command language interpreter that executes commands read from the standard input or from a file. bash also incorporates useful features from the korn and c shells (ksh and csh). bash is intended to be a conformant implementation of the shell and utilities portion of the ieee posix specification (ieee standard 1003.1). bash can be configured to be posix-conformant by default. options all of the single-character shell options documented in the description of the set builtin command can be used as options when the shell is invoked. in addi‐ tion, bash interprets the following options when it is invoked: -c string if the -c option is present, then commands are read from string. if there are arguments after the string, they are assigned to the posi‐ tional parameters, starting with $0. -i if the -i option is present, the shell is interactive. -l make bash act as if it had been invoked as a login shell (see invoca‐ tion below). -r if the -r option is present, the shell becomes restricted (see manual pape bash(1) line 1 (press h for help or q to quiit)
外部命令:
[root@localhost ~]#python --help usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ... [] 可选项 <> 表示变化的数据 ... 表示列表 a|b|c 或者 -abc 表示-a -b -c {} 表示分组
1 executable programs or shell commands #用户命令 2 system calls (functions provided by the kernel) # 系统调用 3 library calls (functions within program libraries) # 库的调用 4 special files (usually found in /dev) #设备文件与特殊文件 5 file formats and conventions eg /etc/passwd # 配置文件格式 6 games #游戏 7 miscellaneous (including macro packages and conventions), e.g. man(7), groff(7) # 杂项 8 system administration commands (usually only for root) # 管理类的命令 9 kernel routines [non standard] # 内核的api 退出q 翻屏 空格 翻行 回车 man 章节 passwd
[root@localhost ~]#name=alexdsb [root@localhost ~]#echo "$name" alexdsb [root@localhost ~]#echo '$name' $name [root@localhost ~]#echo "wo shi `tty`" wo shi /dev/pts/2 [root@localhost ~]#tty /dev/pts/2 [root@localhost ~]#echo "wo shi $(tty)" wo shi /dev/pts/2
touch file{1..20} #创建20个文件 seq 0 2 10 echo file{1..20..2}
echo -e 'dadasda\ndasdasd' echo -e '\a' #播放声音
[root@localhost ~]#whoami # 显示当前的登录用户 root [root@localhost ~]#who am i #显示当前登录用户的详细信息 root pts/2 2019-08-22 15:54 (192.168.21.1) [root@localhost ~]#w 显示所有的用户并显示执行的命令 16:27:54 up 5:19, 9 users, load average: 0.00, 0.01, 0.05 user tty from login@ idle jcpu pcpu what root tty2 11:37 4:48m 0.02s 0.02s -bash wu tty3 11:39 4:48m 0.02s 0.02s -bash root :0 :0 11:30 ?xdm? 1:28 0.36s /usr/libexec/gnome-session-binary --session gnome-classi root pts/0 :0 11:35 4:43m 0.03s 0.03s bash root pts/1 192.168.21.1 12:11 4:03m 0.02s 0.02s -bash root pts/2 192.168.21.1 15:54 2.00s 0.18s 0.03s w wu pts/3 192.168.21.1 12:27 2:26 0.05s 0.05s -bash
[root@localhost ~]#date 显示当前的时间 thu aug 22 16:30:06 cst 2019 usage: date [option]... [+format] or: date [-u|--utc|--universal] [mmddhhmm[[cc]yy][.ss]] [root@localhost ~]#date 010923102018 #修改时间 tue jan 9 23:10:00 cst 2018 [root@localhost ~]#date tue jan 9 23:10:18 cst 2018 [root@localhost ~]#ntpdate time.windows.com #同步网络服务器时间 unix元年 1970-01-01 [root@localhost ~]#date thu aug 22 16:35:44 cst 2019 [root@localhost ~]#date thu aug 22 16:35:47 cst 2019 [root@localhost ~]#date thu aug 22 16:35:48 cst 2019 [root@localhost ~]#date +%a thu [root@localhost ~]#date +%a thursday [root@localhost ~]#date +%f 2019-08-22 [root@localhost ~]#date +%h 16 [root@localhost ~]#date +%i 04 [root@localhost ~]#date +%m 08 [root@localhost ~]#date +%d 22 [root@localhost ~]#date +%m 38 [root@localhost ~]#date +%h aug [root@localhost ~]#date +%c thu 22 aug 2019 04:38:42 pm cst [root@localhost ~]#date +%t 16:39:01 [root@localhost ~]#date +%y 19 [root@localhost ~]#date +%y 2019 [root@localhost ~]#date +%y/m/%d 2019/m/22 [root@localhost ~]#date +%y/%m/%d 2019/08/22 [root@localhost ~]#date +%s 1566463197 [root@localhost ~]#date +%w 33
[root@localhost ~]#timedatectl local time: thu 2019-08-22 16:42:43 cst universal time: thu 2019-08-22 08:42:43 utc rtc time: thu 2019-08-22 08:42:43 time zone: asia/shanghai (cst, +0800) ntp enabled: no ntp synchronized: no rtc in local tz: no dst active: n/a [root@localhost ~]#timedatectl set-timezone asia/tokyo
[root@localhost ~]# cal august 2019 su mo tu we th fr sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
[root@localhost ~]# cal -y 2019 january february march su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 1 2 1 2 6 7 8 9 10 11 12 3 4 5 6 7 8 9 3 4 5 6 7 8 9 13 14 15 16 17 18 19 10 11 12 13 14 15 16 10 11 12 13 14 15 16 20 21 22 23 24 25 26 17 18 19 20 21 22 23 17 18 19 20 21 22 23 27 28 29 30 31 24 25 26 27 28 24 25 26 27 28 29 30 31 april may june su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 6 1 2 3 4 1 7 8 9 10 11 12 13 5 6 7 8 9 10 11 2 3 4 5 6 7 8 14 15 16 17 18 19 20 12 13 14 15 16 17 18 9 10 11 12 13 14 15 21 22 23 24 25 26 27 19 20 21 22 23 24 25 16 17 18 19 20 21 22 28 29 30 26 27 28 29 30 31 23 24 25 26 27 28 29 30 july august september su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 6 1 2 3 1 2 3 4 5 6 7 7 8 9 10 11 12 13 4 5 6 7 8 9 10 8 9 10 11 12 13 14 14 15 16 17 18 19 20 11 12 13 14 15 16 17 15 16 17 18 19 20 21 21 22 23 24 25 26 27 18 19 20 21 22 23 24 22 23 24 25 26 27 28 28 29 30 31 25 26 27 28 29 30 31 29 30 october november december su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 1 2 1 2 3 4 5 6 7 6 7 8 9 10 11 12 3 4 5 6 7 8 9 8 9 10 11 12 13 14 13 14 15 16 17 18 19 10 11 12 13 14 15 16 15 16 17 18 19 20 21 20 21 22 23 24 25 26 17 18 19 20 21 22 23 22 23 24 25 26 27 28 27 28 29 30 31 24 25 26 27 28 29 30 29 30 31
[root@localhost ~]# cal 2008 2008 january february march su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 1 2 1 6 7 8 9 10 11 12 3 4 5 6 7 8 9 2 3 4 5 6 7 8 13 14 15 16 17 18 19 10 11 12 13 14 15 16 9 10 11 12 13 14 15 20 21 22 23 24 25 26 17 18 19 20 21 22 23 16 17 18 19 20 21 22 27 28 29 30 31 24 25 26 27 28 29 23 24 25 26 27 28 29 30 31 april may june su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 1 2 3 1 2 3 4 5 6 7 6 7 8 9 10 11 12 4 5 6 7 8 9 10 8 9 10 11 12 13 14 13 14 15 16 17 18 19 11 12 13 14 15 16 17 15 16 17 18 19 20 21 20 21 22 23 24 25 26 18 19 20 21 22 23 24 22 23 24 25 26 27 28 27 28 29 30 25 26 27 28 29 30 31 29 30 july august september su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 5 1 2 1 2 3 4 5 6 6 7 8 9 10 11 12 3 4 5 6 7 8 9 7 8 9 10 11 12 13 13 14 15 16 17 18 19 10 11 12 13 14 15 16 14 15 16 17 18 19 20 20 21 22 23 24 25 26 17 18 19 20 21 22 23 21 22 23 24 25 26 27 27 28 29 30 31 24 25 26 27 28 29 30 28 29 30 31 october november december su mo tu we th fr sa su mo tu we th fr sa su mo tu we th fr sa 1 2 3 4 1 1 2 3 4 5 6 5 6 7 8 9 10 11 2 3 4 5 6 7 8 7 8 9 10 11 12 13 12 13 14 15 16 17 18 9 10 11 12 13 14 15 14 15 16 17 18 19 20 19 20 21 22 23 24 25 16 17 18 19 20 21 22 21 22 23 24 25 26 27 26 27 28 29 30 31 23 24 25 26 27 28 29 28 29 30 31 30
如对本文有疑问, 点击进行留言回复!!
linux下文本编辑器vim的使用方法(复制、粘贴、替换、行号、撤销、多文件操作)
网友评论