rhce学习笔记(rhce怎么样)-j9九游会登录

大家好!今天让小编来大家介绍下关于rhce学习笔记的问题,以下是酷知号的小编对此问题的归纳整理,让我们一起来看看吧。

rhce学习笔记

 

rh033 red hat enterprise linux essentials

 

一、running commands and getting help

1、设置系统时间

date -s 05/27/2013

date -s 13:12:00

 

2、the man command

(1)格式

man passwd  = man1 passwd   :user commands

man 5 passwd                 :file format

man 8 lvm                    :adminstrator commands

(2)man pages

/:man中查找所有

n/n:下一个/上一个

q:退出man

man -k :查找所有包含的命令

 

3、the info command = web man

tab:movethe next link

n:下一小节

p:上一小节

u:上一层小节

s[]:searchfor text

q:退出

 

二、browsing the filesystem

1、mountpoints

/media:floppy and cdrom

/mnt

 

2、important directories

/etc:systemconfig files

/boot:kerneland bootloader

/dev:device

/usr:programs

/varand /srv:server data

/proc:systeminformation,是一个虚拟目录

 

3、current working directory

pwd:displaythe path

 

4、copying files and directories

1)copy file

cp[option] file destination

cp/tmp/abc.txt /doc

cp –p/tmp/abc.txt /doc :保留所时间戳

 

2)copy directory

cp –r/tmp  /doc

cp  -r –p /tmp /doc:保留所时间戳

or

cp –a /tmp/doc

 

3)copy more file

cpabc.txt dd.txt /doc

 

5、moving and renaming files and directories

1)move or rename file

mv[option] file destination

mv/doc/aaa.txt /doc/bbb.txt  : rename

mv/doc/bbb.txt /tmp/aaa.txt

mv/doc/bbb.txt /tmp

 

2)move or rename directory

mv jpgcalendar   :将目录jpg改为calendar

mv jpgdoc        :将目录jpg移入doc中

 

3)move more file

mv/doc/aa.txt /doc/bb.txt /jpg

 

6、creating and removing files

1) removing files

rm[options] filenames

-i:interactive确认信息)

-r:recursive

-f:force

 

rmabc.txt = rm –i abc.txt

rm –fabc.txt

2) removing directory

rmdirjpg      :jpg必须为空目录

rm –r  jpg    :jpg可不为空

rm –f  jpg

 

3)creating files

touchfilenames

touch/tmp/aaa.txt

 

4)createing directory

mkdir/tmp/doc

 

5)determining file content

file[options] filenames)

filedoc/aaa.txt

 

6)viewing an entire text file

i)cat显示文件所有内容)

cataaa.txt

cat –aaaa.txt    :会出现换行符

cat –saaa.txt    :将2行以上的空白行合并为一个空白行

cat –baaa.txt    :显示行号

ii)less分页显示文件内容)

less aaa.txt

/text  – search for text

n      – next match

v      – open file in text editor

i      – insert mode

q      – quit

 

三、the bash shell

1、wildcard通配符)

*      : zero or more characters

?      : any single character

[a-z]  : a range of characters

[^a-z]: all except the range除外)

 

lstest[1-2].*  : test1.txt test2.mp3

lstest[^1].*   : test2.mp3 test3.txt

2、 history历史指令)

history: 列出所有历史指令

!76    : 执行第76号历史指令  如:passwd–status user2

^2^1    :将上一个指令中的2改为1 :passwd –status user1

         ping 192.168.0.196

         ^196^1

         ping 192.168.0.1

3、tilde~)

cd~  :回到当前用户的home目录

ce~user1 :回到user1的home目录只有root才有权限进入其它用户的home目录)

 

4、{}

touch{a,b}       : create file a and b

toucha{a,b}      : create file aa and ab

touch{a,b}.{1,2} : create file a.1  a.2  b.1 and b.2

 

5、command output :在命令中输出其它命令的结果

``or$) : ``为键盘~下的`

echo “hostname : `hostname`”

ehco “hostname : $hostname)”

 

6、重定向 > >>  <

>  : 输出重定向覆盖 overwrite)

>>:输出重定向append)

<  : 输入重定向

 

0 :standard  input

1 :standard  output默认)

2 : standard  error

 

find/etc –namepasswd 1 > stdout   = find /etc –namepasswd > stdout

find/etc –name passwd2 > stderr

find/etc –namepasswd 2 > errs 1 > output :错误导出到errs,输出导出到output

find/etc –namepasswd > alloutput 2 >&1 : 错误和输出都导出到alloutput

find/etc –namepasswd &> alloutput : &表示0,1,2..

 

tr'a-z' 'a-z' < .bash_profile : 将.bash_profile中所有大写字母改为小写字母

 

7、cut : 显示某列信息

-f :specifies field or column –指定字段或列

-d :specifies field delimiterdefault is tab) –指定分隔符

-c :cuts by characters  –显示指定位置的字符

 

cat/etc/passwd

    root:x:0:0:root:/root:/bin/bash

    bin:x:1:1:bin:/bin:/in/nologin

    daemon:x:2:2:daemon:/in:/in/nologin

cut -f3-d: /etc/passwd

    0

    1

    2

cut-c4-8 /etc/passwd  –显示第4列到第8列的字符

    t:x:0

    :x:1:

    mon:x

 

8、sort :排序,但不改变文件内容

-r : 反向排列

-f : 不区分大小写

-u : 唯一,去重 unique

-t : 设定栏位之间的间隔符

-n : 按数值排列

-k : 按指定列排序

 

sort-ruf aaa.txt

sort-t: -k3 -n /etc/passwd

 

9、pipes |

ls -l/etc | less

cut -f1-d: /etc/passwd | sort -r | less

 

10、mail

sendingmail:

mail -s "1st mail" user2 回车输入内容 回车 .一定在第一列,表示mail结束) cc:回车发送

readingmail:

cat /var/spool/mail/user2

or

mail x离开: 邮件不删除,q离开:删除阅读过的邮件,将邮件移到~user2/mbox)

ls -l | mail -s "3rd mail" user2 : 将ls -l的内容用邮件发送给user2

 

11、xargs

catdelete_file.txt | xargs rm -f : 无提示信息的删除delete_file.txt文件中文件名所对映的文件

delete_file.txt的内容:

f1.txt

f2.txt

f3.txt

 

12、tee :资料分流

cut -f1-d: /etc/passwd | tee cut.file |sort | tee sort.file | less :将cut的内容导出到cut.file,然后排列,并将排列后的内容导出到sort.file中,并在桌面一面一面的显示

 

四、users groups and permissions

1、user

less/etc/passwd

用户名:有无密码x有,空无) :

uid :gid : 说明 :home目录   :  默认shellu

user1:  x                 : 502 : 503 :      :/home/user1 :  /bin/bash

less/etc/shadow

用户名 : 有无密码$1$开头表示设定好密码,!!开头表示密码未设定)

user1  : $1$dg5h312o$z29/fgprtpvnkltyztcrg/ :15854:0:99999:7:::

 

2、groups

less/etc/group

组名   : 有无密码: gid : 组成员

user1  : x      : 503 :

 

less/etc/gshadow

组名 : 有无密码 : gid : 组成员

dba  :   !     :     : oracle

 

3、file security

-r :read           4)

-w :write          2)

-x :execute        1)

 – : no permission  0)

 

4、chmod

chmod[-r] mode file : -r表示将整个目录的文件设定为指定状态

mode:

   u : owner

   g : group

   o : other

   a : all

  

chmodgo w doc

chmod-r ugo-r doc

chmod-r 754 doc

 

五、vi editor basics and printing

1、three modes of vi

1)command mode

2)insert mode a or i,esc退出到command mode)

3)extended mode:)

 

2、cursor movement

  command mode :

      w: 下一个单词

      b: 上一个单词

      : 上一个句子

      ): 下一个句子

      {: 上一个段落

      }: 下一个段落

     

3、entering insert mode

  a : append after the cursor

  i : insert before the cursor

  a : append to end of line

  i : insert at beginning of line

  o : open a line below在光标下方新增空白行)

  o : open a line above在光标上方新增空白行)

 

4、change delete yankcopy) and putpaste): command mode

                  change       delete   yankcopy)

line          :    cc           dd        yy

letter字母)  :     cl           dl        yl

word          :    cw           dw        yw

 

p : 行paste在上方,单字则在光标后面

p :行paste在下方 ,单字则在光标前面

 

5dd : delete5 lines

5yy :copied 5 lines

5x  : delete 5 characters

 

u : 撤消上一个编辑操作 undo)

u : 行撤消,撤消所有在前一具编辑行上的操作

ctrl r : 恢复,即回退前一个命令redo)

 

5、searching for text : command mode

/text :向下查找指定关键字

?text :向上查找指定关键字

 

n :相同方向继续查找

n :相反方向继续查找

 

6、sing and quitting : ex mode

:w  : singwriting)

:q  : quitting

:wq :sing and quitting

!   : forcing

 :w!  : forcing se

 :q!  : forcing quit

   :wq! :forcing se and quit

 

7、printing in linux

1)system-config-printer :  打开打印机设置

2)lprlp) : 打印文件 

lpr abc.txt 

lpr –pmylp abc.txt  :指定名为mylp的打印机打印

or

lp –dmylp abc.txt

 

3)lpqlpstat)  : 查看所有打印机的打印池 ,queue地址为/var/spool/cpus

lpq  -pmylp

or

lpstat

 

4)lprmcancel) :删除指定jobid的打印文件

lprm 2

or

cancel 2

 

5)lpmove : 切换打印机打印

lpmove mylp1-9 mylp2 : 将打印机mylp1中的jobid为9的文件切换到mylp2打印

 

6)lp:插队

lp -i17-q51 : 将jodid为17的文件的优先级设为51(默认为50)

disablemylp1 : 停用mylp1

/user/bin/enablemylp1 : 启用mylp1首先打印优先级高的文件)

 

rejectmylp1 : 不能向打印机mylp1的池增加打印文件

acceptmylp1 : 可以向打印机mylp1的池添加打印文件

 

7)printing utilities

enscript: converts text to postscriptps)

enscript abc.txt -p abc.ps

ggv : 查看ps or pdf文件

ggv abc.ps  orggv abc.pdf

ps2pdf: ps to pdf converter

ps2pdf abc.ps > abc.pdf

pdf2ps: pdf to ps converter

pdf2ps abc.pdf > abc.ps

mpage :将多页合并为一页打印

mpage -4 abc.ps > mpageabc.ps 4页到1页)

 

六、filesystem in-depth

1、ln : 创建快捷方式symbolior soft) links单独的一个文件,指向目标)

ln -ssrcfilename objfilename

ln -stest testlink;

ls -l :可以查看link,

    ls -li desktop/

ls -i :可以查看inode-no. inode-no对应inode-table相当于分区表)

 

2、hard links : 将多个的文件对应到一个inode-no(ls -i 的inode-no相同)

lndoc/doc1 backup

 

3、the seven fundamental filetypes

- file

ddirectory

lsymbolic link

b blockspecial file如:/dev/sda1)

ccharacter special file如:/dev/mice 鼠标、键盘等)

p namedpipe(如:/dev/initctl)

ssocket如:/dev/gpmctl)

 

4、checking  freespace

  df : 查看目录使用空间情况

  df -h

  df doc

  df -h doc

  du:查看目录中文件使用空间情况

  du -s:查看指定目录总共使用多少空间

  du -h /tmp

  du -sh /tmp

 

5、removable media

beforeaccessing, media must be mounted

beforeremoving, media must be unmounted

 

6、mounting cd and dvd

gnome/kdeautomatically mount /media/cdrom

mkdircdrom

mount/dev/hdc cdrom

ls -lcdrom

umountcdrom = eject cdrom

 

7、mounting u media

对应设备文件:/dev/sdax(linux将u视为一个scsidevices)

gnome/kdeautomatically mount /media/

mount/dev/sda1

 

8、mounting floppy disks

mount  /dev/fd0 /media/floppy/

umount/media/floppy/

9、formatting floppy disks

1) a low level format:低格

    fdformat /dev/fd0h1440

2) a filesystem

    mkfs -t ext2 /dev/fd0

    mke2fs /dev/fd0

    mkfs -t vfat /dev/fd0

 

10、tar:打包文件,但不压缩

1)打包文件

tar cvfarchive_name files….

  -c : creates a new archive

  -v : produces verbose messages:显示打包了的文件

  -f : archived_name is name of new file:f后面跟的是打包文件名

  -p : 保留原属性

  -z : 使用gzip压缩文件

  -j : 使用bzip2压缩文件

tar cvf~/doc.tar doc

tarcvfz ~/doc.tar.gz doc : 使用gzip压缩文件

tarcvfj ~/doc.tar.bz2 doc : 使用bzip2压缩文件

2)查看打包文件

tar tfarchive_name.tar:只显示清单

tar tvfarchive_name.tar:清单和详细信息

tarztvf arch_name.tar.gz :查看含gzip属性的tar文件

 

3)解压打包文件

tar xvfarchive_name.tar

  tar zxvf /tmp/etc.tar.gz /tmp

  tar zcvpf /tmp/etc.tar.gz /tmp

 

11、压缩文件

(1)gzip  gunzip

        -v : 显示压缩比

    -c : 保留原文件,新增压缩文件

     gzip filename:只保留压缩文件,原文件删除

       gzip abc.txt : 只剩abc.gz,abc.txt 删除

       gzip -vc abc.txt > abc.gz : abc.txt保留,该命令只能压综文件,不能压缩目录

     gunzip filename

       gunzip abc.gz

   

(2)bzip2  bunzip2

 

七、configuring the bash shell

1、查看variable

set:查看所有变量

env: 查看环境变量

 

2、查看指定变量

echo$oracle_home

 

3、the ps1 local variable

ps1 :sets the prompt提示符)

    \d : today's date

\h :short hostname

\t:current time

\u:user name

\w:current working directory

\! :thehistory munber of current command

\$:shows $ or #root)

\l :theshell's terminal device name. ==tty

echo$ps1

    [\u@\h \w]\$

ps1='[\u@\h \w \l \d \t \!]\$'

 

4、aliases别名)

aliaslf='ls -laf'

 

nautilus:打开图形文件框

 

八、advance topics in users,groups and permissions

1、/etc/passwd /etc/shadow and /etc/group files

/etc/passwd: user database

/etc/shadow: password database,用user id and password以 md-5 hash

/etc/group: group database

 

2、changing your identity

passwdusername :只有root可以修改所有用户密码

passwd :修改自已密码

passwd–status username:查看密码状态

 

3、su

suusername : 切换用户,不切换环境变量

su -username : 切换用户,同时切换环境变量

su : 切换到root

su – :切换到root,同时切换环境变量

 

4、user information commands

whoami: 查看当前用户

groups: 查看当前用户属于哪些组

id : 查看用户详细信息

users :查看当前登陆系统的用户名

who : 查看当前登陆系统的用户名、登陆时间点、登陆地点

w : 查看当前登陆系统的用户名、登陆时间点、登陆地点、使用的指令、占用的cpu

last : 查看用户的历史登陆时间和reboot的记录

 

5、default permissions

defaultpermissions for file is 666 ugo:rw-rw-rw-)

defaultpermissions for directories is 777 ugo:rwxrwxrwx)

defaultumask is 002

rootdefault umask is 022

file666 umask 002 = 664 ugo:rw-rw-r–)

root666 umask 022 = 644 ugo:rw-r–r–)

file666 umask 033 = 644 ugo:rw-r–r–)

 

6、special permissions特殊权限)

suid4): user    s or s  以文件所有者身分执行命令,而不是执行者本身的权限来执行

sgid2): group   s or s  以文件所在组身分执行命令

sticky1): other t or t  以文件所在组的other组身分执行命令

 

chmodu s filename1 

  -rwxr-xr-x —>  rwsr-xr-x

chmodg s filename2 = chmod 2755 filename2 2表示g)

  -rwxr-xr– —>  rwxr-sr-x

chmodo s filename3

  -rwsr-xr-x —>  rwxr-sr-t

  -rwsr-xr– —>  rwxr-sr-t

chmod7755 filename4  第1个7表示4 2 1=suid sgid sticky)

  -rwxr-sr-x —>  rwsr-sr-t

 

 

 

 

九、advanced users of the vi editors

1、file repositioning文件中快速定位)

  g : go to last line in file

  1g : go to first line in file

  ctrl d : go down half a screen

  ctrl u : go up half a screen

 

2、screen repositioning屏幕中快速定位)

h : goto first line on screenhigh)

m : goto middle lin on screen middle)

l : goto last line on screenlow)

z enter: make current line first line on screen将光标所在行变为屏幕的第一行)

z-:make current line last line on screen将光标所在行变为屏幕的最后一行)

 

3、filtering

   the output of a command can be placed in thefile : 将指令执行的信息插入到当前编辑的文件中

   the data int the file can be used as input :将文件内容当作命令的输入使用

   examples:

   vi编辑文件时,在commandmode下输入

   !!ls -l : ls -l的结果插入到光标所在位置

   !!date : date的结果插入到光标所在位置

   !}sort : 光标后的内容排序,也就是将文件内容当成命令的输入在使用

   !}fmt -w60 : 将文件宽度设为60

  

4、search and replace extended mode,也称末行模式last line mode—执行待定命令)

   :s/this/that : 将当前行中第一个的this替换为that

   :s/this/that/g : 将当前行中所有的this替换为that

   :1,10s/this/that/g : 将第1行到第10行中所有的this替换为that

   :1,$s/this/that/g : 将文件中所有的this替换为that. $表示文件最后面,%也是同样功能

   :.,. 10s/this/that/g : 将当前行开始 10行共11行)中所有的this替换为that.  表示向下,-表示向上

 

5、advanced reading and sing

   :r file1 : 将file1中内容输入到当前文件中

   :1,20w file2 : 将当前文件中1到20行内容写入file2中覆盖file2中原有内容)

   :1,$w file3 : 将当前文件中所有内容写入file3中覆盖file3中原有内容)

   :1,20w>> file4 : 将当前文件中中1到20行内容append到file3中

  

   同时用vi开启多个文件时:

   :n   :  move to the next file

   :rew :  rewind to the first file

   :n#  :  jump to the previous file, thustoggling between two files两个文件之间互相切换)

 

6、configuring vi

   :set :  查看基本设备选项

   :setall :查看所有可以设定的设定选项,以no开头的表示没有设定

       nonumber : 表示没有设定启用行号,设定后变为number

       :set number       : 显示行号

       :set nonumber     : 不显示行号    = :set nonu

       :set ignorecase   : 表示设置不区分大小写

       :set noignorecase : 表示设定区分大小写 = :set noic 

       

       

 

十、introduction to string processing

1、head

  head file1 : 默认显示文件前10行

  head -n 15 file1 : 显示文件前15行

  head –lines 17 file1 : 显示前17行  

  head -12 file1 : 显法前12行

 

2、tail

  -f : ,持续显示,文件更新后立即显示

  tail file1 : 默认显示文件最后10行

  tail -n 15 file1 : 显示文件最后15行

  tail –lines 17 file1 : 显示最后17行  

  tail -12 file1 : 显法最后12行

  tail -f file1 : 文件更新后立即显示

 

3、wc字数统计)

  -l : 统计行数line)

  -w : 统计单词数word)

  -c : 统计字符数character)

  wc readme = wc -lwc readme

  cat /etc/passwd | wc -l : 查看系统用户数量

 

4、uniq去掉文件中相邻的相同的行)

  -c : 查看重复的行有多少

  uniq filename

  uniq -c filename

  所以,可以先sort后,再uniq

  sort filename | uniq = sort -u filename

 

5、other string processing tools

    1)paste: 将多个文件的内容合并到一个文件中

      paster file1 file2 file3 > merge2  : 水平合并

      =

      cat file1 file2 file3 > merge2     : 垂直合并

    2)tr : 字符转义器

      tr 'a-z' 'a-z' < .bash_profile :将bash_profile中所有大写改为小写

     

      cat -a file4 | tr '$' '\r' >file4.txt  : 将file4中$转为\r

          cat -a file4 : 显示file4所有内容,包含段落标记

          unix2dos file4 : 将unix转为dos格式

 

6、version comparison with diff

  tail abc abc : 显示abc与abc文件

  diff abc abc : 比较两个文件不一样   = sdiff abc abc 以|表示不一样)

      1c1 : 表示第1行不一样

      <  :表示在第1个文件中abc)

      >  :表示在第2个文件中abc)

     

7、spell checking with aspell拼写检查)

  aspell check letter   : 以/usr/share/dict/words中的内容为蓝本

  look exer : 查看以exer开头的单词

 

8、formatting tools

expandfile > test : 将file中的tab转化为空格

fmt -u-w50 read   : -u格式化空格的规格1个空格),-w规定行宽

pr -5/tmp/words | more :  按打印机格式排版5列)

 

 

 

 

 

rh133 red hat enterprise linux systemadministrator

 

一、installation

1、device node examples

1)block devices512/1024 bytes)

/dev/hda: ide drives

/dev/sda: scsi drives

/dev/fd0: standard floppy

ls –l /dev/sd*

2)character devices1 byte)

/dev/tty[0-6]: virtual consoles

/dev/st0      : scsi tape drive

ls –l /dev/tty* | more

3)symbolic links

ls –l /usr/ |grep ^l | more :列出开头为l的文件

 

2、sample partition structure

mbr :512bytes

boot loader : 446bytes

parition table : 64bytes

magic : 2bytes

 

3、configuring file systems

swapspace is typically 2x physical ram

typicalmount points : /boot /home /usr /var /tmp /usr/local /opt

 

4、software raid

raid 0: high speed、unsafe  and size is n

raid 1: low speed、 safe  and size is n/2

raid 5: highter speed than raid1、safer than raid 0 and  n-1

 

5、lvm : logical volume manager

pvphysicalvolume) —> vgvolume group) —> pephysical extent)

 

6、validating the installation

dmesgand /var/log/dmesg

/var/log/messages

/root/instll.log

 

7、post-install configurationsystem-config-?)

system-config-date  : 打开日期图形设置界面

system-config-display : 打开显示分辩率图形设置界面

system-config-network  : 打开网络图形设置界面

 

 

二、system initiazation and services

1、boot sequence overview

bios —>mbr —>kernel —>init

 

2、grub  and grub.conf

1)grub : the grand unified bootloader

2)/boot/grub/grup.conf

default=0: 默认选择第1组one title)开机

timeout=5: 选择时间为5秒

passwordredhat : 将进入grub的密码设为redhatp进入)

或用grub-md5-crypt加密grub密码

password –md5 $1$94afadfpat0/tkplsrhdkgy

hiddenmenu: 隐藏开机选项windows or linux)

kernel/vmlinuz-2.6.9-5.el ro root=label=/ rhgb quiet

  ro : read only

  label=/ : root的根目录位置.  =  root=/dev/sda2/ 所在分区)

rhgb : 以图形界面方式显示开机信息,如以文件显示刚删除rhgb

quiet : 不显示错误信息,如要显示则删除quiet

3)/in/grub-install /dev/had : 重新安装bootloader

4)edit grub

a :append.只能在ro root=label=/ 后面追加命令,不能修改

grup append> ro root=label=/ 1 :以single usermode启动

e: edit.在选择需修改的行后,按e修改。

c:command-line

 

3、/etc/inittab :

id:5initdefault)—>/etc/rc.sysinit—>/etc/rc5.d/* /etc/rc.local) —>/in/mingetty—>/etc/x11/prefdmifis 5) or text modeis not 5)

 

4、run levels

0 : halt关机do not set initdefault to this)

1 :single user modes,only the root can be logged on,used to perform mantenance

  run level 1 : init —> /etc/rc.sysint—>/etc/rc1.d/*

run level s : init —> /etc/rc.sysint

run level emergency : init —> some /etc/rc.sysint

2 :multi-user,without nfs networking

3 :full multi-user modeincludes networking)

4 :userdefinable,but duplicate of runlevel 3 by default默认与3相同)

5 :x11includes networking)

6 :rebootdo not set initdefault to this)

 

initnumber : 进入相应的run level,如xll下init 3,则进入textmode

runlevel: 显示前一个级别和当前级别.如5 3 表示从5到3

 

5、/etc/rc.d/rc<5>.d

/etc/init.d/httpdstart  : start http

/etc/init.d/httpdstop   : stop http

/etc/init.d/gpmstart    : start gpm鼠标)

/etc/init.d/gpmrestart    : restart = reload

/etc/init.d/gpmreload

/etc/init.d/gpmstatus

 

6、controlling services

1)default startup

ntsysv: 设置启动/停止的自动服务默认只是当前runlevel)

ntsysv –level35 : 设置在runlevel 3和5上的启动/停止的自动服务.

chkconfiggpm –level123 off : 在1、2、3的runlevel上关闭gpm鼠标)服务

ls –l/etc/rc*.d/*gpm

chkconfiggpm –list : 查看gpm服务在所有runlevel上设定情况

system-config-services: 图形界面下设置启动/停止的自动服务(只能设定345)

2)manually startup

service: 手动立即启动/停止服务不建议使用,建议使用/etc/init.d/ start)

service gpm stop

/etc/init.d/gpm start

chkconfigtelnet offon)

system-config-services

 

7、system shutdown

shutdown–h now

halt

poweroff

init 0

 

8、system reboot

shutdown–r now

reboot

init 6

 

三、kernel services and configuration

1、the /proc filesystem

/procis a virtual filesystem containing information about the running kernel

cat /proc/cpuinfo

cat /proc/meminfo

/procsubdirectories:

/proc/scsi/ 、 /proc/sys/ 、/proc//

 

echo “1” >/proc/sys/net/ipv4/icmp_echo_ignore_all: 禁用icmp包

将/proc/sys/net/ipv4/icmp_echo_ignore_all的内容设为1,禁用icmp包

echo “0” >/proc/sys/net/ipv4/icmp_echo_ignore_all: 启用icmp包

将/proc/sys/net/ipv4/icmp_echo_ignore_all的内容设为0,启用icmp包

 

2、/proc/sys configuration with sysctl

 修改/proc/sys中的参数,只是临时有效,重启后失效

 sysctl修改后,永久有效,会写入/etc/sysctl.conf中

 sysctl –p :显示sysctl.conf中内容

 

3、system monitoring and process control

top :display snapshot of processes

gonme-system-monitor: display snapshot of processes图形界面下显示)

vmstat: reports virtual memory stats

  eg : vmstat

us : user space |  sy : system call  |  id :idle  | wa : waiting

free :summary of system memory usage

renice: chang priority of a process

kill :send system signal to a process

 

四、filesystem management

1、managing partitions

1)fdisk

fdisk –l/dev/sda : 查看sda分区

fdisk /dev/sda  : n –> 回车 –>回车–>输入大小 –>w

m :help

p : 查看分区表

2)partprobe : 重新初始化kernel的partition table(不用reboot)

 

3)mke2fs [options] device

dumpe2fs/dev/sda1 | more : 查看sda1分区的详细说明

 

-b : 设定block size的大小,default为1024=1k, 最大为4k.

emke2fs –b 4096/dev/sda1

-c :check the device for bad blocks before creating the filesystem

-i : 设置每个inode的大小

emke2fs –i 4096/dev/sda1

-n : 设定inodes的总数量

emke2fs –n 20000/dev/sda1

-m : 设定分区上保留多少空间给super userroot),default to 5%

emke2fs –m 10/dev/sda1

-l : 设定分区的label

emke2fs –l data/dev/sda1

-j : createan ext3 journal inode and filesystemext3格式文件系统)

emke2fs –j/dev/sda1

 

2、ext3 : journaling ofr ext2 filesystem

ext2转ext3 : tune2fs -j /dev/sda6资料会保存)

ext3转ext2 : emke2fs  /dev/sda1 重新格式化)

 

3、filesystem labels

e2label/dev/sda1 : 查看sda1的label

e2label/dev/sda1 /date : 设定sda1的label为/data

注意:不要改变sda1至sda5的label,未则可能造成不能开机

4、mount

mkdir/data

mount :查看所有挂载点的信息

mount/dev/sda6 /data

以label名来mount

mount-l /data /data : 将label为/data第一个) mount 到/data目录第二个)

 

mountoptions:

mount [-t vfstype] [-o options] device mount_point

-t : vfstypevfat ext2 ext3 iso9660 ) ,but notnormally needed

mount -t iso9660 -o ro,loop boot.iso /iso : 将boot.iso mount到/iso

-o :

     suid: suid or sgid file modes honored

ro : read only access

rw : read write access

default option for the ext2/ext3 filesystem:

rw,suid,dev,exec,auto,nouser and async

mount-o remount,ro /data : 将/data目录重新mount为read only模式

mount-o noexex /dev/sda6 /data : mount后,禁止/data目录下文件的执行权限

 

 

5、umount

umountdevice | mount_point

umount/dev/sda6

umount/data

 

6、fuser

-v : 显示哪个所有者或服务正在使用指定目录

fuser -v /data

-k : killprocesses accessing the named file

-m : showall processes using the named filesystems

fuser -km /data

umount /data 当设备忙时,可以先fuser-km 后,umount)

 

7、connectiong network resources

1)nfs

showmount-e ip : 查看指定ip的共享

showmount -e 192.168.0.144

mount ip:/shared/dir /mnt/nfs : 持载 共享目录

mkdir /mnt/nfs

mount 192.168.0.144:/var/ftp /mnt/nfs

ls -l /mnt/nfs

2)b

bclient -l ip -n : 查看指定ip的b共享

bclient-l 192.168.0.165 -n

mount //ip/share_name /mnt/b -ousername=account%password

  mkdir /mnt/b

  mount//192.168.0.165/rhce /mnt/b -o username=administrator3456

  ls /mnt/b/

 

8、/etc/fstab  : auto mount

cat/etc/fstab

设备

挂载点

文件类型

参数

dump_freq

fsck_order

label=/boot

/boot

ext3

defaults

1

2

tmpfs

/dev/shm

tmpfs

defaults

0

0

devpts

/dev/pts

devpts

gid=5,mode=620

0

0

sysfs

/sys

sysfs

defaults

0

0

proc

/proc

proc

defaults

0

0

/dev/volgroup00/logvol01

swap

swap

defaults

0

0

/dev/sdb1

/tools

ext3

defaults

1

2

 

dump_freq:是否备份(0不备份、1每天备份、2每2天备份…..)

fsck_order:自检顺序(0不自检、1第一个自检)和2(第二个自检)自检、如根分区为1则其它分区只能是2)

 

example:

cp /etc/fstab  /etc/fstab.bak

vi/etc/fstab

yy复制一行

p粘贴

修改为:/dev/sda6  /data   ext3    defaults    1   2

文件系统类型用mount查看

:wq

reboot

 

/etc/mtab: 当前挂载点记录

 

9、auto.master : 监控mount

1)设定auto.master文件

vi/etc/auto.master

增加:

/mnt/nfs   /etc/auto.nfs  –timeout=60  60秒无操作自动卸载,auto.nfs可自定义文件名)

:wq

2)设定auto.nfs

cp/etc/auto.misc /etc/auto.nfs

vi/etc/auto.nfs

新增

server1    -ro,soft,intr      192.168.0.144:/var/ftp

:wq

server1: 自定义名称

soft    : nfs故障时给使用者传回信息

intr    : 允许中断

3)杳看共享内容

cd/mnt/nfs

ls 无结果)

serviceautofs restart :启动auto.master服务

cd/mnt/nfs

ls 无结果)

cdserver1

ls 有结果)

mount可看到servier1r的挂载点)

 

10、ext2/ext3 filesystem attributes

1)lsattr: display file attributes

lsattr

lsattr/data

lsattr/data/abc.emp

2)chattr: changes file attributes

chattr -)=attribute file

a : 不修改文件存取的时间

a : 只能append,不能修改以前的内容

d : 备分时,不备份该文件

i : 不能将文件删除和改名

j : 将文件的meta-data记录在ext3的journal内

s : 文件被修改后,立刻将内容写入到磁盘里否则先buffer)

example:

lsattr test

chattr a test

lsattr test

cat > test   : operation notpermitted

cat >> test  :可append

chattr -a test

lsattr test

 

chattr =aas test  : 在test上设定a、a、s属性

lsattr test

chattr = test  : 取消所有属性

lsattr test

 

11、virtual memory

1)createswap partition

fdisk /dev/sda  :

 n 

回车

100m  

t修改partition’s system id)

7刚建立,是最后一个)

l查看所有partition’s system id,82为swap)

82

p查看partition table)

w

partprobe让partition table立刻生效)

mkswap /dev/sda7  写入特定的swap识别标识)

vi /etc/fstab

/dev/sda7   swap    swap    defaults    0   0

:wq

  swapon -s 杳看swap启用状态)

swapon -a 启用所有swap分区)

swapon -s 杳看swap启用状态)

 

2)createswap file

dd if=/dev/zero of=/swapfile bs=1m count=100

dd:convertand copy file

if:inputfile

/dev/zero:与/dev/null一样是一个伪文件,产生连续不断的二进制零流,写入人的输出会丢失不见. 而从/dev/zero读出一连串的null也比较因难,可通过od或16进制编辑器来做到.主要用来创建一个指定长度的初始化空文件。就像临时交换文件

of:outputfile

bs:blocksize

swapfilesize = bs*count = 1m*100 = 100m

ls -lh/swapfile

mkswap/swapfile  写入特定的swap识别标识)

vi/etc/fstab

/swapfile   swap    swap    defaults    0   0

:wq

swapon-s 杳看swap启用状态)

swapon-a 启用所有swap分区)

swapon-s 杳看swap启用状态)

 

12、filesystem maintenance

1)fsck: check filesystem

检查之前先umount,检查有问题就会copy到lost found目录中

umount/data /data = /dev/sda6)

fsck -y/dev/sda6  :  -y 表示任何问题都回答yes

mount/data

 

2)sulogin:  系统出现严重错误时,系统会进入sulogin模式

实验:

vi/etc/fstab

将lable=/ 修改为lable=abc

:wq

reboot

出现错误,系统无法挂载根目录

ortype control-d to continue):

输入root的密码

repairfilesystem) 1 #   : 进入了sulogin模式

ls该状态下可能输入指令)

vi/etc/fstab   readonly mode)

将lable=abc 修改为lable=/

:wq!  报错,因为此时要目录的partition是readonly模式挂载)

:q!

mount-o remount ,rw /dev/sda2  : 将根目录/重新挂载为rw

vi/etc/fstab

将lable=abc 修改为lable=/

:wq!

reboot

 

13、adding a drive

实验:

增加10g硬盘一个

fdisk-l检查硬盘,未检测到新硬盘,重启

fdisk-l

fdisk/dev/sdb  输入n/p/1/回车/回车/w

fdisk-l

mkfs -text3 -c /dev/sdb1   //format

cd /

mkdirfujian

mount/dev/sdb1 /fujian

df -h

vi/etc/fstab

文件最后填加以下内容,让系统自动挂载

/dev/sdb1      /fujian      ext3   defaults   1  2

reboot

df -h

 

五、network configuration

1、device recognition

/etc/modprobe.conf : 为每个网卡定义别名

alias eth0 vmnics

 

2、ifconfig

将eth0的ip设为10.0.1.100临时有效)

ifconfig eth0 10.0.1.100 netmask 255.0.0.0 broadcast 10.0.1.254

 

3、ifup/ifdown : start or stop network interfaces

ifdowneth0

ifupeth0

 

4、interface configuration files

locaktedin : /etc/sysconfig/network-scripts/

 

ls/etc/sysconfig/network-scripts/ifcfg*

cat/etc/sysconfig/network-scripts/ifcfg-eth0

device=eth0

bootproto=nonestatic、dhcp)

hwaddr=00:50:56:a3:78:bc

onboot=yes开机启动)

netmask=255.255.255.128

ipaddr=192.168.1.144

gateway=192.168.1.254

type=ethernet

userctl=no

ipv6init=no

peerdns=yes

 

5、configuration utilities

(1)netconfigtext)

cd/etc/sysconfig/network-scripts/

lsifcfg*

rmifcfg-eth0

lsifcfg*

 

netconfig   : default is eth0

lsifcfg*

catifcfg-eth0

dhcp:

device=eth0

bootproto=dhcp

onboot=yes

static:

device=eth0

bootproto=static

onboot=yes

netmask=255.255.255.128

ipaddr=192.168.1.144

gateway=192.168.1.254

ifconfig

ifdowneth0

ifupeth0

ifconfig

 

设定指定网卡:

netconfig –device eth1  : 设定eth1

 

手动设定网卡:

vi ifcfg-eth0

device=eth0

bootproto=static

onboot=yes

netmask=255.255.255.128

ipaddr=192.168.1.144

gateway=192.168.1.254

:wq

cat ifcfg-eth0

ifconfig

ifdown eth0

ifup eth0

ifconfig

 

(2)system-config-networkgraphical)

neat and system-config-network都可打开网卡设置图形界面

图形界面设置网卡会产生不必要的文件

在sysconfig中查找关键字192.168.1.144的文件

grep -rl 192.168.1.144 /etc/sysconfig

/etc/sysconfig/network-scripts/ifcfg-eth0

/etc/sysconfig/networking/devices/ifcfg-eth0

/etc/sysconfig/networking/profiles/default/ifcfg-eth0

只需保留/etc/sysconfig/network-scripts/ifcfg-eth0就可以了

 

6、binding multiple ip addresses

绑定少量ip:

必须以ifcfg-ethx:xxx形式设定文件

实验:在eth0上增加ip :192.168.1.156

cp ifcfg-eth0 ifcfg-eth0:0

ls ifcfg*

vi ifcfg-eth0:0

修改:device=eth0:0

ipaddr=192.168.1.156

:wq

cat ifcfg-eth0:0

ifconfig

ifdown eth0

ifup eth0

ifconfig

 

绑定大量ip:

以ifcfg-ethx-rangex形式设定文件

实验:在eth0上增加10个ip :192.168.1.157-166

cp ifcfg-eth0:0 ifcfg-eth0-range0

ls ifcfg*

vi ifcfg-eth0-range0

修改:device= eth0-range0

删除ipaddr

ipaddr_start=192.168.1.157

ipaddr_end=192.168.1.166

:wq

cat ifcfg-eth0-range0

ifconfig

ifdown eth0

ifup eth0

ifconfig

 

7、global network parameters

/etc/sysconfig/network

networking=yes | no

hostname=  —fqdn : short name . domain name

gateway=

nisdomain=

 

8、static routes

    系统连接多个网段时,由kernel自动产生route

配置文件:

/etc/sysconfig/network-scripts/route-eth0

图形工具还会将设置写到: 

/etc/sysconfig/networking/devices/route-eth0

display with:

route -n

netstat -rn

 

manual set route:

route add -net 10.0.1.0 netmask 255.255.255.0 gw 192.168.0.144

net:表示加入一整个网段

route-n

  reboot后失效,如要长期有效,则要写入/etc/sysconfig/network-scripts/route-eth0文件中.

   cd /etc/sysconfig/network-scripts/

   vi route-eth0 不存在,新增)

      10.0.2.0/24 via 192.168.0.144

10.0.3.0/24 via 192.168.0.144

10.0.4.0/24 via 192.168.0.144

       :wq

cat route-eth0

route -n

ifdown eth0

ifup eth0

9、name resolution

hostname : 查看主机名,

主机名存放位置:/etc/sysconfig/network

 

10、dns

hosts文件与dns

在/etc/nsswitch.conf文件中的设定是默认先搜索/etc/hosts,再查找dns

将/etc/nsswitch.conf中的hosts:  files dns这行改为hosts:dns files则先搜索dns

 

11、dns client configuration

/etc/resolv.conf

    defines which name servers to use

    servers arc checked in order listed

   

cat /etc/resolv.conf

serch domain.com        : hostname =simple name domain namedomain.com)

nameserver 192.168.0.1  : dns server

nameserver 192.168.1.1  : dns server

 

ping server1时,自动为ping server1.domain.com

 

12、dns utilities

1)host: gather host/domain ifnormation

    host ns1.redhat.com   :显示ns1.redhat.comhas address 66.187.233.210

    host -a redhat.com    : 显示redhat.com主机上的dns记录

    host -a redhat.com | grep'^[^;]'   : 过滤分号开头的行

 

2)dig: send queries to name server directly

    dig ns1.redhat.com : 显示redhat.com主机上的dns记录

    dig ns1.redhat.com | grep'^[^;]'   : 过滤分号开头的行

    dig @ns1.redhat.com mx redhat.com| grep '^[^;]'

        在ns1.redhat.com服务器上查找domain为redhat.com的邮件服务器

        mx : 邮件服务器

 

13、network diagnostics

ping : network packet loss and latency measurement tool

traceroute 、mtr : displays network path to adestination

netstat : multi-purpose network information tool

 

六、rpm and kickstart

1、 rpm package manager

1)rpmcomponents

    local database : /var/lib/rpm

    rpm and related executables

    package files

   

2)primaryfunctions

    install/remove

    query

    verify

    build

   

2、installing and removing software

1)primaryrpm options

    install : rpm -ior–install)  —-新旧并存

    upgrade : rpm -uor–upgrade)  —-升级旧版本,无旧版本则安装

    freshen : rpm -for–freshen)  —-更新旧版本,无旧版本则不会安装

    erase   : rpm -eor –erase)    —-删除

2)outputoptions

    -v : 表示输出

    -h : 显示安装进度

   

3)example:

   rpm -ivhsysstat-5.0.5-1.i386.rpm   : 安装iostat工具

   rpm -e sysstat                      : 删除sysstat

   rpm -uvhftp://192.168.0.144/pub/redhat/rpms/sysstat*.rpm : 网络安装rpm包

   uname -r  : 查询kernel的版本

 

3、rpm queries

1)installedpackage options已安装)

    rpm -qa               : lists installed packages

    rpm -qf filename      : shows owning package从哪个包安装的)

    rpm -qi package_name  : general information列出已安装包的标准详细信息)

    rpm -ql package_name  : lists files in package

 

2)uninstalledpackage options未安装)

    rpm -qip package_file.i386.rpm

    rpm -qlppackage_file.i386.rpm   : 列出rpm包的文件内容

 

4、rpm verification

installed rpm file verification:

rpm -va  : verifieds all installedrpms against the rpm database

rpm -v package_name : verifies the installed package_name  against

the rpm database

rpm -vp package_file.i386.rpm: verifies the installed package_name  

against the package_file

 

5、other rpm utilities and features

1)rpm2cpio

rpm只能root能用,cpio所有用户可用

rpm2cpio sysstat-5.0.5-1.i386.rpm > sysstat.cpio

cpio -it < sysstat.cpio : 查看sysstat.cpio内有哪些文件,都是以相对路径格式,所以最好是放在单独目录中解压

mkdir sysstat

mv sysstat.cpio sysstat

cd sysstat

cpio -id < sysstat.cpio  : 解压sysstat.cpio

 

2)rpmdb-redhat: 记录本rpm包依赖性的资料库

3)system-config-packages: 打开add or remove packages图形界面

 

6、automatic dependency resolution(自动安装有依赖性的包)

1)条件:

用rpmdb-redhat资料库

有依赖性的包必须都在一个目录中

安装时加上-aid参数

2)example

rpm -ivh rpmdb-redhat-4-0.20050107.i386.rpm

rpm -ivh xsane-0.92-13.i386.rpm

error : failed dependencies

suggested resoltions:

libieee1284-0.2.8-4.i386.rpm

sane-backends-1.0.14-6.i386.rpm

rpm -ivh xsane-0.92-13.i386.rpm –aid

 

7、using kickstart to automate installation自动安装rhel)

ks.cfg : 应答配置文件

example:

system-config-kickstart

error:command not found

system-config-packages

打开add orremove packages,在system的administratortoos中选中system-config-kickstat,update,

rpm -ivhsystem-config-kickstart-0.2.5.16-12.noarch.rpm

system-config-kickstart

打开kickstart configurator对话框,一定要设定root密码

se /root/ks.cfg

也可以直接编辑/root/ks.cfg文件

vi /root/ks.cfg 

 

8、network installation server网络安装服务器)

1)server  : redhat.iso

2)server  : shares the redhat.isodirectorynfs、ftp、http)

3)clients : 放入ks.cfg 的软盘

4)clients : 用redhat.iso启动linux安装

5)clients : linux安装界面的boot: 输入linux ks=floppy

 

七、user administrator

1、/etc/passwd

finger username : 显示指定用户的信息

finger oracle

chfn -o value username : 给指定用户加上注解

 chfn -o 在中国 oracle

如果/etc/passwd最后一栏是/in/nologin,表示只能从ftp登陆

  ftp192.168.0.144  ftp/ftp登陆

如果/etc/passwd最后一栏是/bin/false,表示只能从发邮件,不能登陆

ls -l /etc/passwd 

-rw-r–r–,必须将read权限开放给所有用户,所有用户登陆时都要读取该文件

chmod 600 /etc/passwd

-rw——-

  user1登陆

error: id cannot find name foruser id 501

 

2、adding a new user account

1)新增用户:useradd username

  edit /etc/passwd、 /etc/shadow 、/etc/group  组名=用户名)

  create andpopulate home directory

  set permissionsand ownership

 

useradd user3

cat /etc/passwd

user3:x:503:504::/home/user3:/bin/bash

cat /etc/shadow

user3:!!:15861:0:99999:7:::

cat /etc/group

user3:x:504:

2)修改密码 :passwd username

passwd user3

cat /etc/shadow

user3:$1$qofqkg4g$cvbytvoksszxdevxhagbu/:15861:0:99999:7:::

 

3)批量建立用户 : newusers

新建newuser文件

vi newuser

格式:

用户名:密码:uid:gid:fullname:home:shell

user4:user4:505:505::/home/user4:/bin/bash

user5:user5:506:506::/home/user5:/bin/bash

user6:user6:507:507::/home/user6:/bin/bash

cat newuser

newusers newuser

 

3、group administrator

1)groupadd

groupadd group1  : 新增组group1

2)groupmod

group -n group2 group1 : 将group1重命名为group2

3)groupdel

groupdel group2 : 删除group2

 

4、modifying or deleting user accounts

1)edit /etc/passwd

2) modifying  user  : usermod

  id user3  : 显示user3的基本资料

 

mkdir /home/user-3

chown user3.user3 /home/user-3 :将user-3目录所有者改为 user3

usermod -d /home/user-3 user3 : 将user3的home目录修改为/home/user-3

 

usermod -g groupname username

usermod -g user3 user1 : 将用户user1加入user3组中

usermod -g groupname username

ussermod -g user3 user1 : 将用户user1的组更改为user3

 

usermod -l user1 : 锁定用户user1

usermod -u user1 : 解锁用户user1

3)、deleting user : userdel

userdel  -rusername  只删除/etc/group中相关组下的成员,不会删除所在组)

userdel -r user3

groupdel  user3 如果组中没有成员,则可删除)

 

5、password aging policies(密码有效期)

1)edit/etc/login.defs

 

2)chage

格式: chage [options] username

 

cat /etc/shadow

user3:$1$qofqkg4g$cvbytvoksszxdevxhagbu/:15861:0:99999:7:::

第一栏 : 用户名

第二栏 : 密码,$1$开头表示密码已设定好,!!表示未设定,!表示锁定不能登陆

第三栏 : 最后一次变更密码的日期,从1970年1月1日开始起算,chage -d

第四栏 : 密码最少要使用多久才能变更,0表示无限制,随时可以更改. chage -m

第五栏 : 密码每隔多久就要变更,99999表示无限制,可以永不变更.chage -m

第六栏 : 密码到期前多久就要提示用户变更密码.

第七栏 : 密码过期多久后,还未更改就锁定用忘户帐号. chage -i

第八栏 : 密码到期时间,sincejan 1 1970. chage -e

第九栏 :保留

 

chage -l user3 :  查看user3的密码情况

chage -d 20013-06-05 user3 : 将用户user3的密码最后变更日期改为20013-06-05

chage -m 10 user3 : 用户user3最少要在10天后才能变更密码,也就是该密码最少要用10天

chage -m 30 user3 : 用户user3每隔30天就必须变更密码

chage -i 3 user3 : 密码过期3天后,还未更改就锁定用user3帐号

chage -e 2013-08-31 user3 : 设定user3的密码到期日为2013年8月31日

 

6、login shell scripts(用户登陆时执行的shell

用户登陆时:

第一步:系统首先执行/etc/profile,

第二步:/etc/profile执行 /etc/profile.d/下所有shell: /etc/profile.d/*.sh

cat /etc/profile :

for i in /etc/profile.d/*.sh ; do

    if [ -r"$i" ]; then

        if ["$ps1" ]; then

            . $i

        else

            . $i>/dev/null 2>&1

        fi

    fi

done

第三步:系统执行~/.bash_profile

第四步:.bash_profile 执行~/.bashrc

cat ~/.bash_profile

if [ -f ~/.bashrc ]; then

        .~/.bashrc

fi

第五步:.bashrc 执行/etc/bashrc

cat ~/.bashrc

if [ -f /etc/bashrc ]; then

        ./etc/bashrc

fi

 

7、non login shell scriptssu username)

第一步:执行~/.bashrc

第二步:.bashrc 执行/etc/bashrc

第三步:执行 /etc/profile.d/下所有shell: /etc/profile.d/*.sh

cat /etc/bashrc

if ! shopt -q login_shell ; then # we're not a loginshell

        # need toredefine pathmunge, it get's undefined at the end of /etc/profile

    pathmunge ) {

                if! echo $path | /bin/egrep -q "^|:)$1$|:)" ; then

                        if [ "$2" ="after" ] ; then

                                path=$path:$1

                       else

                                path=$1:$path

                       fi

                fi

        }

 

        # onlydisplay echos from profile.d scripts if we are no login shell

    # andinteractive – otherwise just process them to set envvars

    for i in/etc/profile.d/*.sh; do

        if [ -r"$i" ]; then

            if ["$ps1" ]; then

                .$i

            else

                . $i >/dev/null 2>&1

            fi

        fi

    done

 

        unset i

        unsetpathmunge

fi

 

8、switching accounts

su : non login shell scripts方式切换到root用户

su – : login shell scripts方式切换到root用户

su oracle  : nonlogin shell scripts方式切换到oracle用户

su – oracle : login shell scripts方式切换到oracle用户

su username -c command : 以指定user身份执行一次指定的命令

su oracle -c ‘echo $home’: 以oracle用户身份执行echo $home命令

 

9、sudo其它用户可以执行root才能执行的命令)

修改/etc/sudoers文件

vi /etc/sudoers : 只能以readonly方式打开文件

visudo /etc/sudoers : 才可以执行write操作

  #user aliasspecification

  user_aliaswww=www1,www2  : 新增用户别名为wwwadmin. 并指定用户www1和www2. 命

名是包含大写字母、下划线以及数字,但必须以一个大写字母开头

 

  #cmnd aliasspecification

  cmnd_aliaschttp=/etc/init.d/httpd :新增命令别名www执行/etc/init.d/httpd命令.

必须是文件或目录的绝对路径

 

  #user privilegespecification

  root all=all)all

  wwwall=chttp  : www在任何地点all)都可以执行命令chttp

:wq

 

su – www1

sudo /etc/init.d/httpd restart

password:输入www1的密码

重启httpd服务

 

su – user1

sudo /etc/init.d/httpd restart

password:输入user1的密码

error : user1 is not in the sudoers file. this incidentwill be reported.

并向root发一封mail

 

exit回到root)

mail 查看mail)

& 1 : 查看第一封mail,可看到sudo的详细错误

 

 

 

 

 

 

 

以上就是小编对于rhce学习笔记问题和相关问题的解答了,rhce学习笔记的问题希望对你有用!

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文链接:https://www.andon8.com/419961.html

网站地图