Linux命令笔记

1. 永久加载驱动

cp your_driver.ko /lib/modules/$(uname -r)/
depmod

 

2. debian系统上禁用ipv6

修改grub,GRUB_CMDLINE_LINUX变量中添加IPV6_DISABLE=1,再update-grub

根据需求修改/etc/sysctl.conf

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

 最后执行 sysctl -p

 

3. 修改power button的行为:

cat /etc/systemd/logind.conf 

 

4. U盘操作

查看U盘设备名称:

fdisk -l

mount FAT格式的U盘

mount -t vfat /dev/sdb1 /mnt/usb

unmount

umount /mnt/usb

 

5. 重启

[root@localhost ~]# shutdown -r now
#重启, now是现在重启的意思
[root@localhost ~]# shutdown -r 05:30
#指定时间重启,但会占用前台终端
[root@localhost ~]# shutdown -r 05:30 &
#把定义重启命令放入后台,&是后台的意思
[root@localhost ~]# shutdown -c
#取消定时重启
[root@localhost ~]# shutdown -r +10
#10分钟之后重启

 

6. 挂载CDROM

mount -t iso9660 /dev/cdrom /mnt/cdrom

 

7. 查看网络状态

netstat -ntlup

 

8. 查看防火墙状态

ufw status

 

9. 使防火墙允许某端口的连接

ufw allow 5600/tcp

 

12. 设置IP

ifconfig your_eth_name 192.168.2.1 netmask 255.255.255.0

 

13. 脱离终端运行程序

nohup ./your_sh > /dev/null 2> /dev/null &

 

14. 修改默认gcc版本

sudo rm /usr/bin/gcc
sudo ln -s /usr/bin/gcc-5 /usr/bin/gcc

 

15. 查看service状态

service --status-all

 

16. 修改系统时区

timedatectl set-timezone 'Asia/Shanghai'

 

17. Ubuntu 文本模式,图形模式切换

sudo systemctl set-default multi-user.target

sudo systemctl set-default graphical.target

 

18. 批量操作文件

find "$PWD" -type f \( -iname '*.sh' \) -print0 | xargs -0 chmod +x

 

19. 将文件转换成unix文件

# vi 打开后
set ff=unix

# or
dos2unix file_path

 

posted @ 2019-05-31 12:38  MyCPlusPlus  阅读(186)  评论(0编辑  收藏  举报