15
2026
05

阿里云的xrdp.ini文件 alibabalinux gnome桌面 windows远程 可以xorg登陆

[Globals]

; xrdp.ini file version number

ini_version=1


; fork a new process for each incoming connection

fork=true


; ports to listen on, number alone means listen on all interfaces

; 0.0.0.0 or :: if ipv6 is configured

; space between multiple occurrences

; ALL specified interfaces must be UP when xrdp starts, otherwise xrdp will fail to start

;

; Examples:

;   port=3389

;   port=unix://./tmp/xrdp.socket

;   port=tcp://.:3389                           127.0.0.1:3389

;   port=tcp://:3389                            *:3389

;   port=tcp://<any ipv4 format addr>:3389      192.168.1.1:3389

;   port=tcp6://.:3389                          ::1:3389

;   port=tcp6://:3389                           *:3389

;   port=tcp6://{<any ipv6 format addr>}:3389   {FC00:0:0:0:0:0:0:1}:3389

;   port=vsock://<cid>:<port>

port=3389


; if used inside a Hyper-V VM through vmconnect and bound on vsock,

; turn this on to enable wider security protocol support.

#vmconnect=true


; Unprivileged User name and group to run the xrdp daemon.

; It is HIGHLY RECOMMENDED you set these values. See the xrdp.ini(5)

; manpage for more information on setting and checking these.

runtime_user=xrdp

runtime_group=xrdp


; regulate if the listening socket use socket option tcp_nodelay

; no buffering will be performed in the TCP stack

tcp_nodelay=true


; regulate if the listening socket use socket option keepalive

; if the network connection disappear without close messages the connection will be closed

tcp_keepalive=true


; set tcp send/recv buffer

; These parameters are largely historic. On systems with dynamic TCP

; buffer sizes, setting them manually will either impact performance or

; waste memory

#tcp_send_buffer_bytes=32768

#tcp_recv_buffer_bytes=32768


; security layer can be 'tls', 'rdp' or 'negotiate'

; for client compatible layer

security_layer=negotiate


; minimum security level allowed for client for classic RDP encryption

; use tls_ciphers to configure TLS encryption

; can be 'none', 'low', 'medium', 'high', 'fips'

crypt_level=high


; X.509 certificate and private key

; openssl req -x509 -newkey rsa:2048 -nodes -keyout key.pem -out cert.pem -days 365

certificate=

key_file=


; [Debug] Log file for TLS pre-master secrets - see xrdp.ini(5)

#tls_pms_log_file=/tmp/xrdp-pms/premaster.log


; set SSL protocols

; can be comma separated list of 'SSLv3', 'TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3'

ssl_protocols=TLSv1.2, TLSv1.3

; set TLS cipher suites

#tls_ciphers=HIGH


; concats the domain name to the user if set for authentication with the separator

; for example when the server is multi homed with SSSd

#domain_user_separator=@


; The following options will override the keyboard layout settings.

; These options are for DEBUG and are not recommended for regular use.

#xrdp.override_keyboard_type=0x04

#xrdp.override_keyboard_subtype=0x01

#xrdp.override_keylayout=0x00000409


; Section name to use for automatic login if the client sends username

; and password. If empty, the domain name sent by the client is used.

; If empty and no domain name is given, the first suitable section in

; this file will be used.

autorun=


allow_channels=true

allow_multimon=true

bitmap_cache=true

bitmap_compression=true

bulk_compression=true

#hidelogwindow=true

max_bpp=32

new_cursors=true

; fastpath - can be 'input', 'output', 'both', 'none'

use_fastpath=both

; when true, userid/password *must* be passed on cmd line. If the password

; is incorrect, the login will fail

#require_credentials=true

; when true, the userid will be used to try to authenticate

#enable_token_login=true

; You can set the PAM error text in a gateway setup (MAX 256 chars)

#pamerrortxt=change your password according to policy at http://url


;

; colors used by windows in RGB format

;

#black=000000

grey=e1e1e1

dark_grey=b4b4b4

blue=0078d7

dark_blue=0078d7

#white=ffffff

#red=ff0000

#green=00ff00

#background=626c72


;

; Select a default fv1 font

;

; This parameter is a comma-separated list of DPI:name pairs.

; The list is scanned from left-to-right. The font used is the first

; font whose DPI value is less-than-or-equal to the vertical DPI of

; the monitor used for the login screen.

#fv1_select=130:sans-18.fv1,0:sans-10.fv1

; Default DPI used for a monitor when that information is unknown

#default_dpi=96


;

; configure login screen

;


; Login Screen Window Title

#ls_title=My Login Title


; top level window background color in RGB format

ls_top_window_bg_color=003057


; width and height of login screen

;

; When the sans-10.fv1 font is selected, these values are in pixels.

; For other fonts, these values (and other size values) will be scaled

; appropriately to preserve the proportions of the login screen.

;

; The default height allows for about 5 fields to be comfortably displayed

; above the buttons at the bottom. To display more fields, make <ls_height>

; larger, and also increase <ls_btn_ok_y_pos> and <ls_btn_cancel_y_pos>

; below

;

ls_width=350

ls_height=360


; login screen background color in RGB format

ls_bg_color=f0f0f0


; optional background image filename. BMP format is always supported,

; but other formats will be supported if xrdp is build with imlib2

; The transform can be one of the following:-

;     none  : No transformation. Image is placed in bottom-right corner

;             of the screen.

;     scale : Image is scaled to the screen size. The image aspect

;             ratio is not preserved.

;     zoom  : Image is scaled to the screen size. The image aspect

;             ratio is preserved by clipping the image.

#ls_background_image=

#ls_background_transform=none


; logo

; full path to file or file in shared folder. BMP format is always supported,

; but other formats will be supported if xrdp is build with imlib2

; For transform values, see 'ls_background_transform'. The logo width and

; logo height are ignored for a transform of 'none'.

ls_logo_filename=

ls_logo_transform=scale

ls_logo_width=250

ls_logo_height=110

ls_logo_x_pos=55

ls_logo_y_pos=35


; for positioning labels such as username, password etc

ls_label_x_pos=30

ls_label_width=68


; for positioning text and combo boxes next to above labels

ls_input_x_pos=110

ls_input_width=210


; y pos for first label and combo box

ls_input_y_pos=158


; OK button

ls_btn_ok_x_pos=142

ls_btn_ok_y_pos=308

ls_btn_ok_width=85

ls_btn_ok_height=30


; Cancel button

ls_btn_cancel_x_pos=237

ls_btn_cancel_y_pos=308

ls_btn_cancel_width=85

ls_btn_cancel_height=30


[Logging]

; Note: Log levels can be any of: core, error, warning, info, debug, or trace

LogFile=xrdp.log

LogLevel=INFO

EnableSyslog=true

#SyslogLevel=INFO

#EnableConsole=false

#ConsoleLevel=INFO

#EnableProcessId=false


[LoggingPerLogger]

; Note: per logger configuration is only used if xrdp is built with

; --enable-devel-logging

#xrdp.c=INFO

#main()=INFO


[Channels]

; Channel names not listed here will be blocked by XRDP.

; You can block any channel by setting its value to false.

; IMPORTANT! All channels are not supported in all use

; cases even if you set all values to true.

; You can override these settings on each session type

; These settings are only used if allow_channels=true

rdpdr=true

rdpsnd=true

drdynvc=true

cliprdr=true

rail=true

xrdpvr=true


; for debugging xrdp, in section xrdp1, change port=-1 to this:

#port=/tmp/.xrdp/xrdp_display_10



;

; Session types

;


; Some session types such as Xorg and Xvnc start a display server.

; Startup command-line parameters for the display server are configured

; in sesman.ini. See and configure also sesman.ini.

[Xorg]

name=Xorg

lib=libxup.so

username=ask

password=ask

port=-1

code=20

; Frame capture interval (milliseconds)

h264_frame_interval=16

rfx_frame_interval=32

normal_frame_interval=40


[Xvnc]

name=Xvnc

lib=libvnc.so

username=ask

password=ask

#ip=127.0.0.1

; port is -1 (sesman controlled), numeric (TCP connection) or an

; absolute path (UDS connection).

port=-1

; For sesman-controlled Xvnc, the 'code' parameter can be used to switch

; the connection protocol:-

; 0 - Use a TCP connection

; 1 - Use a Unix Domain Sockets (UDS) connection

;     UDS connections are not supported by older VNC servers, but are

;     supported by TigerVNC. If you select this option, comment out

;     (or remove) the 'ip=' setting.

;

; UDS connections are recommended, if your X server supports them. They are

; more secure, and untroubled by firewalls.

;

; On FIPS-based systems, TCP CANNOT be used, as the classic algorithm used for

; VNC password files is no longer considered secure by FIPS

;

; The default value is 0 on non-FIPS systems, and 1 on FIPS-based systems.

code=1

#xserverbpp=24

#delay_ms=2000

; Disable requested encodings to support buggy VNC servers

; (1 = ExtendedDesktopSize)

#disabled_encodings_mask=0


; Generic VNC Proxy

; Tailor this to specific hosts and VNC instances by specifying an ip

; and port and setting a suitable name.

#[vnc-any]

#name=vnc-any

#lib=libvnc.so

#ip=ask

#port=ask5900

#username=na

#password=ask

#pamusername=asksame

#pampassword=asksame

#delay_ms=2000

; Use one of these to connect to a chansrv instance created outside of sesman

; (e.g. as part of an x11vnc console session). Replace 'n' with the

; display number of the session, and (if applicable) 'u' with the numeric

; UID of the session.

;

; If 'username' or 'pamusername' is set, you probably don't need to use

; the two parameter variant with 'u'.

#chansrvport=DISPLAY(n)

#chansrvport=DISPLAY(n,u)


; Generic RDP proxy using NeutrinoRDP

; Tailor this to specific hosts by specifying an ip and port and setting

; a suitable name.

#[neutrinordp-any]

#name=neutrinordp-any

; To use this section, you should build xrdp with configure option

; --enable-neutrinordp.

#lib=libxrdpneutrinordp.so

#ip=ask

#port=ask3389

#username=ask

#password=ask

; Uncomment the following lines to enable PAM authentication for proxy

; connections.

#pamusername=ask

#pampassword=ask

; Currently NeutrinoRDP doesn't support dynamic resizing. Uncomment

; this line if you're using a client which does.

#enable_dynamic_resizing=false

; By default, performance settings requested by the RDP client are ignored

; and chosen by NeutrinoRDP. Uncomment this line to allow the user to

; select performance settings in the RDP client.

#perf.allow_client_experiencesettings=true

; Override any experience setting by uncommenting one or more of the

; following lines.

#perf.wallpaper=false

#perf.font_smoothing=false

#perf.desktop_composition=false

#perf.full_window_drag=false

#perf.menu_anims=false

#perf.themes=false

#perf.cursor_blink=false

; By default NeutrinoRDP supports cursor shadows. If this is giving

; you problems (e.g. cursor is a black rectangle) try disabling cursor

; shadows by uncommenting the following line.

#perf.cursor_shadow=false

; By default, NeutrinoRDP uses the keyboard layout of the remote RDP Server.

; If you want to tell the remote the keyboard layout of the RDP Client,

; by uncommenting the following line.

#neutrinordp.allow_client_keyboardLayout=true

; The following options will override the remote keyboard layout settings.

; These options are for DEBUG and are not recommended for regular use.

#neutrinordp.override_keyboardLayout_mask=0x0000FFFF

#neutrinordp.override_kbd_type=0x04

#neutrinordp.override_kbd_subtype=0x01

#neutrinordp.override_kbd_fn_keys=12

#neutrinordp.override_kbd_layout=0x00000409


; You can override the common channel settings for each session type

#channel.rdpdr=true

#channel.rdpsnd=true

#channel.drdynvc=true

#channel.cliprdr=true

#channel.rail=true

#channel.xrdpvr=true


[xrdp1]

name=sesman-X11

lib=libxup.so

username=ask

password=ask

ip=127.0.0.1

port=-1

code=20


[channels]

; for sound

audio=true

rdpsnd=true

尤其是最后xrdp1和channels的添加



15
2026
05

阿里云 alibabalinux 安装gnome桌面,然后xrdp,然后有xorg,然后安装音频

阿里云 ECS (Alibaba Cloud Linux + GNOME) RDP 远程声音配置指南

适用场景

云服务器:阿里云 ECS(或其他云服务器)

操作系统:Alibaba Cloud Linux / CentOS 8 / RHEL 8

桌面环境:GNOME

远程协议:RDP (xrdp)

问题:Windows 远程连接后听不到声音

________________________________________

核心原理

云服务器默认没有物理声卡,需要:

1.编译 PulseAudio 源码(生成头文件)

2.编译安装 pulseaudio-module-xrdp(RDP 音频重定向模块)

3.配置 xrdp 和 PulseAudio,让声音通过 RDP 传输到 Windows 客户端

________________________________________

完整操作步骤

第一步:安装基础开发工具和依赖

bash

复制

下载

sudo yum install -y epel-release

sudo yum install -y git gcc gcc-c++ make autoconf automake libtool \

    pulseaudio-libs-devel meson ninja-build \

    glib2-devel libcap-devel libsndfile-devel \

    speexdsp-devel alsa-lib-devel dbus-devel \

    libtdb-devel openssl-devel libudev-devel lirc-devel \

    check check-devel doxygen

第二步:下载并编译 PulseAudio 源码

bash

复制

下载

cd /tmp

wget https://freedesktop.org/software/pulseaudio/releases/pulseaudio-15.0.tar.xz

tar -xf pulseaudio-15.0.tar.xz

cd pulseaudio-15.0


# 配置构建(禁用文档以加快编译)

meson setup build -Ddocumentation=false


# 编译

ninja -C build

第三步:下载并编译 xrdp 音频模块

bash

复制

下载

cd /tmp

git clone --depth=1 https://github.com/neutrinolabs/pulseaudio-module-xrdp.git

cd pulseaudio-module-xrdp


# 生成配置

./bootstrap


# 指向 PulseAudio 源码目录

./configure PULSE_DIR=/tmp/pulseaudio-15.0 PULSE_CONFIG_DIR=/tmp/pulseaudio-15.0/build


# 编译安装

make

sudo make install

第四步:配置自动加载

bash

复制

下载

# 创建 PulseAudio 自动加载配置

mkdir -p ~/.config/pulse/default.pa.d/

cat > ~/.config/pulse/default.pa.d/xrdp.pa << 'EOF'

### Load xrdp module for RDP audio redirection

.ifexists module-xrdp-sink.so

load-module module-xrdp-sink

.endif

.ifexists module-xrdp-source.so

load-module module-xrdp-source

.endif

EOF


# 设置 xrdp-sink 为默认输出设备(登录时自动执行)

echo 'pactl set-default-sink xrdp-sink' >> ~/.profile

第五步:配置 xrdp 服务端

bash

复制

下载

# 编辑 /etc/xrdp/xrdp.ini,确保 [channels] 部分有:

# audio=true

# rdpsnd=true


sudo sed -i '/\[channels\]/,/^$/ s/^;*audio=true/audio=true/' /etc/xrdp/xrdp.ini

sudo sed -i '/\[channels\]/,/^$/ s/^;*rdpsnd=true/rdpsnd=true/' /etc/xrdp/xrdp.ini


# 重启 xrdp

sudo systemctl restart xrdp

第六步:Windows RDP 客户端设置

在 Windows 上打开远程桌面连接(mstsc):

显示选项 → 本地资源 → 远程音频 → 设置

远程音频播放 → 在此计算机上播放

点击确定

第七步:测试声音

重新 RDP 连接后,在服务器终端执行:

bash

复制

下载

# 检查设备

pactl list sinks short


# 播放测试音

paplay /usr/share/sounds/alsa/Front_Center.wav

或者在 GNOME 设置 → 声音 → 输出设备中选择 xrdp-sink,点击测试。

________________________________________

常见问题速查

问题解决方案

pactl list sinks 看不到 xrdp-sink执行 pactl load-module module-xrdp-sink

编译缺依赖根据报错用 yum search 找到对应 devel 包安装

PulseAudio 启动失败检查 XDG_RUNTIME_DIR 环境变量,应为 /run/user/1000

声音卡顿/延迟Windows RDP 客户端降低音频质量为"动态"

重启后声音消失确认 ~/.config/pulse/default.pa.d/xrdp.pa 存在

________________________________________

关键文件路径

文件/目录作用

/usr/lib64/pulse-15.0/modules/module-xrdp-sink.soxrdp 音频模块

~/.config/pulse/default.pa.d/xrdp.pa用户级 PulseAudio 自动加载配置

/etc/xrdp/xrdp.inixrdp 服务配置

/tmp/pulseaudio-15.0/PulseAudio 源码目录(编译用)

________________________________________

这套流程的核心是:让 PulseAudio 识别到 RDP 虚拟出来的音频通道。关键是编译 pulseaudio-module-xrdp 时需要正确的 PulseAudio 源码头文件路径。

以后如果换服务器或重装系统,按这个文档一步步来就行


07
2026
04

CentOS8 Stream安装chrome

先换源:


1. 备份原有配置(重要安全步骤)

# 创建备份目录并移动所有原有的 .repo 文件
sudo mkdir -p /etc/yum.repos.d/backupsudo mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/backup/

2. 创建并编辑新的源配置文件

使用文本编辑器(如 vim 或 nano)创建 /etc/yum.repos.d/CentOS-Stream.repo 文件:


sudo vim /etc/yum.repos.d/CentOS-Stream.repo

然后,将以下内容完整复制并粘贴到文件中:


[BaseOS]
name=CentOS-Stream-8 - Base
baseurl=https://mirrors.aliyun.com/centos/8-stream/BaseOS/x86_64/os/
pgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=CentOS-Stream-8 - AppStream
baseurl=https://mirrors.aliyun.com/centos/8-stream/AppStream/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[extras]
name=CentOS-Stream-8 - Extras
baseurl=https://mirrors.aliyun.com/centos/8-stream/extras/x86_64/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official

注意:baseurl 中的 /8-stream/ 路径是专门为 CentOS Stream 8 设计的


3. 清理并重建缓存

配置完成后,执行以下命令使新源生效

sudo dnf clean all
sudo dnf makecache

1. 添加 Google Chrome 软件源

创建一个新的仓库文件,让系统知道去哪里下载 Chrom

sudo tee /etc/yum.repos.d/google-chrome.repo <<EOF
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch 
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF


2. 导入 Google 的 GPG 签名密钥

这一步是必要的安全验证,确保下载的软件包来自 Google 且未被篡改

sudo rpm --import https://dl.google.com/linux/linux_signing_key.pub

3. 更新软件包缓存

让系统识别刚刚添加的 Chrome 仓库。

sudo dnf update

4. 安装 Chrome

最后,执行安装命令

sudo dnf install google-chrome-stable

安装过程中,系统可能会询问是否导入密钥或确认安装,输入 y 并按回车即可。


19
2026
03

ubuntu24.04修改密码长度低于8位规则

Ubuntu系统中,修改密码长度规则通常是依赖于PAM(Pluggable Authentication Modules)模块的配置。默认情况下,Ubuntu使用了pam_pwquality模块来管理密码策略,其中包括密码长度要求。

修改密码长度规则

要修改密码长度规则,你需要编辑/etc/security/pwquality.conf文件。你可以使用文本编辑器来修改这个文件,例如使用nanovim

  1. 打开终端。

  2. 使用以下命令编辑pwquality.conf文件:

    sudo nano /etc/security/pwquality.conf

    或者使用vim:

    sudo vim /etc/security/pwquality.conf
  3. 在文件中找到或添加以下行来设置密码最小长度:

    minlen = 6


  4. 前面的#去掉

  5. 这里6是你希望设置的密码最小长度。你可以根据需要调整这个数字。

  6. 保存并关闭文件。如果你使用的是nano,可以通过按Ctrl + O保存更改,然后按Ctrl + X退出;如果你使用的是vim,则可以通过输入:wq然后按Enter来保存并退出。

重启PAM服务

修改完配置文件后,为了使更改生效,你可能需要重启PAM服务或整个系统。通常,重启PAM服务就足够了。可以使用以下命令来重启PAM服务:

sudo systemctl restart pam-auth-update.service

或者简单地重启系统:

sudo reboot

验证更改

重启后,你可以通过创建一个新用户或更改现有用户的密码来验证密码长度规则是否生效:

sudo adduser newuser# 或者更改现有用户的密码:sudo passwd username

在设置密码时,系统会强制应用新的密码长度策略。

注意事项

  • 确保设置的密码长度符合组织的安全政策。过短的密码容易被猜测或破解。

  • 如果你在修改配置文件时遇到权限问题,确保你使用了sudo来编辑文件。

  • 在生产环境中,更改密码策略前最好先通知所有用户,并确保他们了解新的安全要求。这有助于避免混乱和可能的用户不满。

通过上述步骤,你应该能够成功修改Ubuntu系统中的密码长度规则。



28
2025
12

解决酷派大神F1声音小的办法

 修改音乐外放大小

1、在拨号界面输入*20121220#,拨号就会进入工程模式,在最后一项:MTK工程模式。
2、点击进入MTK工程模式,找到 Hardware Testing  然后再选择 Audio

3、在Audio 里面,我们选择 Normal Mode 进入

4、然后我们再选择  Type这个下面的下拉框里面的 Media, 再点击 Level,下面的音量等级数值, 直接选择 Level 6,我们把最大音量档调整到最大。

5、最大值是255和160数值。最主要是把下面一个数值改成 160,然后点击 Set, 这样多媒体音量已经解决声音小的问题了,修改后,明显感觉不一样了。有了这个就不需要安装其他第三方扩音器软件了。

下面再来修改铃声的大小。

1、再返回到第一级菜单。如图所示: 点击 LoudSpeaker Mode 进入。

2、同样把刚才的数值,调正到 最大 Level 6,改成 160和255(已经最大了),然后点击 Set,重启。

如有破音,重新把值调下来。所以调值之前最好记一记原始数据。我个人觉得,本来大神F1的音量已经很大了。


27
2025
12

ubuntu12.04安装java1.7

先去 Oracle下载Linux下的JDK压缩包,我下载的是jdk-7u4-linux-i586.tar.gz文件,下好后直接解压

Step1:
# 将解压好的jdk1.7.0_21文件夹用最高权限复制到/usr/lib/jvm目录里
sudo cp -r ~/jdk1.7.0_21/ /usr/lib/jvm/

Step2:
# 配置环境变量
sudo gedit ~/.profile
在末尾加上:
export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21

然后保存关闭,使用source更新下
$ source ~/.profile

使用env命令察看JAVA_HOME的值
$ env
如果JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21,说明配置成功。

Step3:
# 将系统默认的jdk修改过来
$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_21/bin/java 300

输入sun jdk前的数字就好了
$ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_21/bin/javac 300

$ sudo update-alternatives --config java
$ sudo update-alternatives --config javac

Step4:
然后再输入java -version,看到如下信息,就说明改成sun的jdk了:
java version "1.7.0_04"
Java(TM) SE Runtime Environment (build 1.7.0_04-b20)
Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)

 

可能会存在的问题:
1.提示缺失libjli.so无法启动……,碰到这个问题是你下载的JavaJDK压缩包不完整,或者你的解压方式不对导致,直接解压到当前路径,然后拷贝到你需要的目录,JDK的安装目录可以随便选择,比如你可以放在HOME目录下,
libjli.so文件在:~/jdk1.7.0_07/jre/lib/i386/jli/libjli.so

2.可能无法配置成功,需要卸载以前安装的OpenJDK,具体可以命令行移除

3.不同版本的JDK,版本号如上修改即可


27
2025
12

linux下压缩和解压缩命令

linux zip命令

zip -r myfile.zip ./*
将当前目录下的所有文件和文件夹全部压缩成myfile.zip文件,-r表示递归压缩子目录下所有文件.

2.unzip
unzip -o -d /home/sunny myfile.zip
把myfile.zip文件解压到 /home/sunny/
-o:不提示的情况下覆盖文件;
-d:-d /home/sunny 指明将文件解压缩到/home/sunny目录下;

3.其他
zip -d myfile.zip smart.txt
删除压缩文件中smart.txt文件
zip -m myfile.zip ./rpm_info.txt
向压缩文件中myfile.zip中添加rpm_info.txt文件
-------------------------------------------------------------------------------

要使用 zip 来压缩文件,在 shell 提示下键入下面的命令:

zip -r filename.zip filesdir
 

在这个例子里,filename.zip 代表你创建的文件,filesdir 代表你想放置新 zip 文件的目录。-r 选项指定你想递归地(recursively)包括所有包括在 filesdir 目录中的文件。

要抽取 zip 文件的内容,键入以下命令:

unzip filename.zip
 

你可以使用 zip 命令同时处理多个文件和目录,方法是将它们逐一列出,并用空格间隔:

zip -r filename.zip file1 file2 file3 /usr/work/school
 

上面的命令把 file1、file2、 file3、以及 /usr/work/school 目录的内容(假设这个目录存在)压缩起来,然后放入 filename.zip 文件中。

 

tar 命令详解

  -c: 建立压缩档案

  -x:解压

  -t:查看内容

  -r:向压缩归档文件末尾追加文件

  -u:更新原压缩包中的文件

  这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能用其中一个。下面的参数是根据需要在压缩或解压档案时可选的。

  -c: 建立压缩档案

  -x:解压

  -t:查看内容

  -r:向压缩归档文件末尾追加文件

  -u:更新原压缩包中的文件

  下面的参数-f是必须的

  -f: 使用档案名字,切记,这个参数是最后一个参数,后面只能接档案名。

  # tar -cf all.tar *.jpg

  这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。

  # tar -rf all.tar *.gif

  这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。

  # tar -uf all.tar logo.gif

  这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。

  # tar -tf all.tar

  这条命令是列出all.tar包中所有文件,-t是列出文件的意思

  # tar -xf all.tar

  这条命令是解出all.tar包中所有文件,-t是解开的意思

  压缩

  tar –cvf jpg.tar *.jpg //将目录里所有jpg文件打包成tar.jpg

  tar –czf jpg.tar.gz *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用gzip压缩,生成一个gzip压缩过的包,命名为jpg.tar.gz

  tar –cjf jpg.tar.bz2 *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用bzip2压缩,生成一个bzip2压缩过的包,命名为jpg.tar.bz2

  tar –cZf jpg.tar.Z *.jpg //将目录里所有jpg文件打包成jpg.tar后,并且将其用compress压缩,生成一个umcompress压缩过的包,命名为jpg.tar.Z

  rar a jpg.rar *.jpg //rar格式的压缩,需要先下载rar for linux

  zip jpg.zip *.jpg //zip格式的压缩,需要先下载zip for linux

  解压

  tar –xvf file.tar //解压 tar包

  tar -xzvf file.tar.gz //解压tar.gz

  tar -xjvf file.tar.bz2 //解压 tar.bz2

  tar –xZvf file.tar.Z //解压tar.Z

  unrar e file.rar //解压rar

  unzip file.zip //解压zip

  总结

  1、*.tar 用 tar –xvf 解压

  2、*.gz 用 gzip -d或者gunzip 解压

  3、*.tar.gz和*.tgz 用 tar –xzf 解压

  4、*.bz2 用 bzip2 -d或者用bunzip2 解压

  5、*.tar.bz2用tar –xjf 解压

  6、*.Z 用 uncompress 解压

  7、*.tar.Z 用tar –xZf 解压

  8、*.rar 用 unrar e解压

  9、*.zip 用 unzip 解压

  Linux中tar命令详解(转载的资料)

  tar命令

  tar 可以为文件和目录创建档案。利用tar,用户可以为某一特定文件创建档案(备份文件),也可以在档案中改变文件,或者向档案中加入新的文件。tar最初被 用来在磁带上创建档案,现在,用户可以在任何设备上创建档案,如软盘。利用tar命令,可以把一大堆的文件和目录全部打包成一个文件,这对于备份文件或将 几个文件组合成为一个文件以便于网络传输是非常有用的。Linux上的tar是GNU版本的。

  语法:tar [主选项+辅选项] 文件或者目录

  使用该命令时,主选项是必须要有的,它告诉tar要做什么事情,辅选项是辅助使用的,可以选用。

  主选项:

  c 创建新的档案文件。如果用户想备份一个目录或是一些文件,就要选择这个选项。

  r 把要存档的文件追加到档案文件的未尾。例如用户已经作好备份文件,又发现还有一个目录或是一些文件忘记备份了,这时可以使用该选项,将忘记的目录或文件追加到备份文件中。

  t 列出档案文件的内容,查看已经备份了哪些文件。

  u 更新文件。就是说,用新增的文件取代原备份文件,如果在备份文件中找不到要更新的文件,则把它追加到备份文件的最后。

  x 从档案文件中释放文件。

  辅助选项:

  b 该选项是为磁带机设定的。其后跟一数字,用来说明区块的大小,系统预设值为20(20*512 bytes)。

  f 使用档案文件或设备,这个选项通常是必选的。

  k 保存已经存在的文件。例如我们把某个文件还原,在还原的过程中,遇到相同的文件,不会进行覆盖。

  m 在还原文件时,把所有文件的修改时间设定为现在。

  M 创建多卷的档案文件,以便在几个磁盘中存放。

  v 详细报告tar处理的文件信息。如无此选项,tar不报告文件信息。

  w 每一步都要求确认。

  z 用gzip来压缩/解压缩文件,加上该选项后可以将档案文件进行压缩,但还原时也一定要使用该选项进行解压缩。

  Linux下的压缩文件剖析

  对于刚刚接触Linux的人来说,一定会给Linux下一大堆各式各样的文件名给搞晕。别个不说,单单就压缩文件为例,我们知道在 Windows下最常见 的压缩文件就只有两种,一是,zip,另一个是.rap。可是Linux就不同了,它有.gz、.tar.gz、tgz、bz2、.Z、.tar等众多的 压缩文件名,此外windows下的.zip和.rar也可以在Linux下使用,不过在Linux使用.zip和.rar的人就太少了。本文就来对这些 常见的压缩文件进行一番小结,希望你下次遇到这些文件时不至于被搞晕。

  在具体总结各类压缩文件之前呢,首先要弄清两个概念:打包和压缩。打包是指将一大堆文件或目录什么的变成一个总的文件,压缩则是将一个大的文件 通过一些压 缩算法变成一个小文件。为什么要区分这两个概念呢?其实这源于Linux中的很多压缩程序只能针对一个文件进行压缩,这样当你想要压缩一大堆文件时,你就 得先借助另它的工具将这一大堆文件先打成一个包,然后再就原来的压缩程序进行压缩。

  Linux下最常用的打包程序就是tar了,使用tar程序打出来的包我们常称为tar包,tar包文件的命令通常都是以.tar结尾的。生成tar包后,就可以用其它的程序来进行压缩了,所以首先就来讲讲tar命令的基本用法:

  tar命令的选项有很多(用man tar可以查看到),但常用的就那么几个选项,下面来举例说明一下:

  # tar -cf all.tar *.jpg

  这条命令是将所有.jpg的文件打成一个名为all.tar的包。-c是表示产生新的包,-f指定包的文件名。

  # tar -rf all.tar *.gif

  这条命令是将所有.gif的文件增加到all.tar的包里面去。-r是表示增加文件的意思。

  # tar -uf all.tar logo.gif

  这条命令是更新原来tar包all.tar中logo.gif文件,-u是表示更新文件的意思。

  # tar -tf all.tar

  这条命令是列出all.tar包中所有文件,-t是列出文件的意思

  # tar -xf all.tar

  这条命令是解出all.tar包中所有文件,-t是解开的意思

  以上就是tar的最基本的用法。为了方便用户在打包解包的同时可以压缩或解压文件,tar提供了一种特殊的功能。这就是tar可以在打包或解包的同时调用其它的压缩程序,比如调用gzip、bzip2等。

  1) tar调用gzip

  gzip是GNU组织开发的一个压缩程序,.gz结尾的文件就是gzip压缩的结果。与gzip相对的解压程序是gunzip。tar中使用-z这个参数来调用gzip。下面来举例说明一下:

  # tar -czf all.tar.gz *.jpg

  这条命令是将所有.jpg的文件打成一个tar包,并且将其用gzip压缩,生成一个gzip压缩过的包,包名为all.tar.gz

  # tar -xzf all.tar.gz

  这条命令是将上面产生的包解开。

  2) tar调用bzip2

  bzip2是一个压缩能力更强的压缩程序,.bz2结尾的文件就是bzip2压缩的结果。与bzip2相对的解压程序是bunzip2。tar中使用-j这个参数来调用gzip。下面来举例说明一下:

  # tar -cjf all.tar.bz2 *.jpg

  这条命令是将所有.jpg的文件打成一个tar包,并且将其用bzip2压缩,生成一个bzip2压缩过的包,包名为all.tar.bz2

  # tar -xjf all.tar.bz2

  这条命令是将上面产生的包解开。

  3)tar调用compress

  compress也是一个压缩程序,但是好象使用compress的人不如gzip和bzip2的人多。.Z结尾的文件就是bzip2压缩的结 果。与 compress相对的解压程序是uncompress。tar中使用-Z这个参数来调用gzip。下面来举例说明一下:

  # tar -cZf all.tar.Z *.jpg

  这条命令是将所有.jpg的文件打成一个tar包,并且将其用compress压缩,生成一个uncompress压缩过的包,包名为all.tar.Z

  # tar -xZf all.tar.Z

  这条命令是将上面产生的包解开

  有了上面的知识,你应该可以解开多种压缩文件了,下面对于tar系列的压缩文件作一个小结:

  1)对于.tar结尾的文件

  tar -xf all.tar

  2)对于.gz结尾的文件

  gzip -d all.gz

  gunzip all.gz

  3)对于.tgz或.tar.gz结尾的文件

  tar -xzf all.tar.gz

  tar -xzf all.tgz

  4)对于.bz2结尾的文件

  bzip2 -d all.bz2

  bunzip2 all.bz2

  5)对于tar.bz2结尾的文件

  tar -xjf all.tar.bz2

  6)对于.Z结尾的文件

  uncompress all.Z

  7)对于.tar.Z结尾的文件

  tar -xZf all.tar.z

  另外对于Window下的常见压缩文件.zip和.rar,Linux也有相应的方法来解压它们:

  1)对于.zip

  linux下提供了zip和unzip程序,zip是压缩程序,unzip是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法:

  # zip all.zip *.jpg

  这条命令是将所有.jpg的文件压缩成一个zip包

  # unzip all.zip

  这条命令是将all.zip中的所有文件解压出来

  2)对于.rar

  要在linux下处理.rar文件,需要安装RAR for Linux,可以从网上下载,但要记住,RAR for Linux

  不是免费的;然后安装:

  # tar -xzpvf rarlinux-3.2.0.tar.gz

  # cd rar

  # make

  这样就安装好了,安装后就有了rar和unrar这两个程序,rar是压缩程序,unrar是解压程序。它们的参数选项很多,这里只做简单介绍,依旧举例说明一下其用法:

  # rar a all *.jpg

  这条命令是将所有.jpg的文件压缩成一个rar包,名为all.rar,该程序会将.rar 扩展名将自动附加到包名后。

  # unrar e all.rar

  这条命令是将all.rar中的所有文件解压出来

  到此为至,我们已经介绍过linux下的tar、gzip、gunzip、bzip2、bunzip2、compress、 uncompress、 zip、unzip、rar、unrar等程式,你应该已经能够使用它们对.tar、.gz、.tar.gz、.tgz、.bz2、.tar.bz2、. Z、.tar.Z、.zip、.rar这10种压缩文件进行解压了,以后应该不需要为下载了一个软件而不知道如何在Linux下解开而烦恼了。而且以上方 法对于Unix也基本有效。

  本文介绍了linux下的压缩程式tar、gzip、gunzip、bzip2、bunzip2、 compress、uncompress、zip、unzip、rar、unrar等程式,以及如何使用它们对.tar、.gz、.tar.gz、. tgz、.bz2、.tar.bz2、.Z、.tar.Z、.zip、.rar这10种压缩文件进行操作


27
2025
12

ubuntu12.04下打开rar文件

rar 和 7zip 是两种源于 windows 的压缩格式, linux 对它们的支持并不像 tar 或者 gzip 那样理所当然,因此,当你在 ubuntu 下无法避开这两种压缩格式的文件时,你必须安装额外的工具软件来解开这些压缩文件。

安装 rar 解压缩文件:

    sudo apt-get install rar


解压缩 rar 文件:

    rar e myfile.rar


安装 7zip 解压缩工具:

sudo apt-get install p7zip


p7zip 包括 p7zip 和 7zr 两个可执行文件,事实上, p7zip 是 7zr 的 shell 封装。

解压缩 7zip 文件:

7zr x myfile.7z 或者 7zr e myfile.7z

27
2025
12

在linux下一次删除目录下的所有文件的方法

用户可以用rm命令删除不需要的文件。该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除。对于链 接文件,只是断开了链接,原文件保持不变。 rm命令的一般形式为: rm[选项] 文件 如果没有使用- r选项,                                                                                                                       用户可以用rm命令删除不需要的文件。该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所有文件及子目录均删除。对于链 接文件,只是断开了链接,原文件保持不变。

rm命令的一般形式为:

rm[选项] 文件…

如果没有使用- r选项,则rm不会删除目录。

该命令的各选项含义如下:

- f 忽略不存在的文件,从不给出提示。

- r 指示rm将参数中列出的全部目录和子目录均递归地删除,与-f组合:rm -rf 目录,一次性删除目录及子文件中所有内容。 recursion:递归,递归式
           - i 进行交互式删除。

rm -rf * 在当前目录下执行该命令,则删除当前目录下的所有文件和命令。


                   使用rm命令要小心。因为一旦文件被删除,它是不能被恢复的。了防止这种情况的发生,可以使用i选项来逐个确认要删除的文件。如果用户输入y,文件将被删除。如果输入任何其他东西,文件则不会删除。


27
2025
12

DELL D630 Ubuntu12.04安装无线网卡驱动

在光盘上:

cd /cdrom/pool/main/b/b43-fwcutter/

sudo dpkg –I b43-fwcutter*

 

tar xvjf broadcom-wl-5.10.56.27.3_mipsel.tar.bz2

sudo b43-fwcutter –w /lib/firmware broadcom-wl-5.10.56.27.3/dirver/wl_apsta/wl_prebuilt.o

两个文件下载地址:

b43-fwcutter文件夹下载地址:http://pan.baidu.com/s/1jG5b1VC

broadcom-wl-5.10.56.27.3_mipsel.tar.bz2下载地址:http://pan.baidu.com/s/1dDxejN7