上周六周日忘情大神程老师带我们学习了一些基础的、简单有趣的Linux命令,我们了解了Linux这个生动的系统,也学习了如何安装我们自己的虚拟机,以及一些我们学习会需要的一些软件,这也是我第一次使用macdown编辑器,看起来很有趣。相信它以后会是我的得力助手,下面是第一次笔记整理:
echo $shell 意思是查看当前系统正在使用的shell终端 /bin/bash是我们学习的第一条命令,很有趣,shell就像一个人与机器交互的终端/壳
cat /etc/shells 查看当前系统支持的所有Shell如标注,不同的镜像文件shell的数量也不相同
which zsh /usr/bin/which: no zsh in (/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:/home/lzy/.local/bin:/home/lzy/bin)which命令是查看某个命令在系统中存放的位置在哪里,一般来说,单用户模式下可操作的命令都存放在/bin文件夹下
which bash 查看bash命令的存放路径 /usr/bin/bash vi /etc/sysconfig/network-scripts/ifcfg-ens33使用vi编辑器进入etc目录下网卡配置文件进行修改,此外,修改完成后,使用ip a命令可以看到ip地址
alias cdnet='cd /etc/sysconfig/network-scripts/' 定义''内命令别名为cdnet一次有趣的尝试,alias是定义某个命令别名的过程,格式为alias’(命令)’
哈哈,一次简单的命令赋予的尝试,echo+剁了符号就把他输出出来了
[root@localhost lzy]# a=`cat /etc/sysconfig/network-scripts/ifcfg-ens33` [root@localhost lzy]# echo $a TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="dhcp" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" UUID="339da10a-cdf8-4ad6-8de0-c7559f5e2dbd" DEVICE="ens33" ONBOOT="yes"这样依然可以赋值,但是它不会对命令排序,那么我们可以用刚刚学的alies
[root@localhost lzy]# alias a='cat /etc/sysconfig/network-scripts/ifcfg-ens33' 使用ALT+.快捷键输入上一个参数 [root@localhost lzy]# a TYPE="Ethernet" PROXY_METHOD="none" BROWSER_ONLY="no" BOOTPROTO="dhcp" DEFROUTE="yes" IPV4_FAILURE_FATAL="no" IPV6INIT="yes" IPV6_AUTOCONF="yes" IPV6_DEFROUTE="yes" IPV6_FAILURE_FATAL="no" IPV6_ADDR_GEN_MODE="stable-privacy" NAME="ens33" UUID="339da10a-cdf8-4ad6-8de0-c7559f5e2dbd" DEVICE="ens33" ONBOOT="yes"echo的其他用法: 如果要输入let’s go 但这里的单引号与命令单引号冲突,于是我们可以:
[root@localhost lzy]# echo "let's go" let's go小试牛刀…
type (命令) 查看某个命令的类型,他是一个内部命令还是外部命令,内部命令则可以使用--help查看帮助文件类型的头显:
d 目录文件 - 普通文件 l 链接文件 s 套接字文件 b 块设备文件 c 鼠标键盘等字符设备文件 [root@localhost /]# ll -ld boot dr-xr-xr-x. 5 root root 4096 10月 31 14:40 boot查看根目录下,boot文件的详细信息
[root@localhost /]# ll -t 总用量 20 drwxrwxrwt. 19 root root 4096 10月 31 15:07 tmp dr-xr-x---. 5 root root 225 10月 31 15:04 root drwxr-xr-x. 41 root root 1300 10月 31 14:49 run drwxr-xr-x. 138 root root 8192 10月 31 14:46 etc drwxr-xr-x. 3 root root 17 10月 31 14:46 home drwxr-xr-x. 20 root root 3320 10月 31 14:42 dev drwxr-xr-x. 20 root root 282 10月 31 14:42 var dr-xr-xr-x. 13 root root 0 10月 31 14:42 sys dr-xr-xr-x. 216 root root 0 10月 31 14:42 proc dr-xr-xr-x. 5 root root 4096 10月 31 14:40 boot drwxr-xr-x. 3 root root 16 10月 31 14:32 opt drwxr-xr-x. 13 root root 155 10月 31 14:19 usr lrwxrwxrwx. 1 root root 9 10月 31 14:19 lib64 -> usr/lib64 lrwxrwxrwx. 1 root root 8 10月 31 14:19 sbin -> usr/sbin lrwxrwxrwx. 1 root root 7 10月 31 14:19 lib -> usr/lib lrwxrwxrwx. 1 root root 7 10月 31 14:19 bin -> usr/bin drwxr-xr-x. 2 root root 6 4月 11 2018 media drwxr-xr-x. 2 root root 6 4月 11 2018 mnt drwxr-xr-x. 2 root root 6 4月 11 2018 srv以时间正向排序,显示根目录下的文件信息
[root@localhost /]# ll -rt-rt则是以逆向排序显示
[root@localhost /]# mkdir -pv 1/2/3/4 mkdir: 已创建目录 "1" mkdir: 已创建目录 "1/2" mkdir: 已创建目录 "1/2/3" mkdir: 已创建目录 "1/2/3/4"mkdir的一个有趣的用法~ 多重目录,意思是我在1目录中创建了2目录,2目录中创建了3目录,3目录中又创建了4目录,-v的意思是显示这个创建的过程,-p的意思是递归创建,所以都必须加上
[root@localhost 123456]# mkdir 1 [root@localhost 123456]# ls 1 [root@localhost 123456]# mv 1 2 [root@localhost 123456]# ls 2mv命令可以用来给文件改名,很是有意思。
[root@localhost 123456]# cat -n llll 1 hello words 2 hello words 3 hello words 4 hello words 5 hello words 6 hello words 7 hello words 8 hello words 9 hello words 10 hello words 11 hello words 12 hello words以带行号的形式查看文件.
[root@localhost 123456]# cat -n llll | head 1 hello words 2 hello words 3 hello words 4 hello words 5 hello words 6 hello words 7 hello words 8 hello words 9 hello words 10 hello words [root@localhost 123456]# cat -n llll | tail 3 hello words 4 hello words 5 hello words 6 hello words 7 hello words 8 hello words 9 hello words 10 hello words 11 hello words 12 hello words实在是很有意思,管道符的运用有时候很神奇,cat查看前十行/后十行的内容,也可以在tail -5andhead -5指定查看前5行或者后5行的内容
[root@localhost 123456]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 17G 3.6G 14G 21% / devtmpfs 974M 0 974M 0% /dev tmpfs 991M 0 991M 0% /dev/shm tmpfs 991M 11M 980M 2% /run tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/sda1 1014M 166M 849M 17% /boot tmpfs 199M 44K 199M 1% /run/user/1000 tmpfs 199M 0 199M 0% /run/user/0以人可以看得懂的方式查看硬盘使用消息
[root@localhost 123456]# hostname localhost.localdomain [root@localhost 123456]# hostname king [root@localhost 123456]# hostname kinghostname可以查看主机名,后面加上某个名字可以自卫一下,临时改变一下主机名,但是重新启动后就会恢复系统默认的,如果想永久的设置,命令为:
[root@localhost 123456]# hostnamectl set-hostname King [root@localhost 123456]# hostname king [root@localhost 123456]# whoami rootbash也非常智能,常用英语语句,who am i 可以查看当前正在使用的用户是谁
[root@localhost 123456]# w 15:28:54 up 46 min, 2 users, load average: 0.00, 0.01, 0.05 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT lzy :0 :0 14:46 ?xdm? 49.95s 0.14s /usr/libexec/gn lzy pts/0 :0 15:00 6.00s 0.24s 2.66s /usr/libexec/gn这个命令我觉得超好玩,输入w可以知道当前登录了哪些用户,以及他们正在系统中使用什么样的代码,可以监视别人,哈哈哈哈哈哈哈~
tar(选项)(文件)程老师说,这个命令很重要,嗷~那就了解一下: tar是将多个文文件打包为一个文件;将文件打包并压缩;将打包的文件解包;将打包压缩的文件解压 等等…… 简单来说,tar就是一个打包的命令
let me try 我的粘贴板出了一点问题...就手敲好了.. touch {1..6} 创建123456六个文件 tar -jcf lzyzip [0-6] 压缩这六个文件为lzyzip 此外,tar也可以作为解压,还可以解压到别的文件夹,操作如下 tar -xf lzyzip -C /root 解压这个文件到root家目录下 tar -zcf 使用gzip格式压缩 tar -jcf 使用bzip2格式压缩 tar -Jcf 使用 xz格式压缩 tar -xf 解压缩