linux补充资料

  • 关于分区
/dev/sda1	
#/dev是所有设备文件存放的目录,sd代表SCSI硬盘,如果是hd则代表是IDE硬盘;
#a代表第一块硬盘;
#1代表分区,前4个分区(主分区或者扩展分区)用数字1~4表示,逻辑分区从5开始。
举例:/dev/sdc6代表第三块SCSI硬盘的第2个逻辑分区
  • 查看各分区情况
[root@vmcentos7test system]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk 
├─sda1   8:1    0    4G  0 part /boot
├─sda2   8:2    0    4G  0 part [SWAP]
└─sda3   8:3    0   52G  0 part /
sr0     11:0    1 1024M  0 rom  
  • 查看CPU信息
cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l	#查看物理CPU个数

cat /proc/cpuinfo | grep "cpu cores"	#查看每个物理CPU中内核的个数
  • mount格式
mount [-t 文件系统类型] 设备名 挂载点

mount /dev/cdrom /mnt/

umount 挂载目录	#卸载设备

umount /mnt/usb	#卸载U盘
umount /mnt/cdrom	#卸载光盘
  • 将开机执行的命令写入rc.local文件中(需要给予此文件可执行权限“x”)
[root@zabbix ~]# ll /etc/rc.local 
lrwxrwxrwx 1 root root 13 Sep 21 10:12 /etc/rc.local -> rc.d/rc.local
#可以看出/etc/rc.local是/etc/rc.d/rc.loacl的软链接
[root@zabbix ~]# ll /etc/rc.d/rc.local 
-rwx------ 1 root root 722 Oct 13 18:24 /etc/rc.d/rc.local
  • history
.bash_history	#当前用户
最大1000条记录
可修改/etc/profile中的HISTSIZE值	#所有用户
!!	#执行上一条命令,即history中的最后一条
!n	#执行history中的第n条命令
HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "	#在/etc/profile中新增此命令,使得history带有时间显示

source /etc/profile

#新增后如下
[root@onlytest home]# grep HIST /etc/profile
HISTSIZE=1000
HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S "
if [ "$HISTCONTROL" = "ignorespace" ] ; then
    export HISTCONTROL=ignoreboth
    export HISTCONTROL=ignoredups
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
[root@onlytest home]# 
  • 参数补全
按tab键补全命令
#参数补全,安装bash-completion
  • 创建多个连续的文件及文件夹
[root@onlytest ~]# touch {1..9}.txt
[root@onlytest ~]# ll
总用量 8
-rw-r--r--. 1 root root    0 12月 11 14:34 1.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 2.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 3.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 4.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 5.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 6.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 7.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 8.txt
-rw-r--r--. 1 root root    0 12月 11 14:34 9.txt

#同理,创建多个文件夹
[root@onlytest ~]# mkdir {a..g}
  • 特殊符号
 $ 变量前缀,!$组合,正则里面表示行尾
 ;多条命令写到一行,用分号分割
 ~ 用户家目录,后面正则表达式表示匹配符
 & 放到命令后面,会把命令丢到后台
 > >> 2> 2>> &>
 [ ] 指定字符中的一个,[0-9],[a-zA-Z],[abc]
 ||&& ,用于命令之间
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值