linux安装dev命令,Linux安装与基础命令
首先準備一個liunx鏡像和一臺安裝好虛擬機的電腦。
配置好虛擬機,選在稍后安裝。選擇鏡像文件,開啟虛擬機進行安裝。
配置yum源。首先插入光盤。由于是虛擬機,用的光盤鏡像,
在/mnt/下面創建一個文件夾yum 。????? 復制所有光盤里的內容到/mnt/yum ??cp -rf /media/RHEL_5.9\ x86_64\ DVD/* ?/mnt/yum
用vim編輯器配置文件 ? vim /etc/yum.repo.d/rhel-debuginfo.repo配置如下:
[rhel]
name=Red Hat Enterprise Linux
baseurl=file:///mnt/yum/Server
enabled=1
gpgcheck=0
查看yum配置情況
root@localhost ~]# yum repolist
rhel ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 1.5 kB ? ? 00:00
rhel/primary ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? | 932 kB ? ? 00:00
rhel ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?3335/3335
repo id ? ? ? ? ? ? ? ? ? ?repo name ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?status
rhel ? ? ? ? ? ? ? ? ? ? ? Red Hat Enterprise Linux ? ? ? ? ? ? ? ? ? ? 3,335
yum配置成功。
6。查看當前主機名
[root@localhost ~]# hostname
localhost.localdomain
7。修改主機名
[root@localhost ~]#?hostname weiliyang.nsd1405.com
[root@localhost ~]# hostname
weiliyang.nsd1405.com
8.查看當前ip地址
[root@localhost ~]# ifconfig eth0
eth0 ? ? ?Link encap:Ethernet ?HWaddr 00:0C:29:55:29:F0
inet6 addr: fe80::20c:29ff:fe55:29f0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST ?MTU:1500 ?Metric:1
RX packets:117 errors:0 dropped:0 overruns:0 frame:0
TX packets:27 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11674 (11.4 KiB) ?TX bytes:5927 (5.7 KiB)
9.修改主機ip地址,臨時設置為192.168.1.10
[root@localhost ~]# ifconfig eth0 192.168.1.10/24
[root@localhost ~]# ifconfig eth0
eth0 ? ? ?Link encap:Ethernet ?HWaddr 00:0C:29:55:29:F0
inet addr:192.168.1.10 ?Bcast:192.168.1.255 ?Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe55:29f0/64 Scope:Link
UP BROADCAST RUNNING MULTICAST ?MTU:1500 ?Metric:1
RX packets:117 errors:0 dropped:0 overruns:0 frame:0
TX packets:38 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:11674 (11.4 KiB) ?TX bytes:8275 (8.0 KiB)
10.查看cpu信息
[root@localhost ~]# cat /proc/cpuinfo
processor ? ? ? : 0
vendor_id ? ? ? : GenuineIntel
cpu family ? ? ?: 6
model ? ? ? ? ? : 37
model name ? ? ?: Intel(R) Core(TM) i3 CPU ? ? ? M 350 ?@ 2.27GHz
stepping ? ? ? ?: 2
cpu MHz ? ? ? ? : 2261.002
cache size ? ? ?: 3072 KB
11.查看內存信息
[root@localhost ~]# cat /proc/meminfo
MemTotal: ? ? ? 507508 kB
MemFree: ? ? ? ? 39700 kB
Buffers: ? ? ? ? ?5256 kB
Cached: ? ? ? ? 187540 kB
SwapCached: ? ? ? ? ?0 kB
Active: ? ? ? ? 293652 kB
Inactive: ? ? ? 105868 kB
12.查看系統具體屬于RedHat哪一個版本
[root@localhost ~]# lsb_release ?-d
Description: ? ?Red Hat Enterprise Linux Server release 5.9 (Tikang
13.查看當前系統時間
[root@localhost ~]# date
2014年 07月 06日 星期日 17:22:52 CST
14.列出/etc目錄屬性
drwxr-xr-x 102 root root 12288 07-06 16:43 /etc/
15.遞歸顯示/boot下的目錄和文件
[root@localhost ~]# ls ?-R /boot/
/boot/:
config-2.6.18-348.el5 ? ? ?lost+found ? ? ? ? ? ? ? ? vmlinuz-2.6.18-348.el5
grub ? ? ? ? ? ? ? ? ? ? ? symvers-2.6.18-348.el5.gz
initrd-2.6.18-348.el5.img ?System.map-2.6.18-348.el5
/boot/grub:
device.map ? ? grub.conf ? ? ? ? minix_stage1_5 ? ? stage2
e2fs_stage1_5 ?iso9660_stage1_5 ?reiserfs_stage1_5 ?ufs2_stage1_5
fat_stage1_5 ? jfs_stage1_5 ? ? ?splash.xpm.gz ? ? ?vstafs_stage1_5
ffs_stage1_5 ? menu.lst ? ? ? ? ?stage1 ? ? ? ? ? ? xfs_stage1_5
/boot/lost+found:
15.顯示root下面所有文件包括隱藏文件
[root@localhost ~]# ls -a /boot/
. ? ? ? ? ? ? ? ? ? ? ? ? ?lost+found
.. ? ? ? ? ? ? ? ? ? ? ? ? symvers-2.6.18-348.el5.gz
config-2.6.18-348.el5 ? ? ?System.map-2.6.18-348.el5
grub ? ? ? ? ? ? ? ? ? ? ? vmlinuz-2.6.18-348.el5
initrd-2.6.18-348.el5.img ?.vmlinuz-2.6.18-348.el5.hmac
16.進入/tmp目錄,刪除所有文件和目錄,創建file1.txt file2.txt file3.txt file13.txt filea.txt ???????? ??fileab.txt
[root@localhost tmp]# cd /tmp/
[root@localhost tmp]# rm -rf *
[root@localhost tmp]# touch file1.txt file2.txt file3.txt file13.txt filea.txt ???? ? ??fileab.txt
[root@localhost tmp]#
[root@localhost tmp]# ls
file13.txt ?file1.txt ?file2.txt ?file3.txt ?fileab.txt ?filea.txt
17.顯示file開頭的,以.txt結尾的,中間2個字符的文件
[root@localhost tmp]# ls file??.txt
file13.txt ?fileab.txt
[root@localhost tmp]#
18.顯示file開頭的,以.txt結尾的,中間是單個數字的文件
[root@localhost tmp]# ls file[0-9].txt
file1.txt ?file2.txt ?file3.txt
19.顯示file開頭的,以.txt結尾的,中間部分可能是1 3 a ab的文件
[root@localhost tmp]# ls file{1,3,a,ab}.txt
file1.txt ?file3.txt ?fileab.txt ?filea.txt
20.查看/boot和/etc/pki分別占用多大空間
[root@localhost tmp]# du -sh ?/root/
385M ? ?/root/
[root@localhost tmp]# du -sh /etc/pki/
792K ? ?/etc/pki/
21.查看/etc/passwd前5行
[root@localhost tmp]# head -5 /etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
22.查看/etc/passwd尾5行
[root@localhost tmp]# tail -5 /etc/passwd
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:159:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
weiliyang:x:500:500::/home/weiliyang:/bin/bash
23.查看/etc/passwd的第8-12行
[root@localhost tmp]# head -12 /etc/passwd|tail -5 /etc/passwd
haldaemon:x:68:68:HAL daemon:/:/sbin/nologin
avahi-autoipd:x:100:159:avahi-autoipd:/var/lib/avahi-autoipd:/sbin/nologin
gdm:x:42:42::/var/gdm:/sbin/nologin
sabayon:x:86:86:Sabayon user:/home/sabayon:/sbin/nologin
weiliyang:x:500:500::/home/weiliyang:/bin/bash
24.統計系統中有多少個賬戶
[root@localhost tmp]# cat -n /etc/passwd|wc -l
35
25.計算/etc目錄下.conf配置文件的個數
[root@localhost tmp]# ls /etc/*.conf|wc -l
48
26.顯示/etc/passwd中以root開頭的內容
[root@localhost tmp]# grep ^root /etc/passwd
root:x:0:0:root:/root:/bin/bash
27.顯示/etc/passwd中以bash結尾的內容
[root@localhost tmp]# grep bash$ /etc/passwd
root:x:0:0:root:/root:/bin/bash
weiliyang:x:500:500::/home/weiliyang:/bin/bash
28.分別使用gzip和bzip2和zip對/root/gztest.txt進行壓縮和解壓
gzip壓縮
[root@localhost ~]# ls
anaconda-ks.cfg ?Desktop ?gztext.txt ?install.log ?install.log.syslog ?lianxi
[root@localhost ~]# gzip -9 gztext.txt
[root@localhost ~]# ls
anaconda-ks.cfg ?gztext.txt.gz ?install.log.syslog
Desktop ? ? ? ? ?install.log ? ?lianxi
gunzip解壓
[root@localhost ~]# gunzip gztext.txt.gz
[root@localhost ~]# ls
anaconda-ks.cfg ?Desktop ?gztext.txt ?install.log ?install.log.syslog ?lianxi
gzip2壓縮
[root@localhost ~]# ls
anaconda-ks.cfg ?Desktop ?gztext.txt ?install.log ?install.log.syslog ?lianxi
[root@localhost ~]# bzip2 gztext.txt
[root@localhost ~]# ls
anaconda-ks.cfg ?gztext.txt.bz2 ?install.log.syslog
Desktop ? ? ? ? ?install.log ? ? lianxi
gzip2解壓
[root@localhost ~]# bunzip2 gztext.txt.bz2
[root@localhost ~]# ls
anaconda-ks.cfg ?Desktop ?gztext.txt ?install.log ?install.log.syslog ?lianxi
tar壓縮
[root@localhost ~]# ls
anaconda-ks.cfg ?Desktop ?gztext.txt ?install.log ?install.log.syslog ?lianxi
[root@localhost ~]# tar -zcf gztext.txt.tar.gz gztext.txt
[root@localhost ~]# ls
anaconda-ks.cfg ?gztext.txt ? ? ? ? install.log ? ? ? ? lianxi
Desktop ? ? ? ? ?gztext.txt.tar.gz ?install.log.syslog
tar解壓
[root@localhost ~]# tar -zxf gztext.txt.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg ?gztext.txt ? ? ? ? install.log ? ? ? ? lianxi
Desktop ? ? ? ? ?gztext.txt.tar.gz ?install.log.syslog
29.把/etc/mail打包并壓縮到/root/mail.tar.gz
[root@localhost ~]# tar -zcf /root/mail.tar.gz /etc/mail
[root@localhost ~]# ls /root/
anaconda-ks.cfg ?-D ? ? ? gztext.txt ? ? ? ? install.log ? ? ? ? lianxi
-d ? ? ? ? ? ? ? Desktop ?gztext.txt.tar.gz ?install.log.syslog ?mail.tar.gz
30,把/etc/mail打包并壓縮到/root/mail.tar.bz2
[root@localhost ~]# tar jcf /root/mail.tar.bz2 /etc/mail
[root@localhost ~]# ls /root/
anaconda-ks.cfg ?-D ? ? ? gztext.txt ? ? ? ? install.log ? ? ? ? lianxi
-d ? ? ? ? ? ? ? Desktop ?gztext.txt.tar.gz ?install.log.syslog ?mail.tar.bz2
31.將mail.tar.gz解壓到/tmp下,遞歸查看/tmp/etc下的內容,然后刪除/tmp/etc目錄
[root@localhost ~]# tar -zxf mail.tar.gz -C /tmp/
遞歸查看/tmp/etc
[root@localhost ~]# ls -R /tmp/
/tmp/etc:
/tmp/etc/mail:
access ? ? ? ? ?helpfile ? ? ? ? ?Makefile ? ? submit.mc
access.db ? ? ? local-host-names ?sendmail.cf ?trusted-users
domaintable ? ? mailertable ? ? ? sendmail.mc ?virtusertable
domaintable.db ?mailertable.db ? ?submit.cf ? ?virtusertable.db
[root@localhost ~]# rm -rf /tmp/etc/
[root@localhost ~]# ls -R /tmp/
/tmp/:
file13.txt ?file2.txt ?fileab.txt ?scim-bridge-0.3.0.lockfile-0@localhost:0.0
file1.txt ? file3.txt ?filea.txt
32.分別查看mail.tar.gz與mail.tar.bz2文件里面內容
[root@localhost ~]# file mail.tar.gz
mail.tar.gz: gzip compressed data, from Unix, last modified: Sun Jul ?6 19:38:22 2014
[root@localhost ~]# file mail.tar.bz2
mail.tar.bz2: bzip2 compressed data, block size = 900k
33.
創建賬戶
student
stu01,宿主目錄設為/opt/stu01
[root@localhost ~]# useradd ?-d /opt/stu01 stu01
stu02,uid為10001,賬戶在2015-06-30號過期,基本組設為stu01
[root@localhost ~]# useradd -u 10002 -g stu01 -e 2015-06-30 stu02
sys01,不用于登錄
[root@localhost ~]# useradd -s /sbin/nologin sys01
sys02,不創建宿主目錄
[root@localhost ~]# useradd -M sys02
33.查看/etc/passwd文件的第一行
[root@localhost ~]# head -1 /etc/passwd
root:x:0:0:root:/root:/bin/bash
34.查看/etc/shadow文件的第一行
[root@localhost ~]# head -1 /etc/shadow
root:$1$1FskXDzB$KJvDMEmf8TKu18qJvd2nO0:16247:0:99999:7:::
35.針對student操作
設置密碼為123456,然后用student登錄自己修改密碼
[root@localhost ~]# passwd student
Changing password for user student.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
清空student的密碼,查看/etc/shadow里面與student相關的內容
清空前
[root@localhost ~]# grep student /etc/shadow
student:$1$dgLGRByb$xJrSGtmn7MSWlhA6zqMbR1:16257:0:99999:7:::
清空后
[root@localhost ~]# passwd -d student
Removing password for user student.
passwd: Success
[root@localhost ~]# grep student /etc/shadow
student::16257:0:99999:7:::
36.手動創建用戶的過程 (禁止useradd)
1)、/etc/passwd
/etc/shadow
/etc/group
/etc/gshadow
2)、/home/xxxx
3)、/var/spool/mail/xxxx
4)、/etc/skel/.*
5)、權限
[root@localhost ~]# vim /etc/passwd
yang:x:10005:10005::/homeyang:bin/bash
[root@localhost ~]# vim /etc/shadow
yang:!!:16258:0:99999:7:::
[root@localhost ~]# vim /etc/group
yang:x:10005:
[root@localhost ~]# vim /etc/gshadow
yang:!::
[root@localhost ~]# mkdir /home/yang
[root@weiliyang weiliyang]# touch /var/spool/mail/yang
37.為虛擬機添加一塊80GB、SCSI接口的硬盤
劃分2個20GB的主分區,剩余作為擴展分區
[root@localhost ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
fdisk /dev/sdb
按n鍵添加分區
Command (m for help): n
Command action????? ? (e為交換分區,p為主分區)
e ? extended
p ? primary partition (1-4)
p
Partition number (1-4): 3 ?(輸入分區編號)
First cylinder (4867-10443, default 4867): (規劃分區大小)
Using default value 4867
Last cylinder or +size or +sizeM or +sizeK (4867-10443, default 10443): +20g
38.添加交換分區
Command (m for help): n
Command action
e ? extended
p ? primary partition (1-4)
e
Selected partition 4
First cylinder (7300-10443, default 7300):
Using default value 7300
Last cylinder or +size or +sizeM or +sizeK (7300-10443, default 10443):
Using default value 10443
p查看分區列表
Device Boot ? ? ?Start ? ? ? ? End ? ? ?Blocks ? Id ?System
/dev/sdb1 ? ? ? ? ? ? ? 1 ? ? ? ?2433 ? ?19543041 ? 83 ?Linux
/dev/sdb2 ? ? ? ? ? ?2434 ? ? ? ?4866 ? ?19543072+ ?83 ?Linux
/dev/sdb3 ? ? ? ? ? ?4867 ? ? ? 10443 ? ?44797252+ ? 5 ?Extended
/dev/sdb5 ? ? ? ? ? ?4867 ? ? ? ?7299 ? ?19543041 ? 83 ?Linux
/dev/sdb6 ? ? ? ? ? ?7300 ? ? ? ?8516 ? ? 9775521 ? 83 ?Linux
39.將第一個邏輯分區類型改為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)
40.將第二個邏輯分區類型改為vfat(id=b或c)
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)
41.按w保存退出
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
42.使用partprobe更新分區表【最好是重啟一次】
[root@localhost ~]# partprobe
[root@localhost ~]#
43.將/dev/sdb1格式化成ext3分區
[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
2443200 inodes, 4885760 blocks
244288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
150 block groups
32768 blocks per group, 32768 fragments per group
16288 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. ?Use tune2fs -c or -i to override.
44.將/dev/sdb6格式化成FAT32分區
[root@localhost ~]# mkfs.vfat /dev/sdb6
mkfs.vfat 2.11 (12 Mar 2005)
45.將/dev/sdb1掛載到/mnt/part1,在這個掛載目錄新建一個file.txt文件和一個now的目錄
[root@localhost ~]# mount /dev/sdb1 /mnt/part1/
[root@localhost ~]# mount|grep sdb1
/dev/sdb1 on /mnt/part1 type ext3 (rw)
在/mnt/part1/下建立一個新的測試文件并查看
[root@localhost ~]# touch /mnt/part1/file.txt
[root@localhost ~]# ls /mnt/part1/
file.txt ?lost+found
46.分別卸載/dev/sdb1、/dev/sdb6
[root@localhost ~]# umount /dev/sdb1
[root@localhost ~]# umount /dev/sdb6
總結
以上是生活随笔為你收集整理的linux安装dev命令,Linux安装与基础命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 无法扩展该卷 因为群集的数量将超过文件系
- 下一篇: 查看so库中是否有某个定义_论Linux