Linux命令使用(homework)

1. 新安装一台RHEL 6.x 或 CentOS 6.x 虚拟机

1)关闭防火墙、SELinux

[[email protected] ~]#serviceiptables stop

[[email protected] ~]# chkconfigiptables off

[[email protected] ~]# vim/etc/sysconfig/selinux

ELINUX=disabled

2)使用光盘中的软件包为本机配置YUM源    【 提示:指到光盘根目录,不要指向Packages】

[[email protected] ~]# vim/etc/yum.repos.d/bjpz.repo

[rhel6.4]

name=rhel6.4

baseurl=file:///misc/cd

enabled=1

gpgcheck=0

2,查看当前主机名,然后设置为youname.nsd1308.com

[[email protected] ~]# hostname

localhost.localdomain

[[email protected] ~]# hostname youname.nsd1308.com

[[email protected] ~]# hostname

youname.nsd1308.com

3,查看当前主机的IP,临时设置当前IP为192.168.10.X

[[email protected] ~]#ifconfig eth1

[[email protected] ~]# ifconfig eth1 192.168.10.1/24

4,查看CPU与内存信息

[[email protected] ~]# cat /proc/cpuinfo

[[email protected] ~]# cat /proc/meminfo

5,查看系统具体属于RedHat哪一个版本

[[email protected] ~]# cat /etc/issue

6,查看当前系统的时间

[[email protected] ~]# date

7,列出/etc目录属性

[[email protected] ~]# ls -ld /etc/

8,递归显示/boot目录下的文件和内容

[[email protected] ~]# ls -R /boot/

9,显示root下面所有文件包括隐藏文件

[[email protected] ~]# ls -a /root

10,进入/tmp目录,删除所有文件和目录,创建file1.txt file2.txt file3.txt file13.txt filea.txt fileab.txt

[[email protected] ~]# cd /tmp/

[[email protected] tmp]# rm -rf *

[[email protected] tmp]# mkdir file1.txt file2.txt file3.txtfile13.txt filea.txt fileab.txt

11,显示file开头的,以.txt结尾的,中间2个字符的文件

[[email protected] tmp]# find /tmp -name "file??.txt"

12,显示file开头的,以.txt结尾的,中间是单个数字的文件

[[email protected] tmp]#find /tmp -name "file[0-9].txt"

13,显示file开头的,以.txt结尾的,中间部分可能是1 3 a ab的文件

[[email protected] tmp]#ls  file{1,3,a,ab}.txt

14,查看/boot和/etc/pki分别占用多大空间

[[email protected] tmp]# du -sh /boot/

[[email protected] tmp]# du -sh /etc/pki

15,查看/etc/passwd前5行

[[email protected] tmp]# head -5 /etc/passwd

16,查看/etc/passwd尾5行

[[email protected] tmp]# tail -5 /etc/passwd

17,查看/etc/passwd的第8-12行

[[email protected] tmp]# head -12 /etc/passwd|tail -5

18,统计系统中有多少个账户

[[email protected] tmp]# cat /etc/passwd |wc -l

19,计算/etc目录下.conf配置文件的个数

[[email protected] ~]# ls /etc/*.conf|wc -l

20,显示/etc/passwd中以root开头的内容

[[email protected] ~]# grep ‘^root‘ /etc/passwd

21,显示/etc/passwd中以bash结尾的内容

[[email protected] ~]# grep ‘bash$‘ /etc/passwd

28,创建账户student

stu01,宿主目录设为/opt/stu01

stu02,uid为10001,账户在2015-06-30号过期,基本组设为stu01

sys01,不用于登录

sys02,不创建宿主目录

[[email protected] ~]#useradd student

[[email protected] ~]# useradd -d /opt/stu01 stu01

[[email protected] ~]# useradd -u 10001 -e 2015-06-30 -g stu01stu02

[[email protected] ~]#useradd -s /sbin/nologin sys01

[[email protected] ~]# useradd -M sys02

29,查看/etc/passwd文件的第一行

[[email protected] ~]# head -1 /etc/passwd

30,查看/etc/shadow文件的第一行

[[email protected] ~]# head -1 /etc/shadow

31,针对student操作设置密码为123456,然后用student登录自己修改密码

[[email protected] ~]# echo123456|passwd --stdin student

更改用户 student 的密码 。

passwd: 所有的身份验证令牌已经成功更新。

[[email protected] ~]# su - student

[[email protected] ~]$ passwd

更改用户 student 的密码 。

为 student 更改 STRESS 密码。

(当前)UNIX 密码:

新的密码:

重新输入新的密码:

passwd: 所有的身份验证令牌已经成功更新。

清空student的密码,查看/etc/shadow里面与student相关的内容

[[email protected] ~]# passwd -d student

清除用户的密码 student。

passwd: 操作成功

[[email protected] ~]# cat /etc/shadow |grep student

32、手动创建用户的过程 (禁止useradd)

/etc/passwd

[[email protected] ~]# vim/etc/passwd

sys03:x:10004:10004::/home/sys03:/bin/bash

/etc/shadow

[[email protected] ~]# vim /etc/shadow

sys03:!!:16256:0:99999:7:::

/etc/group

[[email protected] ~]# vim /etc/group

sys03:x:10004:

/etc/gshadow

[[email protected] ~]# vim /etc/gshadow

sys03:!::

[[email protected] ~]# su -sys03

[[email protected] ~]$

33)为虚拟机添加一块80GB、SCSI接口的硬盘

34)划分2个20GB的主分区,剩余作为扩展分区

Command (m for help): n

Command action

e   extended

p   primary partition(1-4)

p

Partition number (1-4): 1

First sector (2048-167772159, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-167772159, default167772159): +20G

Command (m for help): n

Command action

e   extended

p   primary partition(1-4)

p

Partition number (1-4): 2

First sector (41945088-167772159, default 41945088):

Using default value41945088

Last sector, +sectors or +size{K,M,G} (41945088-167772159,default 167772159): +20G

Command (m for help): n

Command action

e   extended

p   primary partition(1-4)

e

Partition number (1-4): 3

First sector (83888128-167772159, default 83888128):

Using default value83888128

Last sector, +sectors or +size{K,M,G} (83888128-167772159,default 167772159):

Using default value 167772159

35)新建2个逻辑分区,分别为2GB、10GB

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition(1-4)

l

First sector (83890176-167772159, default 83890176):

Using default value83890176

Last sector, +sectors or +size{K,M,G} (83890176-167772159,default 167772159): +2G

Command (m for help): n

Command action

l   logical (5 or over)

p   primary partition(1-4)

l

First sector (88086528-167772159, default 88086528):

Using default value88086528

Last sector, +sectors or +size{K,M,G} (88086528-167772159,default 167772159): +20G

36)将第1个逻辑分区的类型改为SWAP(ID 82)

Command (m for help): t

Partition number (1-6): 5

Hex code (type L to list codes): 82

Changed system type of partition 5 to 82 (Linux swap / Solaris)

37)将第2个逻辑分区的类型改为VFAT(ID b)

Command (m for help): t

Partition number (1-6): 6

Hex code (type L to list codes): b

Changed system type of partition 6 to b (W95 FAT32)

38)确认分区无误后,保存退出

Command (m for help): p

Disk /dev/sdb: 85.9 GB, 85899345920 bytes

255 heads, 63 sectors/track, 10443 cylinders, total 167772160sectors

Units = sectors of 1 *512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal):512 bytes / 512 bytes

Disk identifier: 0xbc90dae5

Device Boot      Start         End      Blocks  Id  System

/dev/sdb1            2048    41945087   20971520   83  Linux

/dev/sdb2        41945088    83888127   20971520   83  Linux

/dev/sdb3        83888128   167772159   41942016    5  Extended

/dev/sdb5        83890176    88084479    2097152   82  Linux swap / Solaris

/dev/sdb6        88086528   130029567   20971520    b W95 FAT32

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you havecreated or modified any DOS 6.x

partitions, please see the fdisk manual page for additional

information.

Syncing disks.

39)使用partprobe识别新的分区表   【最好是重启一次】

[[email protected] ~]# partprobe

40)将/dev/sdb1格式化成ext3分区

[[email protected] ~]# mkfs.ext3 /dev/sdb1

41)将/dev/sdb6格式化成FAT32分区

[[email protected] ~]# mkfs.vfat -F 32 /dev/sdb6

42)将/dev/sdb1挂载到/mnt/part1,在这个挂载目录新建一个file.txt文件和一个now的目录。

[[email protected] ~]# mkdir/mnt/part1

[[email protected] ~]# mount /dev/sdb1 /mnt/part1/

[[email protected] ~]# mkdir/mnt/part1/now/

[[email protected] ~]# touch /mnt/part1/file.txt

43)分别卸载/dev/sdb1、/dev/sdb6

[[email protected] ~]# umount /dev/sdb1

[[email protected] ~]# umount /dev/sdb6

Linux命令使用(homework),布布扣,bubuko.com

时间: 2024-08-05 03:50:42

Linux命令使用(homework)的相关文章

【Linux基础】常用Linux命令

常用Linux命令:cd, cp, ls, mv, rm cd命令:切换当前工作目录至 dirName(目录参数) 其中 dirName 可为绝对路径或相对路径.若目录名称省略,则变换至使用者的 home 目录 (也就是刚 login 时所在的目录). 另外,"~" 也表示为 home 目录的意思,"." 则是表示目前所在的目录,".." 则表示目前目录位置的上一层目录. cd [dirName] 参数: dirName:要切换的目标目录. 实例

linux命令格式,获取帮助及其目录结构简要理解

我们都知道,一台计算机要是没通电,和一堆废铁没什么区别.那么,通电开机进入系统后,会进入交互界面,等待用户操作,人与计算机交互界面有两种: GUI:图形用户接口.如我们平时使用的Windows  ,linux的X window,有KDE和GOME. CLI:命令行接口,使用的SHELL类型有bash ,csh,tcshell,zshell等. 例如:[[email protected] ~]# commandbin root:当前登录的用户名. dxlcentOS:当前主机的主机名.@是一个分隔

linux 命令 及学习进度综合整理

linux  命令  及学习进度综合整理 pwd 查看当前所在位置 cd  跳转到什么什么目录 ls  显示所有文件和目录 ls -l  显示目录详细信息 cd ..  返回上一级 vi  lnany.txt  创建一个文件 vi  .lnany.txt    创建一个隐藏文件 vim 是 vi 的升级版 功能更多 出现 -bash: vim: command not found 的解决办法 i. 那么如何安裝 vim 呢?输入rpm -qa|grep vim 命令, 如果 vim 已经正确安裝

9个使用时必须时刻警惕的Linux命令

Linux shell/terminal命令非常强大,即使一个简单的命令就可能导致文件夹.文件或者路径文件夹等被删除.为了避免这样的事情发生,我们应该时刻注意PHP代码&命令,今天为大家带来9个必须时刻警惕的Linux命令&代码. Linux shell/terminal 命令非常强大,即使一个简单的命令就可能导致文件夹.文件或者路径文件夹等被删除. 在一些情况下,Linux 甚至不会询问你而直接执行命令,导致你丢失各种数据信息. 一般来说在 Web 上推荐新的 Linux 用户执行这些命

Linux命令之scp

Linux命令之scp 功能说明 scp 是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且 scp传输是加密的.可能会稍微影响一下速度.当你服务器硬盘变为只读 read only system时,用scp可以帮你把文件移出来.另 外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了.虽然 rsync比scp会快一点,但当小文件众多的情况 下,rsync会导致硬盘I/O非常高

linux命令--top命令&free命令

top命令是用来查看系统性能的工具,能够实时显示各个进程的状况,包括进程ID.内存占用率.CPU占用率等. top - 23:12:04 up 79 days,  8:14,  1 user,  load average: 0.00, 0.01, 0.05 Tasks: 573 total,   2 running, 571 sleeping,   0 stopped,   0 zombie Cpu(s):  0.2%us,  0.4%sy,  0.0%ni, 99.5%id,  0.0%wa,

linux命令学习笔记

操作文件和目录: copy: $ cp file1 file2 $ cp -r dir1 dir2 move: $ mv file .. $ mv file dir/ rename: $ mv file1 file2 $ mv dir1 dir2 # dir2如果存在,则为移动操作 remove: $ rm file $ rm -r dir 创建文件: $ touch a.txt $ >a.txt 创建目录: $ mkdir dir 查看文件: #一般 $ cat file #查看文件类型: $

cv:显示Linux命令运行进度

cv: 显示 cp.mv 等命令的进度 2014-07-14 By toy Posted in Apps Edit on GitHub 在 Linux 系统中 , 大多数命令从来都是信奉 “ 沉默是金 ” 的准则 , 所以当我们利用 cp 复制文件的时候并不能看到所谓的进度条 . 如果你在意这一点 , 那么不妨来用用 cv. cv 是 Coreutils Viewer, 它能够显示传输数据的进度 , 包括百分比 . 大小 . 以及速率等信息 .cv 支持 coreutils 中的基本命令 , 比

三个网站让你成为Linux命令行高手

[转载自http://www.linuxeden.com/html/news/20091119/69183.html] Linux的命令行是通向Linux高级应用的必经之路,Linux系统管理员.开发者都是学习对象.Susan Linton向我们推荐了三个学习Linux命令行的网站,现在介绍给大家: 1. LinuxCommand LinuxCommand是一个学习Linux命令行最好的网站之一.网站分为:学习Shell.写Shell脚本.脚本库.超级MAN页面. 2. O'Reilly的Lin