Linux操作系统典型问题

前两天去装机,在Linux操作系统上安装,在公司怎么联系都没有问题,一到现场就状况百出,还是基本功不扎实啊,特将相关的典型问题列举一下,共享给感兴趣的读者,其实都是些非常基本的问题。


欢迎访问《Linux知识学习- ArcSDE安装必备》:http://blog.csdn.net/linghe301/article/details/6149867


1:关于切换用户的错误

问题一:

正常切换用户

[root@ags ~]# su - arcsde
[arcsde@ags ~]$
但是我碰到的问题,切换用户提示“-bash: /home/arcsde: is a directory”
[root@ags ~]# su - arcsde
-bash: /home/arcsde: is a directory
[arcsde@ags ~]$
最后费了好大的劲,发现环境变量多了个~

Linux操作系统典型问题_第1张图片

从上面截图可以看到,我们的环境变量,默认有好多~符号,但是都是虚的,就比如蓝色的~,但是如果不小心自己输入了~,其实跟虚的没有什么区别,这个不容易查看到,就会出现我上面碰到错误。


问题二:

切换用户还会碰到这种情况

[root@ags ~]# su - arcsde
-bash-3.2$
这种情况,就是你的用户下的环境变量等文件丢失。我们可以查看root用户下的信息,将相关的环境变量复制过去,然后在配置好该用户自己的环境变量即可
[root@ags ~]# su - arcsde
-bash-3.2$
-bash-3.2$ su -
口令:
[root@ags ~]# ls -al
总计 292
drwxr-x--- 18 root root  4096 03-21 09:24 .
drwxr-xr-x 24 root root  4096 03-20 09:40 ..
-rw-------  1 root root  1267 2011-04-11 anaconda-ks.cfg
drwxrwxr-x  3 root root  4096 03-20 10:12 .arcgis10.0
-rw-rw-r--  1 root root  1189 03-20 10:14 ArcGIS_MWSysReq.log
-rw-rw-r--  1 root root  6522 03-20 10:28 ArcGISServer_InstallLog.log
-rw-------  1 root root   170 2011-04-13 .bash_history-----------------------------------注意
-rw-r--r--  1 root root    24 2006-07-13 .bash_logout-------------------------------------注意
-rw-r--r--  1 root root   191 2006-07-13 .bash_profile------------------------------------注意
-rw-r--r--  1 root root   176 2006-07-13 .bashrc-------------------------------------------注意
drwx------  2 root root  4096 2011-04-11 .chewing
-rw-r--r--  1 root root   100 2006-07-13 .cshrc
drwxr-xr-x  2 root root  4096 2011-04-11 Desktop
-rw-------  1 root root    26 2011-04-11 .dmrc
drwxr-x---  2 root root  4096 2011-04-11 .eggcups
-rw-------  1 root root    16 2011-04-11 .esd_auth
drwx------  4 root root  4096 03-20 09:42 .gconf
drwx------  2 root root  4096 03-21 09:44 .gconfd
drwxr-xr-x  3 root root  4096 2011-04-11 .gnome
drwx------  7 root root  4096 03-21 08:53 .gnome2
drwx------  2 root root  4096 2011-04-11 .gnome2_private
drwxr-xr-x  2 root root  4096 2011-04-11 .gstreamer-0.10
-rw-r--r--  1 root root    81 2011-04-11 .gtkrc-1.2-gnome2
-rw-------  1 root root   378 03-20 09:42 .ICEauthority
-rw-r--r--  1 root root 27540 2011-04-11 install.log
-rw-r--r--  1 root root  3671 2011-04-11 install.log.syslog
drwx------  3 root root  4096 2011-04-11 .metacity
drwx------  4 root root  4096 2011-04-13 .mozilla
drwxr-xr-x  3 root root  4096 2011-04-12 .nautilus
-rw-r--r--  1 root root  1433 03-20 10:06 .recently-used.xbel
drwxr-xr-x  3 root root  4096 2011-04-11 .redhat
drwx------  4 root root  4096 2011-04-11 .scim
-rw-r--r--  1 root root   129 2006-07-13 .tcshrc
drwx------  2 root root  4096 2011-04-11 .Trash
-rw-------  1 root root    66 2011-04-18 .xauth1TiR6Y
-rw-r--r--  1 root root  3570 03-21 09:43 .xsession-errors

[root@ags ~]# cp .bash_profile /home/arcsde
[root@ags ~]# cp .bashrc /home/arcsde
cp:是否覆盖“/home/arcsde/.bashrc”? yes
[root@ags ~]# su - arcsde
[arcsde@ags ~]$
我上面只缺少.bash_profile文件,直接复制过去即可解决。


2:怎么在RH环境下安装依赖包

首先我们将光驱的RH安装光盘Mount到一个路径

基本语法:mount   光驱路径    自己设定路径

[root@localhost ~]# mount /dev/cdrom /home/soft
mount: block device /dev/cdrom is write-protected, mounting read-only
mount: /dev/cdrom already mounted or /home/soft busy
mount: according to mtab, /dev/hdc is already mounted on /home/soft
[root@localhost ~]# cd /home/soft
[root@localhost soft]# ls
Cluster            README-te.html            RELEASE-NOTES-U5-en
ClusterStorage     README-zh_CN.html         RELEASE-NOTES-U5-en.html
EULA               README-zh_TW.html         RELEASE-NOTES-U5-es.html
eula.en_US         RELEASE-NOTES-as.html     RELEASE-NOTES-U5-fr.html
GPL                RELEASE-NOTES-bn.html     RELEASE-NOTES-U5-gu.html
images             RELEASE-NOTES-de.html     RELEASE-NOTES-U5-hi.html
isolinux           RELEASE-NOTES-en          RELEASE-NOTES-U5-it.html
README-as.html     RELEASE-NOTES-en.html     RELEASE-NOTES-U5-ja.html
README-bn.html     RELEASE-NOTES-es.html     RELEASE-NOTES-U5-kn.html
README-de.html     RELEASE-NOTES-fr.html     RELEASE-NOTES-U5-ko.html
README-en          RELEASE-NOTES-gu.html     RELEASE-NOTES-U5-ml.html
README-en.html     RELEASE-NOTES-hi.html     RELEASE-NOTES-U5-mr.html
README-es.html     RELEASE-NOTES-it.html     RELEASE-NOTES-U5-or.html
README-fr.html     RELEASE-NOTES-ja.html     RELEASE-NOTES-U5-pa.html
README-gu.html     RELEASE-NOTES-kn.html     RELEASE-NOTES-U5-pt_BR.html
README-hi.html     RELEASE-NOTES-ko.html     RELEASE-NOTES-U5-ru.html
README-it.html     RELEASE-NOTES-ml.html     RELEASE-NOTES-U5-si.html
README-ja.html     RELEASE-NOTES-mr.html     RELEASE-NOTES-U5-ta.html
README-kn.html     RELEASE-NOTES-or.html     RELEASE-NOTES-U5-te.html
README-ko.html     RELEASE-NOTES-pa.html     RELEASE-NOTES-U5-zh_CN.html
README-ml.html     RELEASE-NOTES-pt_BR.html  RELEASE-NOTES-U5-zh_TW.html
README-mr.html     RELEASE-NOTES-ru.html     RELEASE-NOTES-zh_CN.html
README-or.html     RELEASE-NOTES-si.html     RELEASE-NOTES-zh_TW.html
README-pa.html     RELEASE-NOTES-ta.html     RPM-GPG-KEY-redhat-beta
README-pt_BR.html  RELEASE-NOTES-te.html     RPM-GPG-KEY-redhat-release
README-ru.html     RELEASE-NOTES-U5-as.html  Server
README-si.html     RELEASE-NOTES-U5-bn.html  TRANS.TBL
README-ta.html     RELEASE-NOTES-U5-de.html  VT
配置YUM
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi rhel-debuginfo.repo
将修改[Server]项,如果没有添加即可
[Server] 
name=Red Hat Enterprise Linux $releasever - $basearch - Debug 
baseurl=file:///home/soft/Server ---------------注意:/home/soft是你mount的路径,相关的包都在Server文件夹里面
enabled=1 
gpgcheck=0
gpgkey=file:///home/soft/RPM-GPG-KEY-redhat-release
我们测试一下是否配置成功
[root@localhost ~]# yum install openmotif
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openmotif.i386 0:2.3.1-2.el5_4.1 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package           Arch         Version                    Repository      Size
================================================================================
Installing:
 openmotif         i386         2.3.1-2.el5_4.1            Server         1.5 M

Transaction Summary
================================================================================
Install       1 Package(s)
Upgrade       0 Package(s)

Total download size: 1.5 M
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : openmotif                                                1/1

Installed:
  openmotif.i386 0:2.3.1-2.el5_4.1

Complete!

这说明安装成功了。但是我在安装现场,不知道为什么,YUM老是没有安装成功!我们可以使用另外一种方式RPM方式
[root@localhost ~]# cd /home/soft/Server/
[root@localhost Server]# ls -l openmotif*
-r--r--r-- 455 root root 1377121 2007-01-18 openmotif22-2.2.3-18.i386.rpm
-r--r--r-- 187 root root 1392893 2007-01-18 openmotif22-2.2.3-18.x86_64.rpm
-r--r--r-- 179 root root 1591633 2010-03-03 openmotif-2.3.1-2.el5_4.1.i386.rpm
-r--r--r--  81 root root 1600928 2010-03-03 openmotif-2.3.1-2.el5_4.1.x86_64.rpm
-r--r--r-- 179 root root 3076726 2010-03-03 openmotif-devel-2.3.1-2.el5_4.1.i386.rpm
-r--r--r--  81 root root 3204880 2010-03-03 openmotif-devel-2.3.1-2.el5_4.1.x86_64.rpm

[root@localhost Server]# rpm -ivh libX11-1.0.3-11.el5.i386.rpm
warning: libX11-1.0.3-11.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                ########################################### [100%]
        package libX11-1.0.3-11.el5.i386 is already installed
安装时候特别注意你安装的位数,光盘上32Bit和64Bit的都有,如果YUM没有安装上,使用这种方式也是可以的

如果不需要mount那个文件,使用umount命令取消

[root@localhost ~]# umount /home/soft
[root@localhost ~]# cd /home/soft
[root@localhost soft]# ls
applypatch  gsrvr        jdk-6u20-linux-i586.bin  sde931-sp2-ora10g-lx64.tar  sdeimport  sderaster
giomgr      jdk1.6.0_20  linux64.ora10g           sdeexport                   sdelayer   sdexinfo
我们看到,该路径下已经没有RH操作系统光盘的信息了

如果安装时候出现如下现象

[root@localhost Server]#rpm -ivh  openmotif22-2.2.3-18.x86_64.rpm
提示 warning  openmotif22-2.2.3-18.x86_64.rpm Header V2 DSA signature:NOKEY ,key ID 37017186  
Error :Failed dependencies: libXp.so.6()(64Bit ) is needed by openmotif 22-2.2.3-18.x86_64
说明你需要安装的这个openmotif22-2.2.3-18.x86_64.rpm需要依赖libXp.so.6(),所以你需要首先安装libXp.so.6(),然后再安装openmotif22-2.2.3-18.x86_64.rpm

3:编辑Linux文件的问题:/bin/sh^M:bad interpreter:没有哪个文件或目录

因为要安装ArcGIS Server,我使用的静默安装,我将两个文件通过SSH导出到Windows上,然后修改完毕后,在导入Linux,然后执行报如下问题

-bash: ./InstallServerSilently.sh:  /bin/sh^M:bad interpreter:没有哪个文件或目录
这是因为,在Linux上的文件,导出到Windows编辑,有些看不到的字符或者换行符什么的,Linux并不解析这些信息,所以,如果这种情况,建议在Linux的文件编辑器进行相关编辑,避免不必要的麻烦。如果想在Windows编辑后再导入,可以查看一下相关帮助。

4:指定用户的默认目录

使用usermod为创建的用户指定相关的目录

[root@localhost ~]# useradd mytest
[root@localhost ~]# su - mytest
[mytest@localhost ~]$ pwd
/home/mytest
[root@localhost home]# mkdir test
[root@localhost home]# cd
[root@localhost ~]# usermod -d  /home/test mytest
[root@localhost ~]# su - mytest
-bash-3.2$ pwd
/home/test
[ags@localhost ~]$ su -
口令:
[root@localhost ~]# cp .bash_profile /home/test
[root@localhost ~]# cp .bashrc /home/test
[root@localhost ~]# su - mytest
[mytest@localhost ~]$ pwd
/home/test
5:查看Linux版本
[root@localhost ~]# uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i                                      686 i686 i386 GNU/Linux
[root@localhost ~]# lsb_release -a
LSB Version:    :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-no                                      arch
Distributor ID: RedHatEnterpriseServer
Description:    Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release:        5.5
Codename:       Tikanga
[root@localhost ~]# cat /proc/version
Linux version 2.6.18-194.el5 ([email protected]) (gcc versi                                      on 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010

6:设置Linux的IP

一般我们查看Linux的IP,是咋Root用户下

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:AF:01:C7  
          inet addr:192.168.200.201  Bcast:192.168.200.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feaf:1c7/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:165288 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1812 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:19567799 (18.6 MiB)  TX bytes:240279 (234.6 KiB)
          Interrupt:67 Base address:0x2024 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2855 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2855 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4247810 (4.0 MiB)  TX bytes:4247810 (4.0 MiB)
但是我们如果需要修改IP,一般是在两个地方,一个是HOSTS文件
[root@localhost ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1              ags ags.localdomain 
#::1            localhost6.localdomain6 localhost6

192.168.200.201 ags ags.localdomain
另外一个是这个ifcfg-etho文件
[root@localhost ~]# more /etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static-----------------------------重要
ONBOOT=YES
HWADDR=00:0c:29:af:01:c7
IPADDR=192.168.200.201----------------------重要
NETMASK=255.255.255.0
GATEWAY=192.168.200.254

7:修改Linux主机名

修改/etc/sysconfig/network   修改这个文件,系统才有效
    /etc/hosts       hostname命令读这个配置文件

[root@RedHat ~]# more /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               RedHat(主机名) localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6
[root@RedHat ~]# more /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=RedHat(主机名)
GATEWAY=192.168.100.254

8:关闭Linux的防火墙和SELINUX服务

关于启动和关闭防火墙的命令:
        1) 重启后生效
        开启: chkconfig iptables on
        关闭: chkconfig iptables off
        2) 即时生效,重启后失效
        开启: service iptables start
        关闭: service iptables stop

关闭SELINUX服务需要修改相关文件/etc/selinux

[root@rhtest sysconfig]# vi config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=enforcing---------------------------------------------------------这个
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

将SELINUX=disabled即可

9:Linux 6.1安装图形界面

1:配置YUM包
2:安装软件包

yum install xorg*
yum groupinstall "X Window System"
yum groupinstall Desktop
yum groupinstall "Desktop Platform"
3:修改启动模式为5
vi /etc/inittab
    文件内容改为 id:5:initdefault:
4:重启 reboot

10:Linux启动SSH服务

判断SSH是否可用

[root@redhat6 ~]# ssh
usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-e escape_char] [-F configfile]
           [-i identity_file] [-L [bind_address:]port:host:hostport]
           [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
           [-R [bind_address:]port:host:hostport] [-S ctl_path]
           [-w local_tun[:remote_tun]] [user@]hostname [command]

开启或者关闭SSH服务

[root@redhat6 init.d]# service sshd status
openssh-daemon (pid  1476) is running...
[root@redhat6 init.d]# service sshd stop
Stopping sshd:                                             [  OK  ]
[root@redhat6 init.d]# service sshd start
Starting sshd:                                             [  OK  ]
[root@redhat6 init.d]# pwd
/etc/init.d

11:Linux查看端口

[root@localhost ~]# netstat -anp | grep 5433
tcp        0      0 0.0.0.0:5433                0.0.0.0:*                   LISTEN      4764/postgres
tcp        0      0 :::5433                     :::*                        LISTEN      4764/postgres
unix  2      [ ACC ]     STREAM     LISTENING     16915  4764/postgres       /tmp/.s.PGSQL.5433

12:Linux查看服务

[root@localhost ~]# chkconfig --list postgresql-9.0
postgresql-9.0  0:off   1:off   2:on    3:on    4:on    5:on    6:off

13:Linux操作系统切换语言

[root@rhsde ~]# more /etc/sysconfig/i18n
LANG="en_US.UTF-8"
将相关的LANG="zh_CN.UTF-8"

14:Linux挂载ISO文件

[root@RHEL6 ~]# mount -o loop -t iso9660 /opt/\[ºìñÆóÒµLinux.6.1\].rhel-server-6.1-x86_64-dvd.iso   /home/soft
[root@RHEL6 ~]# cd /home/soft
[root@RHEL6 soft]# ls
EFI                       RELEASE-NOTES-es-ES.html  RELEASE-NOTES-si-LK.html
EULA                      RELEASE-NOTES-fr-FR.html  RELEASE-NOTES-ta-IN.html
GPL                       RELEASE-NOTES-gu-IN.html  RELEASE-NOTES-te-IN.html
HighAvailability          RELEASE-NOTES-hi-IN.html  RELEASE-NOTES-zh-CN.html
images                    RELEASE-NOTES-it-IT.html  RELEASE-NOTES-zh-TW.html
isolinux                  RELEASE-NOTES-ja-JP.html  repodata
LoadBalancer              RELEASE-NOTES-kn-IN.html  ResilientStorage
media.repo                RELEASE-NOTES-ko-KR.html  RPM-GPG-KEY-redhat-beta
Packages                  RELEASE-NOTES-ml-IN.html  RPM-GPG-KEY-redhat-release
README                    RELEASE-NOTES-mr-IN.html  ScalableFileSystem
RELEASE-NOTES-as-IN.html  RELEASE-NOTES-or-IN.html  Server
RELEASE-NOTES-bn-IN.html  RELEASE-NOTES-pa-IN.html  TRANS.TBL
RELEASE-NOTES-de-DE.html  RELEASE-NOTES-pt-BR.html
RELEASE-NOTES-en-US.html  RELEASE-NOTES-ru-RU.html


15:Linux6配置YUM

其实跟Linux5类似,只是Linux5配置的文件,在Linux6已经没有了

[root@RHEL6 ~]# vi /etc/yum.repos.d/rhel-source.repo
直接修改以上文件,然后添加如下内容(具体路径依照自己环境)
[Packages]
name=Red Hat Enterprise Linux $releasever Beta - $basearch - Source
baseurl=file:///home/soft/Server
enabled=1
gpgcheck=0
gpgkey=file:///home/soft/RPM-GPG-KEY-redhat-release



-------------------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
Blog:               http://blog.csdn.net/linghe301
Weibo:            http://www.weibo.com/linghe301

-------------------------------------------------------------------------------------------------------


你可能感兴趣的:(Linux操作系统典型问题)