admin管理员组

文章数量:1652420

一、YUM安装时报错:E: Unable to lock the administration directory

    执行命令时发现未安装unzip,于是执行安装zip,又发现yum未安装,在执行安装yum时报错误: E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it  详细报错内容如下:

E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable);E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

root@ubuntu:/# yum install -y unzip zip
The program 'yum' is currently not installed. You can install it by typing:
apt-get install yum
root@ubuntu:/# apt-get install yum
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

截图如下:

      出现这个问题的管理的目录无法被锁住,因为其它的进程正在使用(标志就是生成了以下两个文件),执行命令把它们删除。然后就可以安装了。

sudo rm /var/cache/apt/archives/lock 
sudo rm /var/lib/dpkg/lock

publish:September 4, 2015 -Friday 

二、linux-ubuntu查看修改主机名称的命令

查看当前主机名称可以通过 uname -n命令或者/bin/hostname命令查看,例如:

root@ubuntu:~# uname -n
kermitubuntu
root@ubuntu:~# /bin/hostname
kermitubuntu
root@ubuntu:~#

如果要修改当前的主机名称使用 /bin/hostname 新主机名称 即可。如下执行:

root@ubuntu:~# /bin/hostname helloworld
root@ubuntu:~# uname -n
helloworld
root@ubuntu:~#

和WINDOWS一样,LINUX也可以配置hosts来简单使用本机的静态查询: 使用命令:vi /etc/hosts

127.0.0.1       localhost
127.0.1.1       ubuntu

可对下面的IP地址解析指定进行设定。

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

三、 执行shell提示:unable to execute ./my.sh: No such file or directory

    刚编写的一个shell文件执行时突然遇到shell文件不能运行,一下子觉得奇了怪了,明明写的shell文件,而且添加了可执行权限,竟然提示这个结果:如下

[testuser@ISER-2812 opt]$ sudo ./my.sh 
sudo: unable to execute ./my.sh: No such file or directory

     尝试对文件的用vim打开该sh文件,输入:set ff ,显示fileformat=unix,说明没有问题(如果显示fileformat=dos,则有问题,使用命令:set ff=unix 重新设置下文件格式再保存退出)。但是经过几次尝试还是提示这样的现象,最后我打开shell文件,把文件的前几行都删除,特别是首句指定命令解释器的那行代码。将它们都删除再在vi命令中编写保存。这时再执行成功了。

    于是想起问题了,我的shell文件是我从windows中的记事本中复制然后在linux的VI中粘贴的,而windows记事本中保存的格式是ANSI,此时粘贴到linux里时文件的头部可能是垃圾字符导致linux下的shell不能识别sh文件。我没有去尝试,如果将记事本保存成utf8格式的话进行复制粘贴应该就不会碰到这样的问题。

本文标签: 命令错误名称主机directory