linux系统最佳实践经验

dengshuangjang dengshuangjang     2022-12-20     790

关键词:

用户管理

1、groups 查看当前用户所在的组;
将 newuser添加到组staff中
# usermod -G staff newuser
# usermod -aG dlong dlong 将用户dlong加入到dlong组,不退出原组。-d参数为删除该组用户。
2、修改newuser的用户名为newuser1
# usermod -l newuser1 newuser
3、锁定账号 newuser1
# usermod -L newuser1
4、解除对 newuser1 的锁定
# usermod -U newuser1


ManjaroLinux 系统设置

源的配置:
sudo pacman-mirrors -c China
sudo pacman-mirrors -i -c China -m rank
以上命令实际是修改并编辑 /etc/pacman-mirrors.conf。
添加中科大源:
sudo gedit /etc/pacman.conf,在文件末尾添加:
[archlinuxcn]
SigLevel = Optional TrustedOnly
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch
以上命令后能找到源里的软件,但没有密约不能安装,执行:
sudo pacman -Syy && sudo pacman -S archlinuxcn-keyring。
输入的安装和配置:
一般是要sudo gedit ~/.xprofile然后在里面添加:
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=”@im=fcitx”

更新系统错误

命令行sudo apt-get update 或者运行更新管理器的时候。
出现W: GPG 错误:http://ppa.launchpad.net lucid Release: 由于没有公钥,无法验证下列签名: NO_PUBKEY FAF69C646FF368B7的问题。
可以在终端中运行:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FAF69C646FF368B7
总的来说同:sudo apt-key adv --keyserver 服务器 --recv-keys 密约关键是密约,好像很难找到,不晓得官网有没有?
另外可以这样增加密约:方法是使用管道,原理一样。但还是要密约!
gpg --keyserver subkeys.pgp.net --recv-keys 40976EAF437D05B5
gpg -a --export 40976EAF437D05B5 | sudo apt-key add -
/etc/apt/sources.list这是源列表,可增加或删除源。不能更新源时,删除/var/lib/apt里的文件,就可以解决问题。
/usr/share/keyrings为软件源的密约,在更新更新系统软件时有时要密约,可以将不用的删除。
sudo apt-get install ubuntukylin-keyring可以用来安装密约文件。

每次开机都出现错误提示解决办法

开出出现错误如:System program problem detected 很麻烦,关闭方法:sudo gedit /etc/default/apport
enabled=0
把原先的1改成0就可以了。

显示错误

由于显示错误,退出图形界面,无法登陆,无法运行程序,这是因为显示管理器出现故障,可以运行:sudo dpkg-reconfigure lightdm/gdm来解决。

修复引导记录

sudo mount /dev/sda1 /mnt/sda
sudo grub-install --root-directory=/mnt/sda/ /dev/sda
(本步骤用于来重新安装grub2到硬盘的主引导记录【MBR】里面,十分关键!),最后:sudo update-grub2

软件包安装,删除出错的终极解决方法

本方法适用于任何软件包安装,删除时报告的类似于:“post-xxxxx失败”,以及其他错误。
主要是删除下面这个文件中阻碍安装删除的文字.
原理:dpkg之所以能够对每个包的状态了如指掌,完全是因为dpkg数据库--→>/var/lib/dpkg/status

安装并更新系统软件或是其它的软件

安装软件:apt-get install 软件名
删除软件:apt-get remove 软件名
自动删除软件:apt-get autoremove 软件名 //有可能将有用的软件删去
更新软件先更新源:apt-get update //更新软件数据 upgrade //更新升级系统。
purge - Remove packages and config files
dist-upgrade - Distribution upgrade, see apt-get(8)
dselect-upgrade - Follow dselect selections
clean - Erase downloaded archive files

修改键盘映射

命令行输入:xev
得到要修改的键的代码
xmodmap -pke > ~/.Xmodmap
kwrite ~/.Xmodmap
xmodmap ~/.Xmodmap

Fedora 19安装中文

yum list kde*chinese;便显示了下列两个文件:kde-i18n-Chinese.noarch kde-l10n-Chinese.noarch。

如果没有五笔输入法

sudo apt-get install ibus
sudo apt-get install ibus-sunpinyin
sudo apt-get install ibus-pinyin
sudo apt-get install ibus-table-wubi
sudo apt-get install gnome-icon-theme
ibus-setup
ibus-daemon -drx

安装打印机服务

1、先使用systemctl list-unit-files查看服务运动状态,systemctl enable procps.service。
2、apt-get install cups。
3、apt-get install cups-client cups-core-drivers(这个可以不安装)。

安装gnome环境

Sudo apt-get install gnome-shell,就可以安装gnome桌面环境,界面较简洁。
修改/usr/share/gnome-shell/theme/gnome-shell.css,要解决花屏,去掉所有transition-duration相关的代码。
查看:icon-grid与panel可以修改DASH程序视图。


让不同的程序在不同的桌面显示

修改/usr/share/applications下的desktop文件内容:
• NoDisplay=true
• OnlyShowIn=KDE;
• NotShowIn=KDE;

更改命令名称

alias iis=‘service nginx start‘
alias iid=‘service nginx stop‘

Fedora安装视频音频解码器

$> su -
#> dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
#> dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
#> dnf install vlc
安装解码器命令:su -c ‘yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm‘
sudo yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-branched.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-branched.noarch.rpm?
su -c ‘rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm‘?
rpm -ivh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-20.noarch.rpm
rpm -ivh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-20.noarch.rpm
dnf install http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-20.noarch.rpm
sudo apt-get install ubuntu-restricted-extras

实战解决rhythmbox 乱码

对于所有用gstreamer做后端的播放器,如Rhythmbox,设置如下的环境变量后即可正确读取mp3中GBK编码的id3 tag。
sudo gedit /etc/profile
在最后加入
export GST_ID3_TAG_ENCODING=GBK:UTF-8:GB18030
export GST_ID3V2_TAG_ENCODING=GBK:UTF-8:GB18030
注销后重新导入歌曲信息即可解决乱码。
我弄的,更绝:
export GST_ID3_TAG_ENCODING=ASCII:GB2312:GBK:GB18030:UTF-8:UTF16:UTF32
export GST_ID3V2_TAG_ENCODING=ASCII:GB2312:GBK:GB18030:UTF-8:UTF16:UTF32
保存,退出;

Fedora启动优化

查看启动服务:chkconfig
查看开机服务:systemctl list-unit-files
systemctl list-unit-files --type=service | grep enable/disabled/maked(查看启动/禁用/标记的服务情况)。
查看开机各程序所用时间:systemd-analyze plot > plot.svg
禁用服务:sudo systemctl disable 服务名称。

取消客户登陆

#sudo gedit /etc/lightdm/lightdm.conf,添加 allow-guest=false , 即如下内容:
[SeatDefaults]
greeter-session=unity-greeter
user-session=ubuntu
allow-guest=false

桌面没有快捷方式

1.安装gnome-tweak-tool
# yum install gnome-tweak-tool亲手试过了,这个是不行的,版本落后了,在加删除程序中安装程序。
2.在应用程序里找到这个软件,通过配置桌面,可以把我的电脑回收站等放在桌面上
3.进入文件系统 usr/share/application,可以在需要桌面显示的程序上右键 复制到桌面,OK了。

建立关机快捷方式

#!/bin/bash
sudo -S shutdown -h now <<EOF
password
EOF
或:
echo password | sudo -S shutdown -r now 其中的-S是必须的,代替终端输入。
再为启动程序创建一个快捷方式,或是将用户文件夹下的.CONFIG文件下autorun文件夹下的程序复制进行修改。
将上面的文字保存在/sbin文件夹下,并设置为可启动程序。

删除旧内核

sudo dpkg --get-selections|grep linux
sudo apt-get remove linux-image-2.6.27-7-generic
dpkg --list|grep linux-image
sudo apt-get purge linux-image-4.14.12-041412-generic

清除残余的配置文件

dpkg -l |grep ^rc|awk ‘print $2‘ |sudo xargs dpkg -P

使用命令不记得命令

look 要查询的单词

yes 要输出的文字,这些文字用引号引起来

ping -c -i i指一次用的时间,c总次数。

安装MediterraneanNight系列主题

sudo add-apt-repository ppa:webupd8team/themes
sudo apt-get update
sudo apt-get install mediterraneannight-gtk-theme

linux下安装火狐中国版总结

1. 下载的bz2格式的火狐。2. 解压。3. 将解压得到的整个文件夹CP到系统的lib文件夹下。4. 创建链接:sudo ln -s /usr/lib/firefox/firefox /usr/bin/firefox

 

 

安装永中办公软件

1. 先解压
2. 命令转到目录:./setup
3. OK

安装DOCK

sudo apt-add-repository ppa:ricotz/docky
sudo apt-get update
sudo apt-get install plank
Plank 可谓简洁到家,没有任何图形化配置,如果你想要配置,只能修改其配置文件:sudo gedit ~/.config/plank/dock1/settings

>>用Linux作WEB服务器
用Linux作WEB服务器

采用nginx建立个人网站只有三步:
1、卸载apache,安装nginx并启动服务:

sudo apt-get purge apache2* 删除apache2有关的程序,*代表任意。
sudo apt-get autoremove 自动删除无用的临时文件。
sudo apt-get install nginx 安装服务软件。
sudo service nginx start 启动服务。
检查:浏览器地址栏输入: http://localhost。
2、修改配置:
sudo gedit /etc/nginx/nginx.conf
把worker_processes设置成你的CPU数目,如1,2,4等;
sudo gedit /etc/nginx/sites-available/default,修改:
server
listen 80 default_server;
root /usr/share/nginx/html; #修改为你的网站目录,如: /webServer/main
index index.php index.html index.htm;

3、 重启服务:sudo service nginx restart

用Linux作FTP服务器

安装FTP服务软件:yum install vsftpd
启动服务程序:service vsftpd start
Vsftpd配置方法:
# Use this to jail all users in their homes
DefaultRoot ~
# Users require a valid shell listed in /etc/shells to login.
# Use this directive to release that constrain.
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> me start
RequireValidShell off
AuthOrder mod_auth_file.c
AuthUserFile /etc/proftpd/ftpd.passwd
AllowRetrieveRestart on
AllowStoreRestart on
ServerIdent off
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> me end
建立用户
[email protected]:/home/mmc# ftpasswd --file=/etc/proftpd/ftpd.passwd --home=/home/dlong --shell=/bin/false --name=dlongx --uid=33 --gid=34 --passwd
修改文件夹的权限:
调用文件夹用户为:www-data

DEEPIN显示优化

sudo deepin-feedback-cli
#开启 metacity 窗管合成:
deepin-metacity --composite --replace
#关闭 metacity 窗管合成,取代正在运行的窗管:
deepin-metacity --no-composite --replace
#deepin-wm窗管,取代正在运行的窗管:
deepin-wm --replace
deepin-metacity --replace
deepin-metacity --help
startx

mongodb最佳实践经验总结

                    查看详情

创建数据库索引都有哪些最佳实践和“经验法则”?

】创建数据库索引都有哪些最佳实践和“经验法则”?【英文标题】:Whataresomebestpracticesand"rulesofthumb"forcreatingdatabaseindexes?创建数据库索引有哪些最佳实践和“经验法则”?【发布时间】:2010-10-1520:05:36【问题描述】:我... 查看详情

五年java经验,面试还是说不出日志该怎么写更好?——日志规范与最佳实践篇(代码片段)

...变量方便调试,正确的做法是使用日志来输出(使用整个系统大部分时间都是运维人员来维护,日志可以帮助运维人员来了解系统状态(很多运维系统接入的也是日志),运维人员发现日志有异常信息也可以及时通知开发来排查... 查看详情

java项目结构最佳实践,砥砺前行!

...整理的,霸哥没有任何改动)面试主要是从一个系统设计出发,考察基础跟项目架构经验。美团相当重视基础问题(计算机网络、操作系统)主要是围绕一个系统优化来的,下面就只写中间问的几个点࿱... 查看详情

Meteor 中布局模板的最佳实践?

...】:2013-10-2719:15:55【问题描述】:我使用过的大多数模板系统都有一个主“布局”模板的概念,然后是针对页面细节的专门内容模板。例如,在expressjs中,确实有一个与内容分离的布局模板(iirc与ejs或jam模板的工作方式相同)... 查看详情

cobbler自动化部署最佳实践

...几百台,几千台甚至几万台的服务器时,仅仅是安装操作系统,如果不通过自动化来完成,根本是不可想象的。面对生产环境中不同服务器的需求,该如何实现批量部署多版本的操作系统呢?Cobbler便可以的满足这一实际需求,... 查看详情

PHP/MySQL 预约/预约系统的最佳实践

】PHP/MySQL预约/预约系统的最佳实践【英文标题】:BestpracticeforPHP/MySQLAppointment/Bookingsystem【发布时间】:2013-06-0312:26:07【问题描述】:我需要一些人来为我目前正在从事的美发师的PHP/MySQL预约系统争取“最佳实践”。希望我们可... 查看详情

传统idc机房与云计算如何快速结合最佳实践的经验之谈

大家好,有两周没好好坐下来聊聊近期的实践课程了,今年也是对网工技能要求上的一个非常大的挑战,怎么说呢?因为上云的趋势已经来临,去年是所有的企业都在拥抱互联网,今年则是所有的企业都在拥抱云计算,加上各大... 查看详情

以不同用户身份运行 Linux 服务的最佳实践

】以不同用户身份运行Linux服务的最佳实践【英文标题】:BestpracticetorunLinuxserviceasadifferentuser【发布时间】:2010-09-2813:00:26【问题描述】:在我的RHEL机器上,服务默认以root启动。如果我没记错的话,其他使用/etc/init.d中的初始化... 查看详情

除了 syslog 之外,Linux 服务/守护程序文件记录最佳实践是啥? [关闭]

】除了syslog之外,Linux服务/守护程序文件记录最佳实践是啥?[关闭]【英文标题】:WhatisLinuxservice/daemonfileloggingbestpracticeapartfromsyslog?[closed]除了syslog之外,Linux服务/守护程序文件记录最佳实践是什么?[关闭]【发布时间】:2019-08-... 查看详情

在 Linux 上部署 ASP.NET MVC:最佳实践、工具和惊喜

】在Linux上部署ASP.NETMVC:最佳实践、工具和惊喜【英文标题】:DeployASP.NETMVConLinux:BestPractices,Tools&Surprises【发布时间】:2010-11-1310:23:16【问题描述】:我想知道开发ASP.NETMVC应用程序的最佳实践,可以选择在Linux上部署。如果您... 查看详情

开源监控系统prometheus最佳实践(代码片段)

...师,Prometheus/ThanoscontributorPrometheus是目前最流行的开源监控系统之一,这里以我在基于Prometheus构建天机阁2.0Metrics子系统的实践谈一谈Prometheus的一些最佳实践,最佳实践的理念是Prometheus系统简单稳定高效运行的关键。(注:天机阁2.0是... 查看详情

flutter最佳实践-01

Flutter最佳实践-01原文https://vipinvijayannair.medium.com/前言作者把工作中的经验做了罗列,这是第一部分,持续更新。正文1.占位PlaceholderWidget使用SizedBox而不是Container作为占位符widget。看看下面的用例return _loaded ? Container() :... 查看详情

调试linux系统挂起和休眠问题的最佳实践(代码片段)

概述当谈到Linux系统的挂起/休眠时,我们指的是以下三种受支持的Linux系统休眠状态:STI(SuspendToIdle)是一种通用的、纯软件、轻量级系统睡眠状态。与特定于平台的驱动程序增强一起,可以使用这种状态来达到Intel®平... 查看详情

黄金法则:mysql基准测试最佳实践(代码片段)

...个非常重要的分支。本文目的在于让读者对关系型数据库系统有一个基本的了解,掌握MySQL以及如何管理使用Linux。文中讨论了MySQL性能因素以及如何测试CPU性能,同时使用具体的例子来展示几种实用的测试MySQL系统的实践... 查看详情

Bootstrap 嵌套网格系统最佳实践

】Bootstrap嵌套网格系统最佳实践【英文标题】:BootstrapNestedGridSystemsBestPractices【发布时间】:2014-05-3123:25:08【问题描述】:我正在尝试使用引导程序创建一个站点,而不使用外部css。看来我可以使用嵌套网格系统实现许多格式化... 查看详情

阿里云数据库快速搭建疫情分析系统最佳实践

...控任务迫在眉睫,如果快速搭建高效的疫情态势分析系统是众多部门和单位的难题,阿里云RDSPG+Ganos解决方案可在极短时间内完成分析系统搭建,有效助力疫情防控。直达最佳实践:【阿里云数据库快速搭建疫... 查看详情

使用最佳实践反应导入模块 [重复]

】使用最佳实践反应导入模块[重复]【英文标题】:ReactImportModulesusingbestpractices[duplicate]【发布时间】:2019-09-0105:24:33【问题描述】:根据您的经验,将大型模块导入组件时的最佳做法是什么。请您从下面的示例中告诉我其中的... 查看详情