分享
分销 收藏 举报 申诉 / 36
播放页_导航下方通栏广告

类型Linux常用配置方法及重要命令.doc

  • 上传人:仙人****88
  • 文档编号:7172033
  • 上传时间:2024-12-27
  • 格式:DOC
  • 页数:36
  • 大小:309KB
  • 下载积分:10 金币
  • 播放页_非在线预览资源立即下载上方广告
    配套讲稿:

    如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

    特殊限制:

    部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

    关 键  词:
    Linux 常用 配置 方法 重要 命令
    资源描述:
    一、 Fedora系统配置 1. 【设置网卡IP】 步骤如下: 1) 用root用户登陆,打开/etc/sysconfig/network-scripts/ifcfg-eth0文件 注意:打开的文件要根据网卡来设置,如:网卡eth1的配置文件就是ifcfg-eth1。 2) 设置以下内容: DEVICE=eth0 BOOTPROTO=static IPADDR=10.128.32.36 NETMASK=255.0.0.0 ONBOOT=yes GATEWAY=10.128.32.102 说明:网卡GATEWAY不一定要设置在这个网卡配置文件中,也可以配置到/etc/sysconfig/network文件中,如下所示: NETWORKING=yes NETWORKING_IPV6=yes HOSTNAME=localhost.localdomain GATEWAY=10.128.32.102 3) 重启network服务 [root@localhost:/etc/sysconfig]# service network restart Shutting down interface eth0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: [ OK ] 2. 【启动telnet服务】 telnet服务是由xinetd(扩展的网络守护进程服务程序)守护的,所以很多配置都是在xinetd下进行。具体步骤如下: 1) 检测telnet、telnet-server的rpm包是否安装 [root@localhost:/etc/sysconfig]# rpm -qa | grep telnet telnet-0.17-37 telnet-server-0.17-37 主要看telnet-server有没有安装,如果没有要先把telnet-server安装起来(具体安装方法略)。 2) 修改telnet服务配置文件 Fedora默认是不开通telnet服务的,所以需要手动配置开启: [root@localhost:/etc/sysconfig]# vi /etc/xinetd.d/telnet service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/sbin/in.telnetd log_on_failure += USERID disable = yes } 将disable项屏蔽或者改为no: disable = no 3) 修改Fedora下另一个telnet配置文件 对于Red-Hat系统,修改到telnet文件就可以了,但是Fedora对权限的管理比Red-Hat严格,还需要修改同一个目录下的krb5-telnet,不然客户端会鉴权不通过而无法连接。 [root@localhost:/etc/xinetd.d]# ls *telnet* ekrb5-telnet krb5-telnet telnet [root@localhost:/etc/xinetd.d]# vi krb5-telnet service telnet { flags = REUSE socket_type = stream wait = no user = root server = /usr/kerberos/sbin/telnetd log_on_failure += USERID disable = no } 将disable项屏蔽或者改为no: disable = no 注意:在权限和鉴权方面,Fedora和Red-Hat一样,都要让防火墙允许telnet连接。一般,可以直接关闭防火墙,否则就必须用setup工具配置一下。 4) 重新启动xinetd守护进程 [root@localhost:/etc/xinetd.d]# service xinetd restart Stopping xinetd: [ OK ] Starting xinetd: [ OK ] 3. 【启动FTP服务】 FTP守护进程是vsftpd,开启步骤如下: 1) 检测ftp、lftp的rpm包是否安装 [root@localhost:/etc/xinetd.d]# rpm -qa | grep ftp gftp-2.0.18-3.2.2 lftp-3.5.1-2.fc6 vsftpd-2.0.5-8 tftp-server-0.42-3.1 ftp-0.17-33.fc6 tftp-0.42-3.1 2) 配置开启ftp服务 运行setup,在system service中选中vsftpd按空格选中,然后quit。 3) 关闭SeLinux的安全设置 和Red-Hat不同,Fedora存在一个SELinux的安全机制管理,需要撤销SELinux对ftp的安全设置,FTP才能正常登陆,不然会报“500 OOPS: cannot change directory”的错误。执行下面的语句即可: [root@localhost:/etc/xinetd.d]# setsebool ftpd_disable_trans 1 注意:一旦重启该命令就会失效,所以最好的办法是在X界面下,点击菜单“System”à“Administration”à“Security Level and Firewall”,将选项SELinux设置为“Disable”,然后重启系统,就可以保持这个设置了。 4)重启FTP服务 [root@localhost:/etc/xinetd.d]# service vsftpd restart Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ] 4. 【设置开机自动执行】 设置方法如下: 1)用root用户登陆 2)vi /etc/rc.local 3)添加要开机执行的语句,如果是一个脚本文件,注意要绝对路径 #!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here if you don't # want to do the full Sys V style init stuff. touch /var/lock/subsys/local setsebool ftpd_disable_trans 1 service vsftpd restart 5. 【设置自动关机】 自动关机可以在crontab中设置。假设希望每天23::50关机,设置方法如下: 1)用root登陆 2)vi /etc/crontab 3)在文件最后添加以下语句: 50 23 * * * root shutdown -h now 6. 【设置允许root登陆telnet】 设置方法如下: 1)用root登陆 2)vi /etc/pam.d/login 3)注释该文件第一行内容:   #%PAM-1.0     #auth               required           /lib/security/pam_securetty.so     auth               required           /lib/security/pam_stack.so   service=system-auth     auth               required           /lib/security/pam_nologin.so     account         required           /lib/security/pam_stack.so   service=system-auth     password       required           /lib/security/pam_stack.so   service=system-auth     session         required           /lib/security/pam_stack.so   service=system-auth     session         optional           /lib/security/pam_console.so   7. 【设置允许root登陆ftp】 普通方式下,如果/etc/vsftpd/vsftpd.conf文件中有如下内容: userlist_enable=YES userlist_file=/etc/vsftpd.user_list pam_service_name=vsftpd 只需在/etc/vsftpd/user_list和/etc/vsftpd/ftpuser文件中删除root即可做到root用户ftp登陆。 具体方法如下: 1)用root登陆 2)vi /etc/vsftpd/user_list,注释root: # vsftpd userlist # If userlist_deny=NO, only allow users in this file # If userlist_deny=YES (default), never allow users in this file, and # do not even prompt for a password. # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers # for users that are denied. #root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody 3)vi /etc/vsftpd/ftpusers,注释root: # Users that are not allowed to login via ftp #root bin daemon adm lp sync shutdown halt mail news uucp operator games nobody 8. 【设置提示符】 Bash下具体设置方法如下: 1)用户登陆 2)vi .profile或者vi .bashrc 3)添加如下语句(该设置的效果是“[用户名@主机名:路径名]#”): export PS1="[\u@\h:\w]# " (注意,如果对所有用户设定,以上语句追加到/etc/profile。) 4)重新登陆,登陆显示为: [chyy@localhost:~/Documents/ftp资料]# 顺便提一下,在CSH或TCSH下,应该修改.cshrc或.tcshrc文件,修改语句是: set prompt="[`whoami`@`hostname`:`pwd`]# " 9. 【设置默认语言】 设置方法如下: 1)用root用户登陆 2)vi /etc/sysconfig/i18n 该文件内容是: LANG="zh_CN.UTF-8" SYSFONT="latarcyrheb-sun16" SUPPORTED="zh_CN.UTF-8:zh_CN:zh" 3)修改为: LANG="en_US.UTF-8" SUPPORTED="en_US.UTF-8:en_US:en" SYSFONT="latarcyrheb-sun16" 10. 【设置默认启动系统】 设置方法如下: 1)用root用户登陆 2)cp /boot/grub/menu.lst /boot/grub/menu.lst.bak 3)vi /boot/grub/menu.lst 4)从0开始数title,那个title下的操作系统是默认,就将default设置为该title对应的序数 示例,以下内容中,如果default为0,代表默认从Fedora启动;为1,代表从Windows启动: #boot=/dev/hda default=0 timeout=5 splashimage=(hd0,6)/boot/grub/splash.xpm.gz hiddenmenu title Fedora Core (2.6.18-1.2798.fc6xen)         root (hd0,6)         kernel /boot/xen.gz-2.6.18-1.2798.fc6         module /boot/vmlinuz-2.6.18-1.2798.fc6xen ro root=LABEL=/1 rhgb quiet         module /boot/initrd-2.6.18-1.2798.fc6xen.img title Dos         rootnoverify (hd0,0)         chainloader +1 11. 【设置Telnet下的Vim颜色】 设置方法如下: 1)用户登陆 2)cp /usr/share/vim/vim70/vimrc_example.vim .vimrc 3)vi .vimrc,添加如下蓝色语句(最好手动敲入,^[的输入方式是Ctrl-v然后输入Esc) if &t_Co > 2 || has("gui_running") syntax on set hlsearch endif " added by chyy if !has("gui_running") syntax on set t_Co=8 set t_Sf=^[[3%p1%dm set t_Sb=^[[4%p1%dm colorscheme desert endif 4)在SecureCRT的模拟终端类型选择ANSI,并钩上ANSI Color 5)如果需要更换颜色设置,更改colorscheme一句即可,例如: colorscheme default 小窍门:如果不清楚有哪些颜色选项的话,可以用vi打开一个.c文件,键入”: colorscheme“,键入空格,然后敲TAB按钮,vi会自动切换各种颜色选项的名称。 6)注意,某些vimrc_example.vim文件中有个bug: " In an xterm the mouse should work quite well, thus enable it. set mouse=a 在非xterm环境(如Telnet)下,该句会导致vi无法正常运行,建议修改如下: " In an xterm the mouse should work quite well, thus enable it. if has("gui_running") set mouse=a endif 12. 【启动samba服务】 设置方法如下: 1)启动smb服务 service smb start 2)开启suseLinux权限 setsebool -P samba_enable_home_dirs on 注意:如果想开机自动启动smb服务,将上述两句命令加入/etc/rc.d/rc.local即可。 二、 Linux常用系统命令 1. 【crontab定时任务设置】 Crontab文件放在/etc/下,其内容一般是: [root@localhost:/etc]# cat crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root HOME=/ # run-parts 01 * * * * root run-parts /etc/cron.hourly 02 4 * * * root run-parts /etc/cron.daily 22 4 * * 0 root run-parts /etc/cron.weekly 42 4 1 * * root run-parts /etc/cron.monthly 格式说明如下: 第一道第五个字段的整数取值范围及意义是: 0~59 表示分 1~23 表示小时 1~31 表示日 1~12 表示月份 0~6 表示星期(其中0表示星期日) 2. 【shutdown关机】 用man查询命令: [root@localhost:/etc]# man shutdown SHUTDOWN(8) Linux System Administrator鈥檚 Manual SHUTDOWN(8) NAME shutdown - bring the system down SYNOPSIS /sbin/shutdown [-t sec] [-arkhncfFHP] time [warning-message] DESCRIPTION shutdown brings the system down in a secure way. All logged-in users are notified that the system is going down, and login(1) is blocked. It is possible to shut the system down immediately or after a specified delay. All processes are first notified that the system is going down by the signal SIGTERM. This gives programs like vi(1) the time to save the file being edited, mail and news pro-cessing programs a chance to exit cleanly, etc. shutdown does its job by signalling the init pro- cess, asking it to change the runlevel. Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to put to system into a state where administrative tasks can be performed; this is the default if neither the -h or -r flag is given to shutdown. To see which actions are taken on halt or reboot see the appropriate entries for these runlevels in the file /etc/inittab. OPTIONS -a Use /etc/shutdown.allow. -t sec Tell init(8) to wait sec seconds between sending processes the warning and the kill signal, before changing to another runlevel. -k Don鈥檛 really shutdown; only send the warning messages to everybody. -r Reboot after shutdown. -h Halt or poweroff after shutdown. -H Halt action is to halt or drop into boot monitor on systems that support it. -P Halt action is to turn off the power. -n [DEPRECATED] Don鈥檛 call init(8) to do the shutdown but do it ourself. The use of this option is discouraged, and its results are not always what you鈥檇 expect. -f Skip fsck on reboot. -F Force fsck on reboot. -c Cancel an already running shutdown. With this option it is of course not possible to give the time argument, but you can enter a explanatory message on the command line that will be sent to all users. time When to shutdown. warning-message Message to send to all users. The time argument can have different formats. First, it can be an absolute time in the format hh:mm, in which hh is the hour (1 or 2 digits) and mm is the minute of the hour (in two digits). Second, it can be in the format +m, in which m is the number of minutes to wait. The word now is an alias for +0. 命令示例: shutdown -h now 立即关机 shutdown -h 50 50分钟后关机 shutdown –t 54000 15小时后自动关机 3. 【rpm软件安装卸载工具】 1) 查询rpm软件包: rpm -qa | grep xxx 2) 安装rpm软件包: rpm -ivh xxx.rpm 3) 卸载rpm软件包: rpm -e xxx 4) 修复rpm库(执行以前先备份/var/lib/rpm目录): rpm --rebuilddb 4. 【mount挂载磁盘】 1)挂载u盘: mount -t vfat /dev/sda1 /mnt/u 2)挂载Windows磁盘: mount -t vfat /dev/hda1 /mnt/c -o iocharset=cp936, codepage=936 3)挂载iso系统: mount /mnt/e/linux/fc6.iso /root/iso/ -o loop 4)挂载光盘: mount /dev/cdrom -t iso9660 /media/cdrom 4)挂载远程Windows共享目录: mount -t cifs -o username=administrator,password=123456 192.168.1.20:Download /mnt/share 其中administrator和123456分别是用户名和密码,192.168.1.20是Win IP,Download是共享目录,/mnt/share是挂载目录(必须首先创建好) 5. 【date查询和设置系统时间】 用man查询命令: NAME date - print or set the system date and time SYNOPSIS date [OPTION]... [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] DESCRIPTION Display the current time in the given FORMAT, or set the system date. -d, --date=STRING display time described by STRING, not 鈥榥ow鈥? -f, --file=DATEFILE like --date once for each line of DATEFILE -s, --set=STRING set time described by STRING -u, --utc, --universal print or set Coordinated Universal Time 示例一,查询系统时间: [chenyaya:~]# date Mon Feb 1 11:52:33 CST 2010 示例二,设置系统时间: [chenyaya:~]# date -s 12:31:00 Mon Feb 1 12:31:00 CST 2010 示例二,设置系统时间: [chenyaya:~]# date -u 0201123110 Mon Feb 1 12:31:00 UTC 2010 [chenyaya:~]# date Mon Feb 1 20:31:00 CST 2010 6. 【groupadd增加用户组】 语法结构是: groupadd [-g gid] group  说明:  g 制定组的ID号  gid 组的ID号(不能与现有的组ID号重复)  group 组名  示例: #groupadd –g 100 sun 7. 【netstat查询网络端口】 语法结构是: [root@localhost ~]# netstat --help usage: netstat [-veenNcCF] [<Af>] -r netstat {-V|--version|-h|--help} netstat [-vnNcaeol] [<Socket> ...] netstat { [-veenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s } [delay] -r, --route display routing table -I, --interfaces=<Iface> display interface table for <Iface> -i, --interfaces display interface table -g, --groups display multicast group memberships -s, --statistics display networking statistics (like SNMP) -M, --masquerade display masqueraded connections -v, --verbose be verbose -n, --numeric don't resolve names --numeric-hosts don't resolve host names --numeric-ports don't resolve port names --numeric-users don't resolve user names -N, --symbolic resolve hardware names -e, --extend display other/more information -p, --programs display PID/Program name for sockets -c, --continuous continuous listing -l, --listening display listening server sockets -a, --all, --listening display all sockets (default: connected) -o, --timers display timers -F, --fib display Forwarding Information Base (default) -C, --cache display routing cache instead of FIB -T, --notrim stop trimming long addresses -Z, --context display SELinux security context for sockets <Iface>: Name of interface to monitor/list. <Socket>={-t|--tcp} {-u|--udp} {-S|--sctp} {-w|--raw} {-x|--unix} --ax25 --ipx --netrom <AF>=Use '-A <af>' or '--<af>'; default: inet List of possible address families (which support routing): inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) ipx (Novell IPX) ddp (Appletalk DDP) x25 (CCITT X.25) 示例:查询所有端口和相应的程序,不解析主机名 [root@localhost ~]# netstat -anp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 822/rpcbind tcp 0 0 0.0.0.0:56912 0.0.0.0:* LISTEN 835/rpc.statd tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1405/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 902/cupsd tcp 0 0 127.0.0.1:25
    展开阅读全文
    提示  咨信网温馨提示:
    1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
    2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
    3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
    4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
    5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
    6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

    开通VIP折扣优惠下载文档

    自信AI创作助手
    关于本文
    本文标题:Linux常用配置方法及重要命令.doc
    链接地址:https://www.zixin.com.cn/doc/7172033.html
    页脚通栏广告

    Copyright ©2010-2025   All Rights Reserved  宁波自信网络信息技术有限公司 版权所有   |  客服电话:0574-28810668    微信客服:咨信网客服    投诉电话:18658249818   

    违法和不良信息举报邮箱:help@zixin.com.cn    文档合作和网站合作邮箱:fuwu@zixin.com.cn    意见反馈和侵权处理邮箱:1219186828@qq.com   | 证照中心

    12321jubao.png12321网络举报中心 电话:010-12321  jubao.png中国互联网举报中心 电话:12377   gongan.png浙公网安备33021202000488号  icp.png浙ICP备2021020529号-1 浙B2-20240490   


    关注我们 :微信公众号  抖音  微博  LOFTER               

    自信网络  |  ZixinNetwork