Practical Linux - Part 10 - File Operation & Searching | 文件操作与搜索
- Nov 4 - File Operation & Searching
- http://vbird.dic.ksu.edu.tw/linux_basic/0220filemanager.php
- linux.vbird.org/linux_basic/0330regularex.php
- Wildcard
- Searching
which [-a]
for command
- for file
whereis
locate [-ir]
locate passwd
- search from db
updatedb
find
find / -mtime 0
find /etc -newer /etc/passwd
find /home -user ubuntu
find / -name passwd
find /var -type f
find /etc -name passwd -exec cat {} \;
find / -size +1000k
find /etc -name '*ssh*'
- Regex
grep
last | grep 'root'
last | grep -v 'root'
dmesg | grep 'eth'
dmesg | grep -n 'eth'
sed
awk
- Assignment
- log on your amazon vm
- use
find
to find all the files under your home directory which has been modified within 3 weeks
- use
grep
to find all the files containing *
under /etc
- use
sed
to replace ‘exit’ in file .bash_history
with ‘exat’