xfce4 thunar添加搜索选项

 

ref:https://www.reddit.com/r/xfce/comments/94qwuo/when_is_thunar_finally_getting_a_search_file/

You can create a shortcut in Thunar’s right click menu via the “Edit” -> “Configure custom actions…” menu.

  • Name: Search files...

  • Command: catfish --path=%f

  • File pattern: *

  • Appears if selection contains: Directories

vmware modules不能在新内核更新解决方法

ref:https://communities.vmware.com/t5/VMware-Workstation-Pro/VMware-16-2-3-not-working-on-Ubuntu-22-04-LTS/td-p/2905535

cd /usr/lib/vmware/modules/source
git clone https://github.com/mkubecek/vmware-host-modules
cd vmware-host-modules
git checkout workstation-16.2.4
make
tar -cf vmnet.tar vmnet-only
tar -cf vmmon.tar vmmon-only
mv vmnet.tar /usr/lib/vmware/modules/source/
mv vmmon.tar /usr/lib/vmware/modules/source/
vmware-modconfig --console --install-all

ubuntu 查看usb设备

查看 USB 设备 使用的是哪个串口

ls -l /dev/ttyUSB*

查看 USB 设备 是不是存储设备
Linux下查看usb设备信息,常常使用lsusb命令

$lsusb

Bus 002 Device 125: ID 0781:5567 SanDisk Corp. Cruzer Blade
$lsusb -t

Port 1: Dev 125, If 0, Class=Mass Storage, Driver=usb-storage, 480M

Class=Mass Storage,说明我的设备是大容量存储设备。

我优盘的ID 是 0781:5567,如果我要查它的详细信息(包括它是否是存储设备),可以用命令:

$sudo lsusb -d 0781:5567 -v

过滤信息,用下面的命令:

$sudo lsusb -d 0781:5567 -v |grep -i storage

得到结果

bInterfaceClass 8 Mass Storage

Mass Storage,说明该设备是存储设备。

 

Extend the life of your SSD drive with fstrim

原文:https://opensource.com/article/20/2/trim-solid-state-storage-linux

 

Over the past decade, solid-state drives (SSD) have brought about a new way of managing storage. SSDs have benefits like silent and cooler operation and a faster interface spec, compared to their elder spinning ancestors. Of course, new technology brings with it new methods of maintenance and management. SSDs have a feature called TRIM. This is essentially a method for reclaiming unused blocks on the device, which may have been previously written, but no longer contain valid data and therefore, can be returned to the general storage pool for reuse. Opensource.com’s Don Watkins first wrote about TRIM in his 2017 article “Solid-state drives in Linux: Enabling TRIM for SSDs.”

 

If you have been using this feature on your Linux system, then you are probably familiar with the two methods described below.

The old ways

Discard

I initially enabled this with the discard option to the mount command. The configuration is placed into the /etc/fstab file for each file system.

# cat /etc/fstab
UUID=3453g54-6628-2346-8123435f  /home  xfs  defaults,discard   0 0

The discard option enables automatic online TRIM. There has recently been debate on whether this is the best method due to possible negative performance impacts. Using this option causes a TRIM to be initiated every time new data is written to the drive. This may introduce additional activity that interferes with storage performance.

Cron

I removed the discard option from the fstab file. Then I created a cron job to call the command on a scheduled basis.

# crontab -l
@midnight /usr/bin/trim

This is the method I used most recently on my Ubuntu Linux systems until I learned about another way.

A new TRIM service

I recently discovered that a systemd service for TRIM exists. Fedora introduced this into their distribution in version 30, and, although it is not enabled by default in versions 30 and 31, it is planned to be in version 32. If you’re working on Fedora Workstation 31 and you want to begin using this feature, you can enable it very easily. I’ll also show you how to test it below. This service is not unique to Fedora. The existence and status will depend on an individual distribution basis.

Test

I like to test first, to better understand what is happening behind the scenes. I do this by opening a terminal and issuing the command that the service is configured to call.

/usr/sbin/fstrim --fstab --verbose --quiet

The –help argument to fstrim will describe these and other arguments.

$ sudo /usr/sbin/fstrim --help

Usage:
 fstrim [options] <mount point>

Discard unused blocks on a mounted filesystem.

Options:
 -a, --all           trim all supported mounted filesystems
 -A, --fstab         trim all supported mounted filesystems from /etc/fstab
 -o, --offset <num>  the offset in bytes to start discarding from
 -l, --length <num>  the number of bytes to discard
 -m, --minimum <num> the minimum extent length to discard
 -v, --verbose       print number of discarded bytes
     --quiet         suppress error messages
 -n, --dry-run       does everything, but trim

 -h, --help          display this help
 -V, --version       display version

So, now I can see that the systemd service is configured to run the trim on all supported mounted filesystems in my /etc/fstab file –fstab and print the number of discarded bytes –verbose but suppress any error messages that might occur –quiet. Knowing these options is helpful for testing. For instance, I can start with the safest one, which is the dry run. I’ll also leave off the quiet argument so I can determine if any errors will occur with my drive setup.

$ sudo /usr/sbin/fstrim --fstab --verbose --dry-run

This will simply show what the fstrim command will do based on the file systems that it finds configured in your /etc/fstab file.

$ sudo /usr/sbin/fstrim --fstab --verbose

This will now send the TRIM operation to the drive and report on the number of discarded bytes from each file system. Below is an example after my recent fresh install of Fedora on a new NVME SSD.

/home: 291.5 GiB (313011310592 bytes) trimmed on /dev/mapper/wkst-home
/boot/efi: 579.2 MiB (607301632 bytes) trimmed on /dev/nvme0n1p1
/boot: 787.5 MiB (825778176 bytes) trimmed on /dev/nvme0n1p2
/: 60.7 GiB (65154805760 bytes) trimmed on /dev/mapper/wkst-root

Enable

Fedora Linux implements systemd timer service, scheduled to run on a weekly basis. To check the existence and current status, run systemctl status.

$ sudo systemctl status fstrim.timer

Now, enable the service.

$ sudo systemctl enable fstrim.timer

Verify

Then you can verify that the timer is enabled by listing all of the timers.

$ sudo systemctl list-timers --all

The following line referring to the fstrim.timer will appear. Notice that the timer actually activates fstrim.service. This is from where the actual fstrim is called. The time-related fields show n/a because the service has just been enabled and has not run yet.

NEXT   LEFT    LAST   PASSED   UNIT           ACTIVATES
n/a    n/a     n/a    n/a      fstrim.timer   fstrim.service

Conclusion

This service seems like the best way to run TRIM on your drives. It is much simpler than having to create your own crontab entry to call the fstrim command. It is also safer not having to edit the fstab file. It has been interesting to watch the evolution of solid-state storage technology and nice to know that it appears Linux is moving toward a standard and safe way to implement it.

grub定制

grub customizer

ppa

https://launchpad.net/~danielrichter2007/+archive/ubuntu/grub-customizer

grub显示菜单:

GRUB_TIMEOUT_STYLE设置为menu

 

局域网cups共享打印机

https://www.cups.org/doc/sharing.html

Printer Sharing

This document discusses several ways to configure printer sharing.

The Basics

A “server” is any machine that communicates directly to a printer. A “client” is any machine that sends print jobs to a server for final printing. Clients can also be servers if they communicate directly with any printers of their own.

By default, CUPS uses the Internet Printing Protocol (IPP) to send jobs from a client to a server. When printing to legacy print servers you may also use the Line Printer Daemon (LPD) protocol when printing to older UNIX-based servers or Server Message Block (SMB) when printing to Windows® servers.

Clients can automatically discover and access shared printers via DNS Service Discovery (DNS-SD a.k.a. Bonjour®). SMB browsing can also be used to manually discover and access shared printers when Samba is installed.

Configuring the Server

You must enable printer sharing on the server before clients can print through it. The simplest way to do this is to use the cupsctl(8) command on the server:

cupsctl --share-printers

By default, the above command will allow printing from other clients on the same subnet as your server. To allow printing from any subnet, use the following command instead:

cupsctl --share-printers --remote-any

How to force fsck to check filesystem after system reboot on Linux

原文:https://linuxconfig.org/how-to-force-fsck-to-check-filesystem-after-system-reboot-on-linux

This article will explain a procedure on how to force fsck to perform a filesystem check on the next system reboot or force filesystem check for any desired number of system reboots whether it is root or non-root mount point.

Let’s start with discussion about some tools which can be used to obtain filesystem information and configurations which control filesystem check after system reboot. The tool which we are going to discuss is tune2fs filesystem managing utility. Using tune2fs we can export some important information related to filesystem health check. The following linux command will tell as when was the last time the filesystem /dev/sdX was checked:

# tune2fs -l /dev/sdbX | grep Last\ c
Last checked:             Sun Dec 13 09:14:22 2015

Anther useful information which can be retrieved by tune2fs command relates to how many times our /dev/sdX filesystem was mounted:

# tune2fs -l /dev/sdbX | grep Mount
Mount count:              157

 

and lastly how many mounts are allowed to pass before filesystem check is forced:

# tune2fs -l /dev/sdbX | grep Max
Maximum mount count:      -1

From the above outputs we can establish the following information summary. The /dev/sdbX filesystem was last checked on Sun Dec 13 09:14:22 2015. Since the last check, this filesystem was mounted 157 times and maximum amount of mounts before next filesystem fsck check. In the above case the value -1 means that fsck is disabled.



Now, that we have learned about some tune2fs basics let’s discuss PASS system configuration option found in /etc/fstab file containing all on boot mountable partitions and their relevant mount options.

# blkid | grep sdb1
/dev/sdb1: UUID="c6e22f63-e63c-40ed-bf9b-bb4a10f2db66" TYPE="ext2"
# grep c6e22f63-e63c-40ed-bf9b-bb4a10f2db66 /etc/fstab
UUID=c6e22f63-e63c-40ed-bf9b-bb4a10f2db66 /mnt            ext2    errors=remount-ro 0      0

We have used blkid command to retrieve UUID for a given partition and then used the retrieved partition UUID to get a relevant information related to /dev/sdb1 partition from /etc/fstbab.
The last column that is a column 6, aka fsck PASS column is used by fsck to determine whether fsck should check filesystem before it is mounted and in which order given partitions in /etc/fstab should be checked. Possible entries for fstab PASS column are 0,1 and 2.

  1. 0 – disabled, that is do not check filesystem
  2. 1 – partition with this PASS value has a higher priority and is check first. This value is usually set to root / partition
  3. 2 – partitions with this PASS value will be checked last

The connection between fstab PASS value, last checked value and number of mounts value is as follows:
During the system boot the first value which is checked is fstab PASS value. If this value is 0 that not other values are checked ( exemption .. see “Force fsck for root partition” below ) and the fsck will NOT perform filesystem check. If the PASS value found in /etc/fstab is any other than 0, that is 1 or 2 then values of maximum mounts and total mounts are checked. If the value of maximum mounts is greater or equal to total number of mounts value then fsck’s filesytem check will be performed. Few examples:

FSCK DISABLED
fstab PASS: 1
Maximum mount count:      -1
Mount count:              157
----
FSCK DISABLED
fstab PASS: 0
Maximum mount count:      -1
Mount count:              157
----
FSCK ON NEXT REBOOT
fstab PASS: 1 or 2
Maximum mount count:      1
Mount count:              157
----
FSCK DISABLED
fstab PASS: 0
Maximum mount count:      1
Mount count:              1
----
FSCK ON NEXT REBOOT
fstab PASS: 1 or 2
Maximum mount count:      1
Mount count:              1
----
NO FSCK ON NEXT REBOOT
fstab PASS: 1 or 2
Maximum mount count:      200
Mount count:              157


Force fsck for root partition

The simplest way to force fsck filesystem check on a root partition eg. /dev/sda1 is to create an empty file called forcefsck in the partition’s root directory.

# touch /forcefsck

This empty file will temporarily override any other settings and force fsck to check the filesystem on the next system reboot. Once the filesystem is checked the forcefsck file will be removed thus next time you reboot your filesystem will NOT be checked again. To enable more permanent solution and force filesystem check on every reboot we need to manipulate filesystem’s “Maximum mount count” parameter. The following linux command will ensure that filesystem /dev/sdb1 is checked every time your Linux system reboots. Please note that for this to happen the fsck’s PASS value in /etc/fstab must be set to a positive integer as discussed above.

# tune2fs -c 1 /dev/sdb1

alternatively we can set fsck after every 10 reboots:

# tune2fs -c 10 /dev/sdb1

Force fsck for all other non-root partitions

As oppose to root partition creating empty forcefsck file will NOT trigger partition check on reboot. The only way to force fsck on all other non-root partitions is to manipulate filesystem’s “Maximum mount count” parameter and PASS value within /etc/fstab configuration file. To force filesystem check on non-root partition change fsck’s PASS value in /etc/fstab to value 2. For example:

UUID=c6e22f63-e63c-40ed-bf9b-bb4a10f2db66 /mnt            ext2    errors=remount-ro 0      2

and change maximum mounts filesystem parameter to a positive integer, depending on how many times you wish to allow a specified filesystem to be mounted without being checked. Force fsck on every reboot:

# tune2fs -c 1 /dev/sdb1

alternatively we can set fsck to check filesystem after every 5 reboots:

# tune2fs -c 5 /dev/sdb1

To disable fsck run:

# tune2fs -c 0 /dev/sdb1
OR
# tune2fs -c -1 /dev/sdb1

Which will set the filesystem’s “Maximum mount count” parameter to -1

.bashrc不起作用与bash初始化文件执行顺序

原文:https://finisky.github.io/2020/03/29/bashstartupfiles/

.bashrc不起作用

按习惯在HOME中添加了.bashrc文件,定义一些alias和PS1,结果发现putty登录之后并未生效,还须手动source .bashrc,在~/目录增加.bash_profile或.profile解决:

 ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

但问题的根源在于.bash_profile .bashrc .bash_login .profile几个文件的执行顺序。

.bash_profile .bashrc .bash_login .profile执行顺序

bash startup文件执行顺序

man是个好东西,man bash:

When bash is invoked as an interactive login shell, or as a non-interactive shell with the –login option, it first reads and executes commands from the file /etc/profile, if that file exists. After reading that file, it looks for ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and executes commands from the first one that exists and is readable. The –noprofile option may be used when the shell is started to inhibit this behavior.

可见这些文件的执行顺序如下:

  • /etc/profile
  • ~/.bash_profile
  • ~/.bash_login
  • ~/.profile

但同时需要注意前提条件是bash是interactive login shell,那什么是interactive shell,什么是login shell?

interactive shell和login shell

A login shell is one whose first character of argument zero is a -, or one started with the –login option.

An interactive shell is one started without non-option arguments (unless -s is specified) and without the -c option whose standard input and error are both connected to terminals (as determined by isatty(3)), or one started with the -i option. PS1 is set and $- includes i if bash is interactive, allowing a shell script or a startup file to test this state.

上面的定义虽然字字都能看懂,但按字面理解起来比较困难。通俗地来说,interactive shell就是需要人机交互的,比如执行一个脚本就不需要人机交互。login shell就是是否需要登录,比如本地再开一个terminal就不需要再次登录。

参考如下实例对二者排列组合: # Differentiate Interactive login and non-interactive non-login shell

  • interactive login shell: 远程登录,如ssh
  • interactive non-login shell: 本地起一个bash
  • non-interactive non-login shell: 运行脚本
  • non-interactive login shell: 少见

可以用如下命令测试当前环境是什么样的bash:

~$: echo $-; shopt login_shell
himBHs
login_shell     on

第一行中如果含有字母i则是iteractive shell;第二行显而易见。上述执行结果是ssh,可见ssh是iteractive login shell。

 

.bashrc又在什么时候被调用?

When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc, if these files exist.

好了,因为putty通过ssh登录,因此它是iteractive login shell,所以不会调用.bashrc,因此开头增加.bash_profile或.profile文件的目的就是调用.bashrc。

Tips: Linux中有许多不同版本的shell,如sh、csh、tcsh、zsh等。它们之间有一定的继承和渊源,有兴趣可以了解一下。只不过bash在当前的发行版中最为常见。

virtualbox 6.1安装windows xp

系统安装

1.安装系统;

2.重启->F8进入安全模式;

3.安装virtualbox guest additions驱动

4.正常启动至系统。

4k设置

在虚拟机参数设置中

displayer TAB

Scal Fact设置为200%

 

解决杂音问题

将音频输出改为alsa