一本码簿

众里寻码千百度,那段却在github处。

0%

Linux

Linux

查看系统信息

1
2
3
4
5
6
id -un
uname -a
lsb_release -c
lscpu
lshw
cat /proc/meminfo

初始安装

1
2
3
4
5
6
sh -c "$(curl -fsSL http://www.haies.cn/assets/debian-init.sh)"
sh -c "$(curl -fsSL http://www.haies.cn/assets/centos-init.sh)"
sh -c "$(curl -fsSL http://www.haies.cn/assets/ubuntu-init.sh)"
sh -c "$(curl -fsSL http://www.haies.cn/assets/apt-install.sh)"
sh -c "$(curl -fsSL http://www.haies.cn/assets/yum-install-docker.sh)"
sh -c "$(curl -fsSL http://www.haies.cn/assets/dns.sh)"

磁盘管理

查看磁盘格式:lsblk -f
查看磁盘信息:fdisk -l

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mkfs.xfs -f /dev/vdb3mkdir /hda&&
mkdir /hda&&
mount /dev/vdb /hda&&
echo /dev/vdb /hda xfs defaults 0 0 >> /etc/fstab

mkfs.ext4 -T huge -b 4096 /dev/vdb&&
mkdir /hda&&
mount /dev/vdb /hda&&
echo /dev/vdb /hda ext4 defaults 0 0 >> /etc/fstab

mkfs.ext3 -T largefile -i 4096 /dev/xvdb1&&
mkdir /hda&&
mount /dev/xvdb1 /hda&&
echo /dev/xvdb1 /hda ext3 defaults 0 0 >> /etc/fstab

NTFS读写

1
2
3
apt-get install ntfs-3g
mount -t ntfs-3g /dev/hdax /mnt/windows
/dev/hdax /mnt/windows ntfs-3g defaults 0 0

目录操作

迁移目录:

1
2
3
4
5
6
7
8
mkfs.xfs -f /dev/xvdb2&&
mkdir /vartemp&&
mount /dev/xvdb2 /vartemp&&
rsync -avx /var /vartemp&&
mv /var /var.old&&
mkdir /var&&
umount -lf /dev/xvdb2 /vartemp&&
mount /dev/xvdb2 /var

目录备份还原:dumprestore
目录占用查看:fuserlsof
合并文件夹:cp -rlfv parta/* partb/* part

配置主机

在~/.ssh/config中增加

1
2
3
4
5
6
Include ~/.ssh/config.d/*
Host aws
Hostname 10.2.*.*
Port 22
User ubuntu
IdentityFile ~/.ssh/aws.pem

添加自启动服务

1
update-rc.d apache2 defaults

远程执行命令

1
ssh root@59.202.*.* "cd /home/git/.ssh&&cat id_rsq.pub>>authorized_keys"

7Z

1
2
3
4
7z e archive.zip -o/soft *.cpp
tar -zcvpf /tmp/etc.tar.gz /etc
tar -zxvf ./text.tar.gz -C /home/app/test/
ls -l |grep ^d|awk {'print $9'}|xargs -t -i 7z a {}.7z {}

挂载DVD源

1
2
3
4
5
mkdir /iso&&
mount -t iso9660 -o loop /hda/debian7.8/debian-7.8.0-amd64-DVD-1.iso /iso&&
echo deb file:///iso/ wheezy main contrib>/etc/apt/sources.list&&
sudo apt-get update&&
sudo apt-get upgrade