当前位置: 首页 > news >正文

Linux 简要命令记录

1、设置时区:

#设为上海:
timedatectl set-timezone Asia/Shanghai
#搜索特定时区
timedatectl list-timezone

2、修改时间:

#设定系统时间
date -s "2023-11-16 22:30:00"
#同步写入BIOS
hwclock -w

3、fdisk分区

root@heihei:~# fdisk /dev/nvme0n1
Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.The size of this disk is 3.5 TiB (3840755982336 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).Command (m for help): n
Partition typep   primary (0 primary, 0 extended, 4 free)e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-4294967295, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-4294967294, default 4294967294):Created a new partition 1 of type 'Linux' and of size 2 TiB.Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@heihei:~# lsblk |grep nvme0n1
nvme0n1     259:0    0   3.5T  0 disk
`-nvme0n1p1 259:2    0     2T  0 part
#可以看到已经创建成功

4、自动交互

简要作用,shell下老是会有交互界面,比如让你按y确定进行下一步,比如mkfs 的时候需要按y确认等等需要交互的时候,我们可以在给命令的时候就先给出,当其弹出交互时,自动输入
如上面第三条:fdisk分区,需要在输入fdisk /dev/nvme0n1以后再输入

n[回车]
p[回车]
[回车]
[回车]
[回车]
w[回车]

已知回车在 linux下用 \n可以代替

# -e 代表激活转义符
root@heihei:~# echo -e "1\n2"
1
2

得出解:echo -e "n\np\n\n\n\nw\n"
再透过管道命令 | 传递给fdisk命令,效果如下:

root@heihei:~# echo -e "n\np\n\n\n\nw\n"|fdisk /dev/nvme0n1Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.The size of this disk is 3.5 TiB (3840755982336 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).Command (m for help): Partition typep   primary (0 primary, 0 extended, 4 free)e   extended (container for logical partitions)
Select (default p): Partition number (1-4, default 1): First sector (2048-4294967295, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-4294967294, default 4294967294):
Created a new partition 1 of type 'Linux' and of size 2 TiB.Command (m for help): The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@heihei:~# lsblk |grep nvme0n1
nvme0n1     259:0    0   3.5T  0 disk
`-nvme0n1p1 259:2    0     2T  0 part
#创建成功
http://www.lryc.cn/news/233343.html

相关文章:

  • 深度学习与深度强化学习
  • C++函数重载中形参是引用类型和常量引用类型的调用方法
  • Quest 3期间Sui上游戏处理了数百万笔交易
  • Python中如何定义类、基类、函数和变量?
  • 打开文件 和 文件系统的文件产生关联
  • 【Rust】快速教程——模块mod与跨文件
  • crontab定时任务是否执行
  • MATLAB程序设计:牛顿迭代法
  • B031-网络编程 Socket Http TomCat
  • gRPC之metadata
  • 【OpenCV实现图像:OpenCV进行OCR字符分割】
  • 景联文科技入选量子位智库《中国AIGC数据标注产业全景报告》数据标注行业代表机构
  • ClickHouse SQL操作
  • Ubuntu安装Python环境(使用VSCode)
  • QTcpSocket发送结构体的做法
  • 微服务学习 | Ribbon负载均衡、Nacos注册中心、微服务技术对比
  • 【FPGA】zynq 单端口RAM 双端口RAM 读写冲突 写写冲突
  • 【备忘】websocket学习之挖坑埋自己
  • 大数据研发工程师面试
  • 【星海出品】云存储 ceph
  • [nlp] grad norm先降后升再降
  • 云积天赫AI全域营销系统,为品牌营销注入新活力
  • Arthas在线修改Java代码
  • mapbox支持的坐标系
  • 腾讯云新客户优惠服务器88元/年,540元/3年,另有5年优惠服务器
  • 伦敦银和美白银的关系
  • Matplotlib的使用方法
  • 【入门篇】1.7 Redis 之 codis 入门介绍
  • 【JavaEE】Servlet API 详解(HttpServlet类)
  • 微软宣布计划在 Windows 10 版本 22H2 中引入 AI 助手 Copilot