RHCSA(三)

1.创建目录test,使用两种方式在test目录中创建文本文件text1.txt, text2.txt

[root@localhost ~]$ mkdir text
[root@localhost ~]$ cd test
[root@localhost test]$ touch text1.txt 
[root@localhost test]$ vim text2.txt

使用Vim在文件text1.txt中写入
 Welcome to my Linux.
 You are the best.
 This is my first file to create on linux
         设置行号,并将文本中my替换成your,将文件另存为new_test1.txt

1 Welcome to my Linux.
  2  You are the best.
  3  This is my first file to create on linux
~                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
:set nu
1 Welcome to your Linux.
  2  You are the best.
  3  This is your first file to create on linux
                                                                                                                                                                                                                
~                                                                                                                                                                                                                 
:% s/my/your/g
1 Welcome to your Linux.
  2  You are the best.
  3  This is your first file to create on linux
                                                                                                                                                                                                     
:"~/test/new_test1.txt" [New] 3L, 108C written

将test中的文件拷贝到test2目录

[rhcsa@localhost ~]$ cp -a test test2

将test2目录中的test1.txt重命名为test111.txt

[root@localhost test2]$ mv test1.txt test111.txt

在test2目录中新建test111.txt的软链接文件 test111_symb.txt

[root@localhost test2]$ ln -s text111.txt test111_symb.txt

在test2目录中新建test111.txt的硬链接文件 test111_hard.txt

[root@localhost test2]$ ln text111.txt test111_hard.txt

删除test目录中test1.txt
删除test目录

[root@localhost ~]$ cd /root/test/
[root@localhost test]$ rm -rf test1.txt
[root@localhost test]$ cd ~
[root@localhost ~]$ rm -rf test

2.将echo "This is my first time to use pipe"内容输出到屏幕上,且保存到pipe_data.txt中

[rhcsa@localhost ~]$ echo "This is my first time to use pipe" | tee pipe_data.txt
This is my first time to use pipe

3.文件内容浏览
  a.cat查看/etc/passwd文件内容,且输出时带行号

[rhcsa@localhost ~]$ cat -n /etc/passwd
     1	root:x:0:0:root:/root:/bin/bash
     2	bin:x:1:1:bin:/bin:/sbin/nologin
     3	daemon:x:2:2:daemon:/sbin:/sbin/nologin
     4	adm:x:3:4:adm:/var/adm:/sbin/nologin
     5	lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
     6	sync:x:5:0:sync:/sbin:/bin/sync
     7	shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
     8	halt:x:7:0:halt:/sbin:/sbin/halt
     9	mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
    10	operator:x:11:0:operator:/root:/sbin/nologin
    11	games:x:12:100:games:/usr/games:/sbin/nologin
    12	ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
    13	nobody:x:65534:65534:Kernel Overflow User:/:/sbin/nologin
    14	dbus:x:81:81:System message bus:/:/sbin/nologin
    15	systemd-coredump:x:999:997:systemd Core Dumper:/:/sbin/nologin
    16	systemd-resolve:x:193:193:systemd Resolver:/:/sbin/nologin
    17	tss:x:59:59:Account used for TPM access:/dev/null:/sbin/nologin
    18	polkitd:x:998:996:User for polkitd:/:/sbin/nologin
    19	geoclue:x:997:995:User for geoclue:/var/lib/geoclue:/sbin/nologin
    20	rtkit:x:172:172:RealtimeKit:/proc:/sbin/nologin
    21	pipewire:x:996:992:PipeWire System Daemon:/var/run/pipewire:/sbin/nologin
    22	pulse:x:171:171:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
    23	qemu:x:107:107:qemu user:/:/sbin/nologin
    24	clevis:x:995:989:Clevis Decryption Framework unprivileged user:/var/cache/clevis:/sbin/nologin
    25	usbmuxd:x:113:113:usbmuxd user:/:/sbin/nologin
    26	unbound:x:994:988:Unbound DNS resolver:/etc/unbound:/sbin/nologin
    27	gluster:x:993:987:GlusterFS daemons:/run/gluster:/sbin/nologin
    28	rpc:x:32:32:Rpcbind Daemon:/var/lib/rpcbind:/sbin/nologin
    29	avahi:x:70:70:Avahi mDNS/DNS-SD Stack:/var/run/avahi-daemon:/sbin/nologin
    30	chrony:x:992:986::/var/lib/chrony:/sbin/nologin
    31	setroubleshoot:x:991:984::/var/lib/setroubleshoot:/sbin/nologin
    32	saslauth:x:990:76:Saslauthd user:/run/saslauthd:/sbin/nologin
    33	libstoragemgmt:x:989:983:daemon account for libstoragemgmt:/var/run/lsm:/sbin/nologin
    34	dnsmasq:x:981:981:Dnsmasq DHCP and DNS server:/var/lib/dnsmasq:/sbin/nologin
    35	radvd:x:75:75:radvd user:/:/sbin/nologin
    36	sssd:x:980:980:User for sssd:/:/sbin/nologin
    37	cockpit-ws:x:979:979:User for cockpit web service:/nonexisting:/sbin/nologin
    38	cockpit-wsinstance:x:978:978:User for cockpit-ws instances:/nonexisting:/sbin/nologin
    39	flatpak:x:977:977:User for flatpak system helper:/:/sbin/nologin
    40	colord:x:976:976:User for colord:/var/lib/colord:/sbin/nologin
    41	rpcuser:x:29:29:RPC Service User:/var/lib/nfs:/sbin/nologin
    42	gdm:x:42:42::/var/lib/gdm:/sbin/nologin
    43	gnome-initial-setup:x:975:975::/run/gnome-initial-setup/:/sbin/nologin
    44	tcpdump:x:72:72::/:/sbin/nologin
    45	sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
    46	rhcsa:x:1000:1000:rhcsa:/home/rhcsa:/bin/bash

b.使用more/less查看/etc/passwd内容,且每页显示10行
 

[rhcsa@localhost ~]$ more -10 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin

c.使用head/tail分别查看文件前5行内容和后5行内容

[rhcsa@localhost ~]$ head -5 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
[rhcsa@localhost ~]$ tail -5 /etc/passwd
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
gnome-initial-setup:x:975:975::/run/gnome-initial-setup/:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
rhcsa:x:1000:1000:rhcsa:/home/rhcsa:/bin/bash

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值