初涉linux(二)

2.linux文件与目录命令
2.1 讲义
2.1.1.vi以单词为单位
b w 以单词为单位向前 向后移动
db dw //delete a word for each before/after
s 替换
2.1.2.ftp服务器
在/etc/vsftpd/下,注释掉ftpusers 与root
getsebool -a
setsebool ftp_home_dir=1
service vsftpd restart
service iptables restart
2.1.3. //mknod add a device
系统目录
比较重要的几个:
/etc存放了各种配置文件
/dev 各种外部设备文件
/lib 存放系统的动态链接共享库
/root /home /usr
2.1.4.cd
cd /path/directory
cd ./path/directory
cd ..
cd .
cd
cd -
2.1.5.
ls
ln -s filename linkname//soft link
ln filename linkname //hard link ;同步更改
2.1.6.cat
cat -n //标行号
cat -s //多于一行空白只显示一行空白
cat -b //不对空白行编号
nl filename //the same as cat -n
head/tail -n N filename
2.1.7.
cp -r newDirectoryName oldDirectory
mv newDir oldDir
2.1.8.
grep -A2 -B2 --color=auto -e pattern filename
grep -A3 -B2 --color=auto --include=/etc/pass* -e "bae\+" /etc/* //显示etc下跟密码有关文件中与用户bae有关的前2后3行数据
2.1.9.用户和组命令(/etc/passwd shadow login.defs /etc/default/useradd /etc/skel/ /etc/group)
/etc/passwd
/etc/shadow //用户配置有关文件
/etc/group //组配置有关文件
useradd
usermod
userdel

groupadd
groupmod old_user -u new_user
groupdel
2.1.10.
chown user:group filename
chgrp
umask //用户新建文件默认权限
chmod 777 filename
chmod ug+rw filename
2.1.11
lsattr
chattr +ai filename
2.2扩展
2.2.1 以find及ls命令理解文件的各种状态
Find 中有几个参数-atime –ctime –mtime,如何去理解这些时间,首先以ls命令的--time来说明:
Man ls 中有
[quote]with -l, show time as WORD instead of modification time: atime
-u, access -u, use -u, ctime -c, or status -c; use specified
time as sort key if --sort=time[/quote]
侧面反映了对于每个文件都有最后访问时间(atime,access,use),最后状态改变时间(ctime,status)。而find中的-atime就与最后访问时间相关;-ctime与最后状态改变时间有关;经测试过后,-mtime也与最后状态更改时间有关。
由于min与time只是时间上的差别,这里测试使用--amin --cmin –mmin
1>create test.c
ls –time=atime –l test.c
-rw-r—r— 1 root root 0 2009-02-28 14:09 test.c
Ls --time=status –l test.c
-rw-r—r— 1 root root 0 2009-02-28 14:09 test.c
2>view test.c //cat test.c
Ls --atime=atime –l test.c
-rw-r—r— 1 root root 0 2009-02-28 14:10 test.c
Ls --time=status –l test.c
-rw-r—r— 1 root root 0 2009-02-28 14:09 test.c
3>test the follow command in one minute
find . –amin -4
find . –cmin -4
find . –mmin -4
-cmin –mmin相同,由此就说明在文件数据变更时,文件的状态也改变了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值