Original file:
Find/etc-name passwd 2>&1 | Tee Ee.log
1. Cat-n The document contents of the E.log with the line number and enter E2.log in this document:
[Email protected] ~/t2scripts $ cat-n E.log |Tee E2.log1/etc/passwd2 3 4Find: '/etc/ntp/crypto': Permission denied 5Find: '/etc/audisp': Permission denied 6Find: '/etc/audit': Permission denied 7 8Find: '/etc/polkit-1/localauthority': Permission denied 9Find: '/etc/dhcp': Permission denied Ten/etc/pam.d/passwd OneFind: '/etc/lvm/backup': Permission denied AFind: '/etc/lvm/cache': Permission denied -Find: '/etc/lvm/archive': Permission denied -Find: '/etc/cups/ssl': Permission denied theFind: '/etc/pki/rsyslog': Permission denied - - - + - + AFind: '/etc/pki/ca/Private': Permission denied atFind: '/etc/vmware-tools/guestproxydata/trusted': Permission denied -Find: '/ETC/SUDOERS.D': Permission denied -Find: '/etc/selinux/targeted/modules/active': Permission denied
2. Cat-b appends the contents of the Textfile1 and textfile2 documents to the TEXTFILE3 document after adding the line number (blank line):
[Email protected] ~/t2scripts $ cat-b E.log |Tee E3.log1/etc/passwd2Find: '/etc/ntp/crypto': Permission denied 3Find: '/etc/audisp': Permission denied 4Find: '/etc/audit': Permission denied 5Find: '/etc/polkit-1/localauthority': Permission denied 6Find: '/etc/dhcp': Permission denied 7/etc/pam.d/passwd8Find: '/etc/lvm/backup': Permission denied 9Find: '/etc/lvm/cache': Permission denied TenFind: '/etc/lvm/archive': Permission denied OneFind: '/etc/cups/ssl': Permission denied AFind: '/etc/pki/rsyslog': Permission denied -Find: '/etc/pki/ca/Private': Permission denied -Find: '/etc/vmware-tools/guestproxydata/trusted': Permission denied theFind: '/ETC/SUDOERS.D': Permission denied -Find: '/etc/selinux/targeted/modules/active': Permission denied
3. Cat/dev/null empty the contents of the Ee.log document:
cat/dev/NULL
4. chattr +i: The file or directory shall not be arbitrarily altered.
[Email protected]/home/xiluhua/t2scripts $ chattr +/home/xiluhua/t2scripts $ rm-RF ttt.sh rm:cannot Remove ' ttt.sh': Operation not permitted
5. CHGRP (1)
[email protected]/home/xiluhua/t2scripts # Touch ttt.sh[email Protected] /home/xiluhua/t2scripts # ll ttt.sh -rw-r--r--. 1 root root 0 Jan : 22 ttt.sh[email protected] /home/xiluhua/t2scripts # chgrp Xiluhua ttt.sh [email protected] / Home/xiluhua/t2scripts # ll ttt.sh -rw-r--r--. 1 root xiluhua 0 Jan : 22 ttt.sh
6. CHGRP (2)
Bash Shell programming Exercises