zoukankan      html  css  js  c++  java
  • centos 目录结构 快捷键 ls命令,alias别名,so:动态库 a:静态库,环境变量PATH,Ctrl+z 暂停命令,Ctrl+a 光标到行首,Ctrl+e 光标到行尾,Ctrl+u 删除光标前所有字符 Ctrl+r 搜索命 hash命令 Ctrl+左箭头/右箭头 cd命令 第三节课

    centos 目录结构 快捷键 ls命令,alias别名,so:动态库 a:静态库,环境变量PATH,Ctrl+z 暂停命令,Ctrl+a 光标到行首,Ctrl+e 光标到行尾,Ctrl+u 删除光标前所有字符 Ctrl+r 搜索命 hash命令  Ctrl+左箭头/右箭头 cd命令  第三节课

    上半节课

    ls命令

    下半节课

    alias别名

    so:动态库 a:静态库

    环境变量PATH

    Ctrl+z 暂停命令

    Ctrl+a 光标到行首

    Ctrl+e 光标到行尾

    Ctrl+u 删除光标前所有字符

    hash命令

    ls命令

    目录或者文件最后更改时间

    ls -a  --显示隐藏文件和目录,.开头的文件和目录
    ls -ld  --只显示目录
    ls -lt  --最新的显示在最上头,文件最近什么时候更新的
    ls -lh  --显示文件的大小,但是不能显示目录下各文件之和大小,只能显示目录的大小
    ls -li  --查看inode
    ls -R   --递归显示当前目录和下级子目录的文件和目录内容
    ls -lhS  --按文件大小排序

    alias别名

    [root@steven ~]# alias aming='ls /tmp/'
    [root@steven ~]# aming
    1.txt  yum_save_tx-2015-03-18-13-02DUsJHx.yumtx

    [root@steven ~]# ls /tmp/
    1.txt  yum_save_tx-2015-03-18-13-02DUsJHx.yumtx
    [root@steven ~]#

    --查看当前有哪些alias

    要永久生效需要 添加在/etc/rc.d/rc.local

    [root@steven ~]# alias
    alias aming='ls /tmp/'
    alias cman='man -M /usr/local/zhman/share/man/zh_CN'
    alias cp='cp -i'
    alias l.='ls -d .* --color=auto'
    alias ll='ls -l --color=auto'
    alias ls='ls --color=auto'
    alias mv='mv -i'
    alias rm='rm -i'
    alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'

    --取消别名

    unalias aming

    s:是超级权限的意思

    sbin:super  binary

    软链接

    /etc/grub.conf -> /boot/grub/grub.conf


    目录

    so:动态库 a:静态库

    查看动态库依赖,一般在/lib下

    ldd /bin/ls

    /bin, /sbin, /usr/bin, /usr/sbin 放命令的目录,/sbin是超级用户root才可以用的命令
    /boot Linux内核及引导系统程序所需要的文件目录
    /dev 存放的是Linux的外部设备
    /etc/ 配置文件目录
    /home 用户家目录 命令:useradd
    /lib ,/lib64 命令: ldd ,存放必备的共享库和内核模块,系统启动和运行根文件系统的各种命令时都要用到共享库,所以需要放在根文件系统下一起加载,如果是x86_64,这个目录部分功能会转到/lib64目录,但内核模块只会使用/lib目录,无论是否是64位系统,内核模块放在/lib/modules目录下
    /usr/lib ,/usr/lib64:共享库文件和目标文件,如果是64位x86_64系统,这个目录功能转移到/usr/lib64目录下
    /media, /mnt
    /opt 是存放某些大型软件或者某些特殊软件的目录,现在很少有人安装在/opt目录,只有一些少数软件非得安装在/opt才会安装在/opt目录,例如:Oracle,一般配置文件放在/etc/opt下,可变更文件放在/var/opt下
    echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
    /root root用户家目录
    /selinux
    /srv 存放一些服务启动之后需要提取的中间数据
    /proc 系统内核映射 伪文件系统
    /sys 伪文件系统
    /sys/class 包含所有注册在kernel里面的设备类型,链接到device
    /sys/dev 维护一个按照字符设备和块设备的主次号码列表,链接到device
    /sys/device 是全局设备结构体系,包含所有被发现的注册在各种总线上的各种物理设备,是内核对系统中所有设备的分层次表达模型,也是/sys文件系统管理设备的最重要的目录结构
    /sys/fs 描述系统中所有的文件系统
    /sys/kernel 存放的是内核中所有可调整的参数
    /tmp 临时文件
    /usr user share readonly, 用户程序存放目录,类似win program files文件夹,安装完Linux后,/usr目录最大
    /var 存放着在不断扩充着的东西,我们习惯将那些经常被修改的目录放在这个目录下。包括各种日志文件。

     

     

    cron任务计划会存放在/var/spool/cron下

    cd  后面不加东西,就是进入到当前用户的家目录
    cd ~  这里的~符号也表示用户的家目录
    cd -  切换到上一次所在的目录
    cd .  ..   其中.表示当前目录, ..表示上一级目录

    pwd 相当于 pwd -L

    默认显示软链接目录,如果有软链接

    pwd -P

    显示真正的目录

    L logical

    P physical

     [root@steven ~]# ll /etc/sysconfig/
    总用量 216
    -rw-r--r--  1 root root  403 10月 18 2014 atd
    -rw-r-----  1 root root  992 10月 15 2014 auditd
    -rw-r--r--. 1 root root  398 1月  26 2015 authconfig
    -rw-r--r--  1 root root  339 1月   5 2015 autofs
    drwxr-xr-x. 2 root root 4096 3月  10 12:04 cbq
    -rw-r--r--  1 root root  486 10月 18 2014 cgconfig
    -rw-r--r--  1 root root  950 10月 18 2014 cgred.conf
    -rw-r--r--. 1 root root   21 1月  26 2015 clock
    drwxr-xr-x. 2 root root 4096 11月  4 2014 console
    -rw-r--r--  1 root root 2651 8月  13 2013 cpuspeed
    -rw-------  1 root root  110 11月 23 2013 crond
    drwxr-xr-x. 2 root root 4096 2月   2 2015 daemons
    -rw-r--r--. 1 root root   25 1月  26 2015 grub
    -rw-r--r--  1 root root  529 8月  15 2014 htcacheclean
    -rw-r--r--  1 root root  947 8月  15 2014 httpd
    -rw-r--r--  1 root root   47 3月  12 17:04 i18n
    -rw-r--r--  1 root root 1154 11月  4 2014 init
    -rw-------. 1 root root  481 1月  26 2015 ip6tables
    -rw-------  1 root root 1988 10月 15 2014 ip6tables-config
    -rw-------. 1 root root  481 1月  26 2015 ip6tables.old
    -rw-------. 1 root root  476 1月  26 2015 iptables
    -rw-------  1 root root 1974 10月 15 2014 iptables-config
    -rw-------. 1 root root  476 1月  26 2015 iptables.old
    -rw-r--r--  1 root root  903 6月   2 2014 irqbalance
    -rw-r--r--  1 root root 1212 10月 16 2014 kdump
    -rw-r--r--  1 root root  180 3月  10 12:05 kernel
    -rw-r--r--. 1 root root   63 1月  26 2015 keyboard
    -rw-r--r--  1 root root  271 10月 15 2014 mcelogd
    drwxr-xr-x. 2 root root 4096 11月  4 2014 modules
    -rw-r--r--  1 root root  634 11月  4 2014 netconsole
    -rw-r--r--  1 root root   43 3月   5 2015 network
    drwxr-xr-x. 4 root root 4096 11月  4 2014 networking
    drwxr-xr-x. 2 root root 4096 4月  24 14:09 network-scripts
    -rw-r--r--  1 root root 2222 10月 16 2014 nfs
    -rw-r--r--  1 root root   85 12月 20 2014 ntpd
    -rw-r--r--  1 root root  167 12月 20 2014 ntpdate
    -rw-r--r--  1 root root 1459 7月  19 2013 prelink
    -rw-r--r--  1 root root  178 3月   5 2014 quota_nld
    -rw-r--r--  1 root root 2585 11月 12 2014 raid-check
    -rw-r--r--  1 root root  549 11月 23 2013 readahead
    -rw-r--r--  1 root root  659 11月  4 2014 readonly-root
    -rw-r-----. 1 root root   41 12月 18 2011 rngd
    -rw-r--r--  1 root root  200 12月 10 2014 rsyslog
    -rw-r--r--  1 root root  111 2月  23 2015 samba
    -rw-r--r--  1 root root  136 10月 18 2014 sandbox
    -rw-r--r--  1 root root  553 11月 18 2014 saslauthd
    lrwxrwxrwx. 1 root root   17 1月  26 2015 selinux -> ../selinux/config
    -rw-r--r--. 1 root root  125 2月  22 2013 smartmontools
    -rw-r-----. 1 root root  438 11月 13 2014 sshd
    -rw-r--r--. 1 root root  473 10月 16 2014 sysstat
    -rw-r--r--. 1 root root 6253 10月 16 2014 sysstat.ioconf
    -rw-------. 1 root root   73 1月  26 2015 system-config-firewall
    -rw-------. 1 root root   71 1月  26 2015 system-config-firewall.old
    -rw-r--r--  1 root root  183 10月 16 2014 udev

    环境变量PATH的用法
    echo $PATH 可以查看系统的环境变量PATH的值,使用which命令可以查看某个命令所在的绝对路径
    PATH=$PATH:/tmp  这样我们可以使用/tmp/下面的可执行文件作为命令
    让PATH永久生效的,需要把它加入到/etc/profile 里,重启生效,或者直接运行命令: 
    source  /etc/profile

    alias设置命令的别名,例如 alias aming='ls -lt'  
    解除别名使用 unalias  aming 
    让别名永久生效,需要把设置别名的命令,加入到 ~/.bashrc 里

    root用户的配置文件:~/.bashrc



    5. 快捷键

    tab:补全命令和路径
    Ctrl+c 取消命令
    Ctrl+z 暂停命令
    Ctrl+a 光标到行首
    Ctrl+e 光标到行尾
    Ctrl+u 删除光标前所有字符
    Ctrl+k 删除光标后所有字符
    Ctrl+l 清屏
    Ctrl+d 退出登录/shell == exit,结束输入, 比如wc命令和sort命令如果不加文件名会等待标准输入Ctrl+d可以结束输入
    Ctrl+s 锁住命令终端,按任何键都不会有反应
    Ctrl+q 解锁命令终端
    Ctrl+r 搜索命令 比如ctrl + r ls 再输入一次 ctrl + r 会从最后一次ls或命令中包含ls的命令列出来
    Ctrl+左箭头/右箭头 以单词为单位进行移动



    扩展阅读

    # du -sh --max-depth=1   /   #--max-depth=1  ,根分区
    0 /misc
    244K /dev
    4.0K /media
    48M /boot
    225M /var
    2.2G /usr
    4.0K /aming
    4.0K /srv
    4.3G /root
    4.0K /selinux
    28M /lib64
    4.0K /testsdb1
    7.8M /bin
    4.0K /mnt
    4.0K /cgroup
    37M /etc
    255M /lib
    52K /tmp
    4.0K /.ssh
    4.0K /testsdb3
    16K /lost+found
    73M /data
    0 /net
    du: 无法访问"/proc/2818/task/2818/fd/4": 没有那个文件或目录
    du: 无法访问"/proc/2818/task/2818/fdinfo/4": 没有那个文件或目录
    du: 无法访问"/proc/2818/fd/4": 没有那个文件或目录
    du: 无法访问"/proc/2818/fdinfo/4": 没有那个文件或目录
    0 /proc
    4.0K /download1
    8.0K /123
    0 /sys
    787M /download
    8.0K /opt
    284K /home
    15M /sbin
    7.9G /

    大目录
    4.3G /root
    2.2G /usr
    7.9G /


    ls /var  马哥  Linux就这个范儿

    通常情况下,应用程序不得在/var顶层添加任何目录,这个位置只留给那些影响到整个系统的软件,而且还需经过Linux社区商量决定是否添加(比如nginx的访问日志最好在/var下创建一个nginx目录,例如/var/log/nginx/error.log)

    /var下的目录
    account :系统审计程序psacct的专有目录,psacct程序可以监控所有用户执行的命令。
    lock :两个人同时编辑一个文件,用于硬件设备和其他被多个程序所共享的资源,例如串行设备锁文件,锁文件命名方式必须是LCK..后接设备和本名,例如进程是1230的锁文件,它的锁文件内容将包含11个字符:空格 空格 空格 空格 空格 空格 空格 1、2、3、0和换行符
    run :守护进程的pid文件一般放这里,系统启动进程开始的时候会清空这个目录,一般程序在/var/run目录下有一个子目录(/var/run/nginx/nginx.pid),鼓励程序使用不止一个运行时文件,pid文件命名规则是<程序名>.pid
    必须以ascii码数字字符描述进程标识符
    cache:应用程序缓存数据,应用程序必须能再生或恢复这些数据,和/var/spool不同,删除缓存文件不会造成数据丢失错误
    lib :进程信息,应用程序状态信息,应用程序运行期间保存程序所处的状态,/var/lib/misc给不需要单独子目录的程序
    log :进程日志一般放这里,各种日志文件,lastlog、message、wtmp
    spool :spool有mail目录和cron目录,redhat是放用户的邮件 cron放定时任务文件,供以后用的(可以被程序、用户、管理员处理),一旦被处理完毕都会被删除。
    mail :非redhat是放用户的邮件
    opt:/opt下软件包的可变数据都应该安装到/var/opt子目录中去,子目录名应该和/opt下子目录名称一样
    tmp:/var/tmp目录使得程序要求在系统重启期间保护临时文件或目录成为可能,因此保存在/var/tmp目录中的数据,比/tmp中的数据得到更多保护。/var/tmp目录中数据在系统启动时不得删除

    两个伪文件系统
    /proc 内核信息
    /sys 内核信息 硬件设备相关的
    /misc 存放杂项文件,乱七八糟的文件,默认一般是空的

    nginx编译安装

    cd /software/nginx-1.4.6 && ./configure --sbin-path=/usr/sbin/nginx 
    --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx/nginx.pid 
    --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log 
    --user=nginx --group=nginx --with-pcre --with-http_gzip_static_module --with-http_ssl_module 
    --with-http_realip_module --with-http_geoip_module --with-http_stub_status_module 
    --add-module=/usr/local/nginx_upstream_check_module-master 
    --add-module=/usr/local/ngx_cache_purge-2.1 --with-http_gunzip_module 
    --add-module=/usr/local/ngx_req_status-master && make -j2 && make install

    hash命令

    bash shell特有功能,记住你执行过的命令,在hash表里找

    # hash
    hits command
    1 /usr/bin/tail
    1 /usr/bin/file
    3 /usr/bin/du
    1 /bin/env
    14 /bin/ls

    mv  /usr/bin/wc  /bin
    wc /etc/passwd
    -bash: /bin/wc: 没有那个文件或目录

    因为缓存了wc命令,bash shell在hash表找不到那个命令,这时候需要清空一下hash表

    hash -r 清空hash表

    下次移动了系统里面的命令记得执行一下hash -r

    mv /usr/bin/wc /bin
    hash -r

    bin目录

    /bin 二进制 ,为所有用户使用,不得包含任何子目录
    /sbin 二进制 ,为管理员所用,存储的是那些系统启动,恢复,还原,修复过程中必备系统工具,也是对/bin内容的补充,那些已知在/usr挂接后才需要的程序一般放在/usr/sbin下,用户自行安装的程序应该放在/usr/local/sbin目录下
    /usr 系统运行相关文件 Linux系统源码等 user share readonly
    /usr/bin 所有用户使用 系统启动时或启动后的用户程序
    /usr/sbin 系统软件 系统启动时或启动后的系统程序
    /usr/local/bin 第三方软件 所有用户使用
    /usr/local/sbin 第三方软件 系统软件

    redhat现在很少按照上面的目录来区分



    # echo $PATH
    /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

    搜索顺序从左到右,局部大于全局/usr/local/sbin-》/usr/local/bin-》/usr/sbin-》/usr/bin-》/sbin-》/bin


    命令帮助

    内部命令:help command
    外部命令:command --help
    man command

    man 一个命令

    []:可选内容
    <>:必须给出内容
    | :或者
    [|] :多选一


    cd命令

    cd ~steven 用户家目录
    cd - 上一次目录
    cd ../.. 上层再上层目录,不是根分区开头/的都是相对路径,相对于当前目录
    cd ~当前用户家目录


    /usr/share目录

    Linux就这个范儿


    存放着所有体系结构无关的数据文件,他的内容可以共享给运行在任何体系结构下的操作系统,但必须保证它们运行的是不同体系结构平台的相同操作系统。


    必须安装在/usr/share目录下的内容
    dict,doc,games,info,locale,nls,sgml,terminfo,tmac,xml,zoneinfo 时区配置信息
    /bin/cp /usr/share/zoneinfo/Asia/Shanghai   /etc/localtime   #校对时区

    /usr/share目录下必须具备的内容
    man 目录
    misc 目录

    手册页
    /usr/share/man/专为联机帮助而准备,包含了/和/usr下大部分程序的帮助信息,从man1到man8
    ll /usr/share/man/
    drwxr-xr-x. 2 root root 36864 Jan 29 16:15 man1
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man1p
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man1x
    drwxr-xr-x. 2 root root 4096 Jul 10 2015 man2
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man2x
    drwxr-xr-x. 2 root root 49152 Jan 29 16:15 man3
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man3p
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man3x
    drwxr-xr-x. 2 root root 4096 Jan 8 08:38 man4
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man4x
    drwxr-xr-x. 2 root root 4096 Jan 19 21:11 man5
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man5x
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man6
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man6x
    drwxr-xr-x. 2 root root 4096 Jan 3 23:44 man7
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man7x
    drwxr-xr-x. 2 root root 20480 Jan 12 12:59 man8
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man8x
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man9
    drwxr-xr-x. 2 root root 4096 Sep 23 2011 man9x

    /usr/share/misc目录存放那些不需要拥有自己目录的应用程序,将它们的体系结构无关数据放在这里
    ascii码表
    file命令的文件特征符号表

    f

  • 相关阅读:
    查看linux cpu和内存利用率__linux - top命令
    Maven仓库管理Nexus(转帖后加强版)
    实现系统菜单的两种方式
    使用Iterator遍历数组
    Android自定义退出弹出框
    AsyncTask的学习
    Android中常用到的权限
    Java集合
    Android中以文件的形式保存数据
    Android仿微信的开机滑动界面
  • 原文地址:https://www.cnblogs.com/MYSQLZOUQI/p/4790213.html
Copyright © 2011-2022 走看看