选用课程是老男孩,采取完成课后作业的方式来写博客。
linux基础
查看当前登陆Linux系统所使用的用户名
[root@centos7 ~]# who root :0 2019-11-03 21:16 (:0) root pts/0 2019-11-03 21:17 (:0) root pts/1 2019-11-03 21:17 (192.168.228.1)
查看哪些用户在系统上工作
[root@centos7 ~]# whoami root [root@centos7 ~]# who am i root pts/1 2019-11-03 21:17 (192.168.228.1)
修改当前时间为2018年8月26号11:28
[root@centos7 ~]# date 082611282018 Sun Aug 26 11:28:00 CST 2018 [root@centos7 ~]# date Sun Aug 26 11:28:13 CST 2018
查看2015年10月份日历
[root@centos7 ~]# cal 10 2015 October 2015 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
新建tom用户,为tom用户设置密码“123”
切换当前用户为tom
查看当前登陆Linux系统所使用的用户名
[root@centos7 ~]# useradd tom [root@centos7 ~]# passwd tom Changing password for user tom. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [root@centos7 ~]# su - tom [tom@centos7 ~]$ whoami tom [tom@centos7 ~]$ who am i root pts/1 2019-11-03 21:17 (192.168.228.1)
使用命令切换到root用户的家目录
[tom@centos7 ~]$ su root Password: [root@centos7 tom]# cd ~ [root@centos7 ~]# pwd /root
创建目录wg
使用绝对路径的方法在wg目录下新建文件a.txt
进入wg目录
[tom@centos7 ~]$ mkdir wg [tom@centos7 ~]$ touch /home/tom/a.txt [tom@centos7 ~]$ cd /home/tom [tom@centos7 ~]$ pwd /home/tom
使用相对路径的方法在当前目录下新建wg01目录和b.txt文件
以长列表格式列出当前目录下的内容
[tom@centos7 ~]$ mkdir {wg01,b.txt} [tom@centos7 ~]$ ls -l total 0 -rw-rw-r--. 1 tom tom 0 Aug 26 11:46 a.txt drwxrwxr-x. 2 tom tom 6 Aug 26 12:03 b.txt drwxrwxr-x. 2 tom tom 6 Aug 26 11:46 wg drwxrwxr-x. 2 tom tom 6 Aug 26 12:03 wg01
删除空目录wg01
[tom@centos7 ~]$ rmdir wg01 [tom@centos7 ~]$ ls a.txt b.txt wg
强制删除非空目录wg
[tom@centos7 ~]$ rm -r wg [tom@centos7 ~]$ ls a.txt b.txt
复制/etc/passwd到当前目录,名为file1
[tom@centos7 ~]$ cp /etc/passwd /home/tom/file1 [tom@centos7 ~]$ ls a.txt b.txt file1
不停的以只读的方式查看file1文件的内容
查看file1文件的前3行内容
查看file1文件的后2行内容
[tom@centos7 ~]$ cat file1 [tom@centos7 ~]$ head -3 file1 root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/bin:/sbin/nologin daemon:x:2:2:daemon:/sbin:/sbin/nologin [tom@centos7 ~]$ tail -2 file1 durenli:x:1001:1001::/home/durenli:/bin/bash tom:x:1002:1002::/home/tom:/bin/bash
以百分比的方式分页查看file1文件的内容
以上下翻页的方法分页查看file1文件的内容
[tom@centos7 ~]$ more file1 [tom@centos7 ~]$ less file1