Ubuntu: summary common used knowledge

Add some command into startup process

cpp 复制代码
sudo vim /etc/systemd/system/rc-local.service
[Unit]
 Description=/etc/rc.local Compatibility
 ConditionPathExists=/etc/rc.local
[Service]
 Type=forking
 ExecStart=/etc/rc.local start
 TimeoutSec=0
 StandardOutput=tty
 RemainAfterExit=yes
 SysVStartPriority=99
[Install]
 WantedBy=multi-user.target

sudo vim /etc/rc.local
#!/bin/bash
dhclient
service ssh restart
service smbd restart
mount /dev/sdb1 /mnt/disk16t
exit 0

sudo chmod +x /etc/rc.local

sudo systemctl start rc-local
sudo systemctl enable rc-local

sudo reboot

Wait so long to connect network when startup process

cpp 复制代码
cd /etc/systemd/system/network-online.target.wants/

more systemd-networkd-wait-online.service
#  SPDX-License-Identifier: LGPL-2.1-or-later
#
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

[Unit]
Description=Wait for Network to be Configured
Documentation=man:systemd-networkd-wait-online.service(8)
DefaultDependencies=no
Conflicts=shutdown.target
Requires=systemd-networkd.service
After=systemd-networkd.service
Before=network-online.target shutdown.target

[Service]
Type=oneshot
ExecStart=/lib/systemd/systemd-networkd-wait-online
RemainAfterExit=yes

TimeoutStartSec=2sec

[Install]
WantedBy=network-online.target

How to fix ip address

cpp 复制代码
more /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    eno1np0:
      dhcp4: no
      addresses:
        - 10.18.57.25/24
      gateway4: 10.18.57.255
      nameservers:
        addresses: [8.8.8.8, 4.4.4.4]
    eno2np1:
      dhcp4: true
  version: 2

Makeup U boot ubuntu

cpp 复制代码
download u tools: http://rufus.ie/downloads/
Ubuntu image mirror: https://launchpad.net/ubuntu/+cdmirrors

Linux change passwd

cpp 复制代码
passwd
sudo passwd root

How to get core dump file

cpp 复制代码
cat /proc/sys/kernel/core_pattern
echo core > /proc/sys/kernel/core_pattern
uclimit -c unlimited

Linux doesn't suspend after close LID

cpp 复制代码
sudo vim /etc/systemd/logind.con
	HandleLidSwitch=ignore
	HandleLidSwitchExternalPower=ignore
	HandleLidSwitchDocker=ignore
sudo systemctl restart systemd-logind	

SSH

cpp 复制代码
Server
    sudo apt install openssl-server
    sudo /etc/init.d/ssh restart
client
	ssh username@ipaddress

SAMBA

cpp 复制代码
Linux
    sudo  apt install samba
    sudo vim /etc/samba/smb.conf
        [jow]
            comment = jow share folder
            path = /home/jow
            browseable = yes
            read only = no
    sudo smbpasswd -a jow
    sudo smbpasswd -e jow
    sudo /etc/init.d/smbd restart
Windows
	right click mycomputer ===> mapping driver device ===> fill \\linuxIpAddress\jow

grep awd sed

cpp 复制代码
find /usr -name *.c -or -name *.h
find /usr -name *.c -and -name main*.c
find /usr -name *.txt | xargs grep -Rni "Hello*.world"
grep -Rni "Hello*.world"
ls -l | awk '{print $1}'
sed -i "s|subproject(|# subproject(|" meson.build
sed -i '/gn_args_args = list/i \ \ \ \ \ \ \ \ \ \ \ \ \ \ gn_args["external_cxxflags"] += [self._generate_gitmsg()]' build.py

Usb serial device response slowly

cpp 复制代码
Windows
	Find the device from device manager.
		right click ===> advanced ===> delay counter ===> default is 16ms, change to be 1ms
Linuxs
	sudo -i
    cat /sys/bus/usb-serial/devices/ttyUSB0/latency_timer
    echo 1 > /sys/bus/usb-serial/devices/ttyUSB0/latency_timer
相关推荐
辉哥大数据几秒前
ubantu22.04 源异常
ubuntu
MUTA️1 分钟前
使用ImageZMQ将本地摄像头画面传输到服务器
运维·服务器
wjykp9 分钟前
1.vmware虚拟机安装和配置os
linux·运维·服务器
Henry Zhu12325 分钟前
VPP中的DPDK插件源码详解第一篇:DPDK插件的作用和意义以及整体架构
运维·服务器·网络·计算机网络·云原生
Better Bench1 小时前
Ubuntu aarch64 (arm64)架构开发板的Linux系统安装拼音输入法
linux·ubuntu·arm64·aarch64·拼音输入法
测试人社区-千羽1 小时前
智能测试的终极形态:从自动化到自主化的范式变革
运维·人工智能·python·opencv·测试工具·自动化·开源软件
秋刀鱼 ..1 小时前
2026年机器人感知与智能控制国际学术会议(RPIC 2026)
运维·人工智能·科技·金融·机器人·自动化
roman_日积跬步-终至千里1 小时前
【源码分析】StarRocks 跨集群数据迁移工具 - 基于快照进行的快速迁移
运维
koddnty1 小时前
在c++中使用HOOK修改sleep函数
linux·c++
Jovin Giogic1 小时前
简明教程:记录 Ubuntu系统命令行安装TexLive,配置vscode
linux·vscode·ubuntu·latex·texlive