Google
 
Back to index
包管理器 Synaptic
安装、删除和卸载 Deb 包文件
通过软件包管理器进行 deb 包安装
从命令终端进行安装
查看系统的 CPU 和内存条型号
如何查询软件安装在什么目录
系统的环境变量
Environment Variables
修改环境变量的值
杂项
开机自动启动某应用程序
字体设置
修改用户名密码
在 Ubuntu 下开户 ssh 服务
通过 SSH 服务连接 VirtualBox 里 Linux

本文介绍 Ubuntu/Debian 系 Linux 系统的基本管理技巧。

包管理器 Synaptic

使用 Ubuntu/Debian 最先应该配好的是 Synaptic,即软件升级中心。

所有的源都在文件

/etc/apt/sources.list
里定义了。

当然,也有 GUI 界面的包管理中心:

安装、删除和卸载 Deb 包文件

Ubuntu/Debian 通过用 Deb 包的方式,能够方便地进行软件安装与更新。除了可以联网安装 deb 包外,我们还可以把 deb 包下载到本地再进行安装。

通过软件包管理器进行 deb 包安装

1. 菜单 -> 系统 -> 系统管理 -> 新立得软件包管理器 或 Alt+F2(运行窗口)输入

sudo synaptic

2. 点击 [来源] 在左侧的选择框中选择 [本地/main] 再在右侧的选择框中查找需要卸载的deb包

如果知道deb包名,直接点击 [搜索]输入包名

3.选择要删的包,右击,选择[标记以便删除]

4.选择完后,单击[应用]

从命令终端进行安装

如果是用命令的话,要移除的软件包名

sudo apt-get autoremove

要安装的软件包名

sudo apt-get install

要安装下载到本地的 .deb 套件包时

sudo dpkg -i package_file.deb

要反安装 .deb 套件包时

sudo dpkg -r package_name

查看系统的 CPU 和内存条型号

用下面的命令即可查看系统现在的 CPU 和内存条型号:

cat /proc/meminfo
cat /proc/cpuinfo

如何查询软件安装在什么目录

一般的deb包(包括新立得或者 apt-get 下载的)都装在 /usr/bin 目录下。自己下载的压缩包或者编译的包,有些可以选择安装目录,默认一般放在 /usr/local/ 里,也有在 /opt 里的。

如果想知道具体位置,用命令

dpkg -L xxx.deb

注意, xxx 是 deb 包的名称,也可以用新立得来查看。

系统的环境变量

Environment Variables

Environment variables in the bash shell help you in several ways. Certain built-in variables change the shell in ways that make your life a little easier, and you can define other variables to suit your own purposes. Here are some examples of built-in s hell variables:

To list the current values of all environment variables, issue the command

$ env

or list a specific variable with the echo command, prefixing the variable n ame with a dollar sign (the second line shows the result of the echo command):

echo $HOME
/home/water

修改环境变量的值

A variable assignment like this will work just fine, but its scope (visibility) is limited to the current shell. If you launch a program or enter another shell, that child task will not know about your environment variables unless you export them first.

Unless you know for sure that an environment variable will have meaning only in the current shell, it's a good idea to always use export when creating variables to ensure they will be global in scope—for example,

export PS1="\u \$ "
export code=$HOME/projects/src/spew

And be sure to add these commands to your .profile file so you won't have to retype them eac h time you log in.

如果需要在已有的环境变量后面追加路径值,比如说我要在 GTAGSLIBPATH 变量后面添加一个 /usr/include,现在能怎么呢?

$ export GTAGSLIBPATH=$GTAGSLIBPATH:/usr/include

这样就可以在原来的值后面追加多一个路径。

杂项

开机自动启动某应用程序

如果需要开机自动启动某应用程序,例如 skype 等,是 gnome 桌面可以在“系统 ==> 首选项 ==> 启动应用程序“里进行设置。

字体设置

官方文档:https://wiki.ubuntu.com/Fonts

个人总结:http://blog.waterlin.org/articles/install-new-fonts-under-ubuntu.html

修改用户名密码

用命令

$ passwd username

即可以修改用户密码。

在 Ubuntu 下开户 ssh 服务

1. 首先需要在 Ubuntu 下安装 ssh 这个服务,用新立得安装即可;

2. 对SSH服务器进行配置

#vi /etc/ssh/sshd_config

打开服务器端SSH的22端口,让SSH服务器端监听所有的网卡ListenAddress 0.0.0.0.即把这行前的注释删掉。

这些应该都是默认开启的,你只需要检查一下就好了。

3. 开启SSH服务

# /usr/sbin/sshd

如果你不知道 sshd 安装在哪里了,你可以用whereis这个命令去查找一下。

通过 SSH 服务连接 VirtualBox 里 Linux

大部分的项目管理工作都是在 Windows 下完成的,可是经常又需要上 Linux 服务器检查一下有关项目代码的情况,甚至于自己亲手试一把。

这个时候,很有必要装一个 VirtualBox 虚拟机,然后在里面装一个 Ubuntu,在里面进行调试即可。

这样操作起来,有点卡,我们可以开启虚拟机里的 ssh 服务,然后在从 Windows 桌面上远程连接过去,即可顺利地完全相关的任务。

要实现这样一个工作环境,对 VirtualBox 里的 Ubuntu 需要进行一些设置。

默认情况下,VirtualBox 里的 Guest 机器的网络连接被设置为NAT(Network Address Translation),我们可以修改为 Bridged 网络连接方式;设成 Bridger 模式,这样 VirtualBox 里的 Ubuntu 就有自己的 IP了,可以开启服务了。

然后按上面讲的开启 Ubuntu ssh 服务的方法,即可从 Windows 远程连接。