Shell/Bash在线运行

所属目录
点击了解高性能代码运行API
运行结果
教程手册
代码仓库
极速运行
终端运行
图形+终端

                        
以下是用户最新保存的代码
shell脚本学习 发布于:2024-03-07 16:03 bash zndf判断 发布于:2024-03-06 10:23 #### 实验1.1验证输入密码脚本 发布于:2024-03-05 20:16 rm -f测试程序 发布于:2024-03-05 17:40 shell保存简悦导出的markdown文件 发布于:2024-03-03 15:22 grep 三个命令递进组合 发布于:2024-02-28 17:41 if+单大括号 发布于:2024-02-22 15:18 cp拷贝文件 发布于:2024-02-22 14:48 shell脚本编辑学习 发布于:2024-02-20 09:24 shell脚本 发布于:2024-01-26 20:43 学习shell 发布于:2024-01-23 17:31 此脚本检测ChIP-seq样本是否input和IP匹配 发布于:2024-01-17 13:38 一键运行脚本 发布于:2024-01-13 21:37 单点进程与图形声音进程 发布于:2024-01-12 14:58 随机生成10个不相同的整 发布于:2023-12-08 10:18 game color 发布于:2023-12-04 20:01 一键sh安装脚本 发布于:2023-12-15 18:53 打印等边三角形 发布于:2023-11-28 20:00 shell计算器 发布于:2023-11-22 17:22 重启执行docker 发布于:2023-11-21 10:57 测试数据局 发布于:2023-10-19 17:06 查询被封禁ip 发布于:2023-09-19 16:37 shell减法函数 发布于:2023-09-13 10:57 centos7测试tomcat服务是否正常运行 发布于:2023-09-13 10:25 shell-study 发布于:2023-09-06 15:06 just for shell script learn 发布于:2023-09-01 09:34 测试Shell参数传递 发布于:2023-08-24 11:27 对cdh6进行自动化安装 发布于:2023-08-23 10:10 安装zookeeper 发布于:2023-08-14 18:32 安装mongo 发布于:2023-08-11 17:40 容器安装mysql 发布于:2023-08-04 15:19 最后的最后把它搞定 发布于:2023-08-03 14:32 shell测试 发布于:2023-08-01 16:07 Shell 代码验证 发布于:2023-07-24 15:25 shell测试程序 发布于:2023-07-23 22:31 shell函数5-4 while循环 发布于:2023-07-20 10:56 shell的demo 发布于:2023-07-17 23:14 # linux 初学者 发布于:2023-08-24 15:02 shell 在线脚本 1 发布于:2023-07-12 22:16 简单的计算器实现 发布于:2023-07-11 17:17 手机号码正则验证 发布于:2023-08-07 16:20 指定关闭或打开端口号 发布于:2023-07-07 16:14 #!/bin/bash a="hello,world,nice,to,meet,you" #要将$a分割开,先存储旧的分隔符 OLD_IFS="$IFS" #设置分隔符 IFS="," #如下会自动分隔 arr=($a) #恢复原来的分隔符 IFS="$OLD_IFS" function func1(){ echo $@ } #遍历数组 for s in ${arr[@]} do func1 "$s" done echo "完成" 发布于:2023-07-04 14:17 批量增加用户打印 发布于:2023-06-12 13:41 ##10num求最值平均值 发布于:2023-06-12 16:12 测试Jenkins 发布于:2023-06-07 14:02 九九乘法表 发布于:2023-06-07 10:37 case判断 发布于:2023-06-07 10:13 这是一个测试代码 发布于:2023-06-07 09:25 测试shell 发布于:2023-05-29 18:53 [更多]
显示目录

fdisk 命令-进行分区



学习嵌入式的绝佳套件,esp8266开源小电视成品,比自己去买开发板+屏幕还要便宜,省去了焊接不当搞坏的风险。 蜂鸣版+触控升级仅36元,更强的硬件、价格全网最低。

点击购买 固件广场

fdisk 命令

fdisk 命令进行分区。

格式

[root@localhost ~]# fdisk ~l
#列出系统分区
[root@localhost ~]# fdisk 设备文件名
#给硬盘分区

注意,千万不要在当前的硬盘上尝试使用 fdisk,这会完整删除整个系统,一定要再找一块硬盘,或者使用虚拟机。

[root@localhost ~]# fdisk -l
#查询本机可以识别的硬盘和分区
Disk /dev/sda:32.2 GB, 32212254720 bytes
#硬盘文件名和硬盘大小
255 heads, 63 sectors/track, 3916 cylinders
#共255个磁头、63个扇区和3916个柱面
Units = cylinders of 16065 *512 = 8225280 bytes
#每个柱面的大小
Sector size (logical/physical): 512 bytes/512 bytes
#每个扇区的大小
I/O size (minimum/optimal): 512 bytes/512 bytes
Disk identifier: 0x0009e098
Device Boot Start End Blocks ld System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
#分区1没有占满硬盘
/dev/sda2 26 281 2048000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary
#分区2没有占满硬盘
/dev/sda3 281 3917 29203456 83 Linux
#设备文件名启动分区 起始柱面 终止柱面容量 ID 系统
Disk /dev/sdb: 21.5 GB, 21474836480 bytes #第二个硬盘识别,这个硬盘的大小
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes/512 bytes Disk identifier: 0x00000000

使用 "fdisk -l" 查看分区信息,能看到添加的两块硬盘(/dev/sda 和 /dev/sdb)的信息。解释一下这些信息,其上半部分态是硬盘的整体状态,/dev/sda 硬盘的总大小是 32.2 GB,共有 3916 个柱面,每个柱面由 255 个磁头读/写数据,每个磁头管理 63 个扇区。每个柱面的大小是 8225280 Bytes,每个扇区的大小是 512 Bytes。

信息的下半部分是分区的信息,共 7 列,含义如下:

Device: 分区的设备文件名。
Boot: 是否为启动引导分区,在这里 /dev/sda1 为启动引导分区。
Start: 起始柱面,代表分区从哪里开始。
End: 终止柱面,代表分区到哪里结束。
Blocks: 分区的大小,单位是 KB。
id: 分区内文件系统的 ID。在 fdisk 命令中,可以 使用 "i" 查看。
System: 分区内安装的系统是什么。

如果这个分区并没有占满整块硬盘,就会提示 "Partition 1 does not end on cyl inder boundary",表示第一个分区没有到硬盘的结束柱面。/dev/sda 已经分配完了分区,没有空闲空间。而第二块硬盘 /dev/sdb 已经可以被识别了,但是没有可分区。

以硬盘 /dev/sdb 为例来做练习,命令如下:

[root@localhost ~]# fdisk /dev/sdb
#给/dev/sdb分区
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xed7e8bc7.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated.it's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').
Command (m for help):m
#交互界面的等待输入指令的位置,输入 m 得到帮助
Command action
#可用指令
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
I list known partition types m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verity the partition table
w write table to disk and exit
x extra functionality (experts only)

注意这里的分区命令是 "fdisk /dev/sdb",这是因为硬盘并没有分区,使用 fdisk 命令的目的就是建立分区。

fdisk 交互

在 fdisk 交互界面中输入 m 可以得到帮助,帮助里列出了 fdisk 可以识别的交互命令,如表 所示。

命令 说 明
a 设置可引导标记
b 编辑 bsd 磁盘标签
c 设置 DOS 操作系统兼容标记
d 删除一个分区
1 显示已知的文件系统类型。82 为 Linux swap 分区,83 为 Linux 分区
m 显示帮助菜单
n 新建分区
0 建立空白 DOS 分区表
P 显示分区列表
q 不保存退出
s 新建空白 SUN 磁盘标签
t 改变一个分区的系统 ID
u 改变显示记录单位
V 验证分区表
w 保存退出
X 附加功能(仅专家)
由JSRUN为你提供的Shell/Bash在线运行、在线编译工具
        JSRUN提供的Shell/Bash 在线运行,Shell/Bash 在线运行工具,基于linux操作系统环境提供线上编译和线上运行,具有运行快速,运行结果与常用开发、生产环境保持一致的特点。
yout