Linux学习笔记(三)基础命令

权限解说:r可读-4   w可写-2  x执行-1

        -rw-r--r--

           1文件类型  

           2 3 4 拥有者权限  

           4 5 6 组拥有权限

           7 8 9 其他人拥有的权限

        chomd 修改目录或文件权限 -R集联操作

drwxr-xr-x.   2 root root  4096 Nov 22  2013 cgroup <pre name="code" class="plain">第一个文件类型  rwx是拥有者权限为可读可写可执行  r-x是组权限为可读可执行   r-x是其他用户权限为可读可执行
 

 

编辑命令:分为模式和编辑模式

        vi [文件名]

        按键esc 进入命令行模式

        i插入(进入编辑模式)

        I进入行首插入

        A进入行尾编辑

        o光标移动到下一行并插入一行

        O光标移动到上一行并插入一行

        dd删除光标所在当前行

        D删除光标所在当前行并在当前行插入新行

        u撤销

        J删除空白行

        x删除光标所在的字符

        r[字符] 替换光标所在的字符

        cw删除光标所在处的的光标到单词尾部 并进入编辑模式

        dw删除光标所在处的光标到单词尾部

        caw删除光标所在处的整个单词

        :5顶定位行

        f[字符]查找当前行第一个[字符],继续点查找下一个

        :set nu 显示行号

        :set nonu 取消行号

        :wq保存退出

        :wq!强制保存 

        :q退出

        :q!强制退出

        y复制当前行,yy复制当前行开始两行

        p粘贴复制行

        Jo光标移动到最后一行并进入编辑模式

        ZZ保存退出

        ZQ不保存退出

        :%s@[字符串]@[字符串]    替换所有行的第一个[字符串]但区分大小写

        :%s@[字符串]@[字符串]@g  替换所有行的所有[字符串]但区分大小写

        :%s@[字符串]@[字符串]@gi 替换所有行的所有[字符串]不区分大小写

        /[字符串] 查找[字符串] N上一个 n 下一个

查看文件:

        cat 显示文件全部内容

        more 分屏查看  -[数字] 查看多少行

        tail 查看文件尾行 -[数字]查看后[数字]行

        head 查看首行 -[数字]查看前[数字]行

[root@root etc]# cat grub.conf    以cat查看文件全部内容
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-LogVol01
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Oracle Linux Server Unbreakable Enterprise Kernel (3.8.13-16.2.1.el6uek.x86_64)
	root (hd0,0)
	kernel /vmlinuz-3.8.13-16.2.1.el6uek.x86_64 ro root=/dev/mapper/VolGroup-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/LogVol01 SYSFONT=latarcyrheb-sun16   KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=VolGroup/LogVol00 rd_NO_DM rhgb quiet
	initrd /initramfs-3.8.13-16.2.1.el6uek.x86_64.img
title Oracle Linux Server Red Hat Compatible Kernel (2.6.32-431.el6.x86_64)
	root (hd0,0)
	kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/LogVol01 SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=VolGroup/LogVol00 rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-431.el6.x86_64.img

[root@root etc]# more -5 grub.conf     以more分屏查看文件内容
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.

[root@root etc]# head -8 grub.conf    以head查看前8行内容
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-LogVol01
#          initrd /initrd-[generic-]version.img

[root@root etc]# tail -3 grub.conf    以tail显示后三行的内容
tail: inotify cannot be used, reverting to polling
	root (hd0,0)
	kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-LogVol01 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/LogVol01 SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=VolGroup/LogVol00 rd_NO_DM rhgb quiet
	initrd /initramfs-2.6.32-431.el6.x86_64.img



bash在用户登录时从四个文件中读取环境设定:

        -全局设置文件:

             -etc/profile            不需要刷新生效一次就好

             -etc/bashrc             不需要刷新生效一次就好

        -用户设置文件:

              ~/.bashrc              每一回都需要再次刷新生效除root用户设定

              ~/.bash_profile        不需要刷新生效一次就好



rpm的安装和卸载:

        rpm -i     安装

        rpm -U     升级

        rpm -F     更新

        rpm -e     卸除




散点:

       cp 复制文件 -r复制路径 -p保留原属性

       mv 移动 -p保留原属性 -r移动路径上

       rm 删除 -i提示 -f强制删除不提示 -r递归删除

       df  查看分区使用情况    df -h  以(M,G)显示

[root@root etc]# df     用df查看分区
Filesystem                    1K-blocks    Used Available Use% Mounted on
/dev/mapper/VolGroup-LogVol01  94617444 3960256  85844184   5% /
tmpfs                           2024352     300   2024052   1% /dev/shm
/dev/sda1                        194241   55290    128711  31% /boot
/dev/sr0                          57620   57620         0 100% /media/VBOXADDITIONS_5.0.10_104061
[root@root etc]# df -h    用df -h 显示内存使用大小情况
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01   91G  3.8G   82G   5% /
tmpfs                          2.0G  300K  2.0G   1% /dev/shm
/dev/sda1                      190M   54M  126M  31% /boot
/dev/sr0                        57M   57M     0 100% /media/VBOXADDITIONS_5.0.10_104061

       kill      干掉一个进程    kill -9   强制干掉一个进程

       hostname 显示当前主机名 

       free 显示内存使用状况 

[root@root etc]# free    用free显示内存使用状况
             total       used       free     shared    buffers     cached
Mem:       4048708     549824    3498884          0      34884     237164
-/+ buffers/cache:     277776    3770932
Swap:      8388604          0    8388604

       top 动态的电脑资源状况  ps 查看进程  -ef查看所有进程

       /var/log/messages*    系统运行日志

       /路径/脚本名 运行shell脚本命令

       ./路径/脚本名         sh /路径/脚本名

       uname -r 查看系统版本

       linux   --man  查看帮助    oracle --help  查看帮助     q退出查看




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值