Linux basic commands (4)

Several basic directory files in linux
http://blog.51cto.com/13523981/2055286 (more detailed here)


File system storage is probably, this theory is not very easy to understand. (You can check it online) The
file system is roughly:
superblock (occupied space - total)
inode (index information)
block (data size)


Link
1. Hard link ln source file target file (cannot operate on directories, cannot cross operating systems, delete one of them will not affect other files) (hard links are more like copy and paste in windows, but can operate on folders )

 [root@localhost boke]# ls -i  (显示出文件/目录的inode)
 918011 1  942691 2  942692 3  931215 a  925186 a1b  931292 b  782599 c  931764 file  931388 file1  942690 no  931296 vim
 [root@localhost boke]# ll -i
total 0
912130 -rw-r--r--. 2 root root 0 Apr 23 12:27 fu
912130 -rw-r--r--. 2 root root 0 Apr 23 12:27 yaun
[root@localhost boke]# echo 1 > yaun 
[root@localhost boke]# cat fu 
1
[root@localhost boke]# echo 2 > fu 
[root@localhost boke]# cat yaun 
2
[root@localhost boke]# cat fu 
2
[root@localhost boke]# mkdir mulu
[root@localhost boke]# ln mulu/ mulu2
ln: `mulu/': hard link not allowed for directory(不能对目录进行链接)
[root@localhost boke]# 

2. Soft link ln -s source file target file (can operate on the directory, can use different inodes across the system source and target, all your operations on the target file are modifying the source file, if the source file has a hard link , then all files will be modified, delete soft links, do not affect the source, delete the source affects all linked files)
(soft links are more like shortcuts in windows)

[root@localhost boke]# ll -i
total 12
912130 -rw-r--r--. 2 root root    2 Apr 23 12:28 fu
918011 drwxr-xr-x. 2 root root 4096 Apr 23 12:30 mulu
925186 lrwxrwxrwx. 1 root root    5 Apr 23 12:47 mulu2 -> mulu/
912130 -rw-r--r--. 2 root root    2 Apr 23 12:28 yaun
[root@localhost boke]# echo 1 > mulu/1 
[root@localhost boke]# cat mulu/1 
1
[root@localhost boke]# cat mulu2/1 
1
[root@localhost boke]# 


find command

  1. ls -R directory (recursively find all files/directories under a directory)
  2. whereis (7 system, find the specified command)
  3. which command (alias variable, type which sees the command type)
  4. locate file name (non-real-time, fuzzy query, fast) (search according to the /var/lib/mlocate/mlocate.db database, updatedb update the database
    
    [root@localhost boke]# cat /etc/cron.daily/mlocate.cron (定时任务来更新此数据库)
    #!/bin/sh
    nodevs=$(< /proc/filesystems awk '$1 == "nodev" { print $2 }')
    renice +19 -p $$ >/dev/null 2>&1
    ionice -c2 -n7 -p $$ >/dev/null 2>&1
    /usr/bin/updatedb -f "$nodevs"

[root@localhost boke]# vim /etc/updatedb.conf
PRUNEPATHS = "/afs /media /net /sfs /tmp /udev /var/cache/ccache /var/spool/cups /var/spool/squid /var/ tmp" (do not update these places when updating)



-----

5.find 路径  查找条件  找到后的动作(条件可以连用     默认动作:打印)
   条件:name,type,size,perm...

   例子:[root@localhost boke]# find /etc/ -name *.conf -exec 命令 {}  路径 \;(分两步!可以与重定向,管道...连用  先执行-exec前面的部分,然后每执行一行就写入到{}里面  \;是换行和结束符)(-exec可以替换成-ok,变成交互式)
/etc/sudo.conf
/etc/php-fpm.d/www.conf
/etc/ld.so.conf
/etc/named.conf
/etc/fprintd.conf
/etc/ntp.conf
......

-----

-----

bash简介
1.history(命令缓存历史)
!+ 数字 执行命令历史换成的对应指令
!! 执行上一条命令
!$  上一条命令的参数
ctrl + r  搜索关键字

-----

alias 查看当前用户所有别名
alias   新名字='命令'(立即生效)
alias  一般写到家目录下文件的环境变量(永久生效)(执行一下文件或重启都可以)

-----

tab(键盘上的)(补全功能   按一下显示唯一条件,按两下是不唯一条件)

-----

ctrl + a(跳命令行行首)
ctrl + e(跳命令行行尾)
ctrl + l(清屏)
ctrl + c(终端)
ctrl + d(推出当前用户)

-----

今晚,发一篇简单的DNS+邮件服务器的搭建。

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326842671&siteId=291194637