Linux 学习笔记(一)
其他
2018-11-26 08:51:06
阅读次数: 0
shell的版本:
/bin/sh
/bin/bash *
/sbin/nologin
/bin/tcsh
/bin/csh
外部命令:任何一个外部命令都是一个可执行的文件,例如ls,外部命令保存在硬盘上
内部命令:shell解释器的一部分,例如cd,内部命令保存在内存中
复制:ctrl+shift+c
粘贴:ctrl+shift+v
复制粘贴:选中,按下滚轴
help cd 内部命令帮助,内部命令少
man ls 外部命令帮助,外部命令多
ls --help
目录操作命令:
cd - 上一次目录
cd .. 上一级目录
linux中不记录创建日期
ls -lh 可以显示文件大小(以K,M,G等单位)
ls -ld /etc 显示/etc本身目录的属性
alias 建立别名
alias la="ls -a"
unalias 删除别名
unalias la
mkdir -p /test/a{1,2}/b{1..5}
ls -R test/ 递归查询test文件夹,R注意大小写
/test/a1:
b1 b2 b3 b4 b5
/test/a2:
b1 b2 b3 b4 b5
du -sh /etc/ 显示/etc文件内的大小
ls -lhd /etc 显示/etc本目录文件的大小
drwxr-xr-x. 120 root root 12K 12月 18 14:06 /etc/ //120表示硬链接文件数
文件操作命令:
file /etc 查看文件类型 /etc/: directory
file1: empty
cp file1 file2 file3 file4 file5 /etc 将5个文件复制到/etc下
cp -r 1 2 3 5 将目录1 ,2 ,3复制到5下 //复制目录需要加-r,文件不需要
1 2 3
[root@localhost 5]# tar -czf 123.gz 1 2 3 //建立123.gz压缩包
1 123.gz 2 3
[root@localhost 5]# tar -xvf 123.gz -C 2/ //将123.gz压缩到2下,必须要用-C,C注意大小写
在文件中
ctrl+r 与 u 相反
:r /etc/host.conf 把/etc/host.conf复制到本文件末尾
cp -r 复制目录 cp -r /etc /mnt
cp -a 复制目录 cp -a /etc /mnt
cp -r 复制目录 \cp -rf /etc /mnt ?下面解释
alias
alias cp='cp -i' //-i 的优先级高于f,需要用\强制转换cp即可
alias rm='rm -i' //-f 的优先级高于i,不需要用\强制转换
rm -f file1
which 用于查找外部命令,在PATH环境变量中找
/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/root/bin
whereis passwd 找到passwd的命令和passwd的文件
passwd: /usr/bin/passwd /etc/passwd /usr/share/man/man5/passwd.5.gz /usr/share/man/man1/passwd.1.gz
locate 找出用户输入的关键词文件名
bash: locatepasswd: command not found
[root@localhost /]# find /etc -name "*.conf" -a -size +10k //大于10k,-a表示and,-10k,小于10k
/etc/dnsmasq.conf
/etc/lvm/lvm.conf
/etc/latrace.d/ncurses.conf
/etc/snmp/snmpd.conf
/etc/httpd/conf/httpd.conf
/etc/ltrace.conf
find /etc -name "*.conf" -a -size +10k -exec ls -lh {} \; //{}表示find /etc -name "*.conf" -a -size +10k的结果,\;表示转义字符; -exec ls -lh 对结果再处理
-rw-r--r--. 1 root root 21K 8月 17 2011 /etc/dnsmasq.conf
-rw-r--r--. 1 root root 29K 10月 19 2011 /etc/lvm/lvm.conf
-rw-r--r--. 1 root root 11K 6月 4 2010 /etc/latrace.d/ncurses.conf
find /etc -name "*.conf" -exec ls -lh {} \;
find /etc -name "*.conf" -exec ls -lh {} + //结果一样,+号效率高
硬链接只能针对文件创建,而且不能跨分区
软连接目录文件,可以跨分区创建
每一个文件都会占用一个inlde号,查找就找inode号,ls -i 查看inode号,inode号在系统中是唯一的
root:x:0:0:root:/root:/bin/bash
operator:x:11:0:operator:/root:/sbin/nologin //包括root的行
[root@localhost etc]# grep ^root passwd //以root开头的行
root:x:0:0:root:/root:/bin/bash
[root@localhost etc]# grep nologin$ passwd 以nologin结尾的行
[root@localhost etc]# grep nologin$ passwd | wc -l //算的前面结果的行数
33
[root@localhost etc]# ls -l | grep passwd //含有passwd的行显示出来
-rw-r--r--. 1 root root 1897 12月 17 23:52 passwd
-rw-r--r--. 1 root root 1897 12月 17 23:52 passwd-
[root@localhost ~]# tar czf /root/etc.tar.gz 123 456
123 etc.tar.gz workspace 视频 下载
456 install.log 公共的 图片 音乐
anaconda-ks.cfg install.log.syslog 模板 文档 桌面
ctrl+v 选中 , I , #, ESC,ESC 选择的行加# //可视模块
转载自blog.csdn.net/weixin_42325841/article/details/81501412