Linux系统命令练习题

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,不创建宿主目录

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

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

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

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

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

/etc/passwd

/etc/shadow

     /etc/group

/etc/gshadow

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

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

p

[[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

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

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

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

更改用户 student 的密码 。

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

[[email protected] ~]# su - student

[[email protected] ~]$ passwd

更改用户 student 的密码 。

为 student 更改 STRESS 密码。

(当前)UNIX 密码:

新的密码:

重新输入新的密码:

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

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

清除用户的密码 student。

passwd: 操作成功

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

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

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

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

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

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

sys03:x:10004:

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

sys03:!::

[[email protected] ~]# su -sys03

[[email protected] ~]$

Command (m for help): n

Command action

e   extended

p   primary partition(1-4)

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):

Command (m for help): n

Command action

+20G

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): w

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系统命令练习题

时间: 2024-12-18 17:50:51

Linux系统命令练习题的相关文章

Linux系统命令

一  进程查看            1   ps  aux     查看当前系统所有运行的进程            -a 显示前台所有进程            -u  显示用户名            -x  显示后台进程            user: 用户名            pid:   进程id.PID     1  init  系统启动的第一个进程            %CPU    cpu占用百分比            %MEM    内存占用百分比         

常用的linux系统命令汇总

top vmstat w & uptime ps && pstree free iostat sar mpstat pmap netstat & ss iptraf tcpdump /proc Nagios Cacti KDE System Guard Gnome System Monitor sysstat 常用的linux系统命令汇总,布布扣,bubuko.com

Linux 系统命令及其使用详解

Linux 系统命令及其使用详解 cat cd chmod chown cp cut名称:cat 使用权限:所有使用者 使用方式:cat [-AbeEnstTuv] [--help] [--version] fileName 说明:把档案串连接后传到基本输出(萤幕或加 > fileName 到另一个档案) 参数:-n 或 --number 由 1 开始对所有输出的行数编号-b 或 --number-nonblank 和 -n 相似,只不过对于空白行不编号-s 或 --squeeze-blank

登录linux系统命令提示符显示为:-bash-4.1$

1.问题描述 登录linux系统命令提示符显示如下: -bash-4.1$ -bash-4.1$ 2.原因分析 与用户相关的环境变量的配置文件.bashrc和.bash_profile没了 3.解决方法 /etc/skel当通过 useradd 命令创建新用户,/etc/skel 目录下的文件,都会原封不动的复制到新建用户的家目录下- -bash-4.1$ cp/etc/skel/.bash*   . 4.检查 退出后,重新登录 -bash-4.1$ logout [[email protect

Linux笔记Linux 系统命令及其使用详解(大全)

开机默认界面修改:字符界面和图形界面-->修改ect/inittab文件 Windows远程Telnet访问Linux系统:telnet+远程Linux系统IP地址 Linux目录结构: /:根目录 /bin:存放必要的命令 /boot:存放内核以及启动所需的文件等 /dev:存放设备文件 /etc:存放系统的配置文件 /home:用户文件的主目录,用户数据存放在其主目录中 /lib:存放必要的运行库 /mnt:存放临时的映射文件系统 /proc:存放存储进程和系统信息 /root:超级用户的主

PHP执行linux系统命令

本文是第一篇,讲述如何在PHP中执行系统命令从而实现一些特殊的目的,比如监控服务器负载,重启MySQL.更新SVN.重启Apache等.第二篇<PHP监控linux服务器负载>:http://www.ccvita.com/390.html 首先先要给大家介绍PHP执行linux系统命令的几个基本函数.我曾经很长一段时间都分不清下面几个函数的具体用法区别. system函数说明:执行外部程序并显示输出资料.语法:string system(string command, int [return_

性能检测工具介绍-Linux系统命令行

本文介绍的关于Linux自带命令进行性能检测的介绍,详细介绍这些linux自带的工具的使用. 一.uptime uptime命令的显示结果包括服务器已经运行了多长时间,有多少登陆用户和对服务器性能的总体评估(load average).load average值分别记录了上个1分钟,5分钟和15分钟间隔的负载情况,load average不是一个百分比,而是在队列中等待执行的进程的数量.如果进程要求CPU时间被阻塞(意味着CPU没有时间处理它),load average值将增加.另一方面,如果每

[Linux&amp;C语言] Linux系统命令“ls -l”的实现

Linux系统命令"ls -l"的实现 一.基本概念 1. "ls -l"所显示各项的意义 例:-rw-rw-r--   1  using using  3102  7月 22 17:06  test.c drwxrwxr-x  2  using using  4096  7月 22 18:39  testdir lrwxrwxrwx  1  using using      17   7月 22 18:43  shared -> /media/sf_shar

Linux系统命令(一)

一.linux简介                                                                                                                       1.linux的特点 免费开源 模块化程度高      内核设计分为五个部分:进程管理.内存管理.进程间通信.虚拟文件系统和网络 广泛的硬件支持   几乎能在所有流行的处理器上运行 安全稳定           拥有多项安全技术措施 多用户多任