This is my to-do list what needs to be configured before you can start working on the new Linux PC. This steps were done by me after completing the Manjaro installation process explained in my second gist. I decided to split it up because that other gist about configuring what needs to be done to have a working OS on the machine while the steps here are about software configuration and are mostly personal. Tbh the main reason I'm doing this list is for my future self to remember what needs to be done and in which order after the OS is installed. This tutorial is also very hardware independent and covers the steps needed to be taken on every PC with Manjaro (Linux in general) and not only the Thinkpad mentioned in the second gist.
My terminal text editor of choice is nano
, but working in it with the default config is kinda annoying so the first thing to do is going thru the ~/.nanorc
file.
To create the file take the default one from /etc/nanorc
and create copy as ~/.nanorc
. You may also take my current one I'm attaching to this gist (for version 6.4) but if the version is lot newer/older it's better to compare it with the default one and manually create the desired one.
Remember also to set .nanorc
for root user as this config is being used when sudo nano
. Installing the nano-syntax-highlighting
package is also a good idea.
Manjaro doesn't have colordiff
package installed by default, but I'm suggesting installing it and making an alias for it. You may install it with
# pacman -S colordiff
and create the alias by adding alias diff=colordiff
to your .bashrc
/.zshrc
.
Sometime ago I also found an dark mode for colordiff which might be put into ~/.colordiffrc
# Example colordiffrc file for dark backgrounds
#
# Set banner=no to suppress authorship info at top of
# colordiff output
banner=no
# By default, when colordiff output is being redirected
# to a file, it detects this and does not colour-highlight
# To make the patch file *include* colours, change the option
# below to 'yes'
color_patches=no
# Sometimes it can be useful to specify which diff command to
# use: that can be specified here
diff_cmd=diff
#
# available colours are: white, yellow, green, blue,
# cyan, red, magenta, black,
# darkwhite, darkyellow, darkgreen,
# darkblue, darkcyan, darkred,
# darkmagenta, darkblack
#
# Can also specify 'none', 'normal' or 'off' which are all
# aliases for the same thing, namely "don't colour highlight
# this, use the default output colour"
#
plain=off
newtext=darkgreen
oldtext=darkred
diffstuff=darkcyan
cvsstuff=cyan
Remember to create custom profile (default ones are read-only) and change some settings:
- set scrollback to unlimited (if system drive is encrypted)
- turn on "Mouse click in input line moves cursor"
This is the most complicated step for me because I don't remember in which order I had configured this stuff. Following subsections shows all the stuff that needs to be done, they don't need to be done in that order tho.
All configs for the ssh server are stored in /etc/ssh/sshd_config
file. For me the best way is to just copy the config from the old PC and compare it with the default one to see what you need to change.
The same goes with the SSH client, but the config for it is in ~/.ssh/config
file. This file is also used for specifying custom host names. I'm attaching a little redacted version of this file here for future reference.
The ~/.ssh/authorized_keys
file contains the ssh keys that can be used for given user authentication. So to be able to login to this PC with certain key it needs to be added there (even if you have that key on the machine used as your identity key).
You may add keys with ssh-copy-id -i <private-key-file> <user>@<host>
command from the old PC (or just copy this file from the old PC).
If you need to use a proxy to connect via ssh to certain hosts you may need to use the special config (ProxyCommand
) and netcat
package. The config below is done for the openbsd-netcat
package so choose this one when asked, because gnu-netcat
has a different command syntax.
For hosts behind the proxy use ProxyCommand nc -X connect -X <ProxyIP>:<port> %h %p
and for other hosts use ProxyCommand none
.
After the setup remember to set all files from ~/.ssh
to read/write only by the owner. You may do it with a command
chmod 600 ~/.ssh/*
If you're sure that your ssh server config is OK then you may start the server with
sudo systemctl enable sshd.service
sudo systemctl start sshd.service
This step is about setting up the SSH agent which let's you use your SSH key without entering the passphrase (actually it asks for a password ones but the pwd is being provided via kwallet
which is unlocked automatically when you login to the PC). IMO this is the most complicated step and I'm not really sure how I did it. If I'm not mistaken I have followed this tutorial but I remember I had some issues with that. I'm trying to recreate the way I did it below.
You may do it with this command
sudo pacman -Syu --needed kwallet ksshaskpass kwalletmanager
The only way it worked for me (which was mentioned by @openminded in their comment as well) was to set both of the required env vars in the /etc/profile.d/ssh-askpass.sh
file. So adding the following lines to that file worked for me
export SSH_ASKPASS=/usr/bin/ksshaskpass
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR"/ssh-agent.socket
This step is to create a ~/.config/systemd/user/ssh-agent.service
file (creating the dir might be required before) with following content
[Unit]
Description=SSH agent (ssh-agent)
[Service]
Type=simple
Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
Environment=DISPLAY=:0
ExecStart=ssh-agent -D -a $SSH_AUTH_SOCK
ExecStop=kill -15 $MAINPID
[Install]
WantedBy=default.target
You may do it with following commands
systemctl --user daemon-reload
systemctl --user enable ssh-agent.service
In this step you need to create the ~/.config/autostart/ssh-add.desktop
file with following content
[Desktop Entry]
Exec=ssh-add -q /home/<user>/.ssh/key1 /home/<user>/.ssh/key2 /home/<user>/.ssh/key3 < /dev/null
Name=ssh-add
Type=Application
The most important part here is to keep the absolute path to the key (/home/<user>/.ssh/key1
, NOT ~/.ssh/key1
), because it wasn't working with the ~
or $HOME
.
The next step is to reboot the PC. During the next login you may be asked for a passphrases for all you SSH keys. If possible provide them and select the checkbox to add the passphrase into kwallet
. If not after the login run the command ssh-add
with needed keys to trigger the passphrase box once more and then provide the passphrase.
On my old PC I've been using different setup for ssh-agent
which is considered worse (doesn't work in terminal only sessions) and is explained here. I ended up with this solution because I wanted to have auto-login turned on which results in kwallet
not being unlocked automatically so I turned on another pop up to ask for kwallet
password. At that time it looked like a better idea (I really don't know why).
This point is straightforward. Here you just need to check if
ssh-agent
is working (no asking for the SSH passphrase)- you can connect to other PC with your SSH key
- you can connect to this PC from other one
- you can connect to
localhost
- you can connect to some weird host in the Internet
- proxy is working OK and all hostnames are reachable
- and others
When connecting to any host check if you still have your ssh keys inside the agent (the easiest way is to do a loop of connection to the localhost or from your PC (PC1) connect to some other device (PC2) and back again to PC1.
I found kinda strage situation in Manjaro - on clean install it is possible to install any AUR package using pamac
in the terminal, but running pamac update
shows no packages to update even tho some of them are outdated. Turns out to properly use AUR with pamac you HAVE TO open the "Add/Remove Software" GUI, enter settings and turn on support for AUR. Without that you can install AUR packages but pamac
will not remember that they were installed from AUR and won't let you update them without reinstalling.
To list all foreign packages on the system you can use pacman -Qm
. To list all AUR packages installed via pamac
(with AUR support turned on) you can use pamac list -i | grep AUR
. If the output of the second command is empty while you know some of the packages were installed from AUR (pacman
lists some foreign packages) you haven't turned on the AUR support properly.
Yakuake is a drop-down terminal app which works great with KDE and Konsole. I suggest installing it as having a drop-down terminal is really handy.
In terms of the config this app needs to be manually added to the list of autostarted apps in KDE and you should change the profile to the same custom one you created for Konsole.
In terms of the skin/theme I stick to using the Breath Dark theme (when using Manjaro). This theme is not available in the Yakuake skin repo so if you don't have access to the Breath Dark I would go with Breeze Perfect Dark (by noahadvs/Noah Davis) which is the one I use on my Steam Deck.
Here's the list of packages that are useful and are not part of the basic Manjaro installation:
net-tools
- forifconfig
(or use modernip
command)- NOT
ceph-libs
- this issue is rather specific to my machine but remember to not install theceph-libs
from AUR. This package is very often updated and it takes years to compile it. If you really need this package install theceph-libs-bin
. Right now both of them are in AUR, but I had it installed on my machine for some reason.
I'm using the GPG key to sign my commits so during the new PC setup I need to copy my key from one machine to another. I'm using this key only for git
so this setup here is connected with the git
setup.
The following steps are based on this and this tutorials.
Firstly identify your private key and remember its ID (the part after the /
).
gpg --list-secret-keys [email protected]
Next export the selected key to the file - you will be asked for a passphrase, even if you have it in the keyring (eg. kwallet
), so have it prepared.
gpg --export-secret-keys <key-id> > private.key
Transfer the file to the second machine securely, eg. using the scp
.
scp <local-path> <host>:<remote-path>
The next step is to import the key (again, have your passphrase ready).
gpg --import private.key
You may also need to add the key to the gpg2
key list but in my case it was done automatically. After that you need to raise that key to the ultimate trust. To do this enter the key edit mode.
gpg --edit-key <key-id>
In the key edit mode enter trust
to edit the trust level, select the desired level (in this case 5) and enter save
to commit changes.
Right now it should be possible to use the key, but being asked for the passphrase every time.
The steps required to set up the gpg-agent
are explained on the arch-wiki.
Start with installing required packages - pinentry
and kwalletcli
(the second one is available in AUR repos).
sudo pacman -S pinentry
pamac build kwalletcli
After that put the required config into the ~/.gnupg/gpg-agent.conf
file. For me the content of this file looks like that.
default-cache-ttl 18748800
max-cache-ttl 18748800
pinentry-program /usr/bin/pinentry-kwallet
After that restart the gpg-agent
(or your PC) and the next time you're using the gpg key you should be asked to save the passphrase into the kwallet
.
Setting up git is pretty straightforward. The first step is to set up ~/.gitconfig
file. If you don't have any additional config just setting up fields for name and email is enough, but I'm attaching my whole .gitconfig
to this gist for future reference.
The next step is cloning the required repos and checking if committing (here you might have an issue with GPG key) and push (here you might have an issue with SSH key) works.
To check if commit is properly signed you may use
git log --show-signature
If both of that works remember about repo specific settings (like different email address for work repos and so on).
The official package that is available in the Arch repos is code
which is open-source version of VSCode which is stripped from the proprietary code. Because I prefer the official release I suggest using the visual-studio-code-bin
package that is available in the AUR. You may install it with
pamac build visual-studio-code-bin
After that the only thing that needs to be done is to open the app, go thru the into checklist and enable the settings sync. I haven't yet go thru the whole VSCode settings so I'm not gonna put it here, but I can list few must-have plugins:
- C/C++
- Gist
- Code Spell Checker (with language plugins)
- GitLens
- Markdown All in One
- Markdown PDF
This tool is a game changer for me when using a terminal. OK, sure, I don't use everything it can, but the sole command finder is so nice, that I can't use terminal without it.
During this system reinstall I took some time to went thru the fzf
docs and did some configuration of this tool. However for basic operation it's enough to just instal the tool and source two files mentioned on arch-wiki. On the other hand installing the version from the github sources these files automatically.
If you want to check out other setting of this tool you may read this article on github wiki. My current config (for zsh
) based on what I found in the wiki is as follows (it required to additionally install ag
and tree
packages).
# fzf
## turning on fzf
source "/usr/share/fzf/key-bindings.zsh"
source "/usr/share/fzf/completion.zsh"
## fzf settings
export FZF_COMPLETION_TRIGGER='' # fuzzy completion works without any trigger
bindkey '^Y' fzf-completion # fuzzy completion is binded to ctrl+y
bindkey '^T' fzf-file-widget # ctrl+t is default file search
bindkey '^I' $fzf_default_completion # tab works normally
## show hidden files in file search
export FZF_CTRL_T_COMMAND='ag --hidden --ignore .git -g ""'
## file search shows file preview
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
## command search can have preview activated by ?
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
## fast cd (alt+c) shows tree in preview
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
For bash
you need to change the sourced files to the correct ones (ending with .bash
) and skip the part about the FZF_COMPLETION_TRIGGER
and keybindings as it doesn't really works with bash
(you can still uze fuzzy search with **<TAB>
).
# fzf
## turning on fzf
source "/usr/share/fzf/key-bindings.bash"
source "/usr/share/fzf/completion.bash"
## show hidden files in file search
export FZF_CTRL_T_COMMAND='ag --hidden --ignore .git -g ""'
## file search shows file preview
export FZF_CTRL_T_OPTS="--preview '(highlight -O ansi -l {} 2> /dev/null || cat {} || tree -C {}) 2> /dev/null | head -200'"
## command search can have preview activated by ?
export FZF_CTRL_R_OPTS="--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
## fast cd (alt+c) shows tree in preview
export FZF_ALT_C_OPTS="--preview 'tree -C {} | head -200'"
This chapter is about setting up your shell. Until now I've been using only bash
and the fact the newest Manjaro uses zsh
by default was something new for me. However as a lot of ppl suggest that zsh
is in fact more user friendly then I decided to give it a try. This step is almost at the end because I knew it will take me a lot of time to find out how to use zsh
and what settings I really need. I'm also went thru the .bashrc
as I want to have it set up as well if I need to use it for some reason (eg. ssh
connection).
The default Manjaro .bashrc
and .zshrc
files are OK and I'm mostly leaving them as they are and I only add my stuff to it.
For a long time I liked having the git
status showed as part of the bash
prompt and I was using the git-prompt.sh
script which is a part of the git
itself.
To have it set up in the bash you need to do two things. The first one is sourcing that file at the beginning of the .bashrc
file (and setting up some additional settings if you want):
# git prompt
source /usr/local/bin/git-prompt.sh
export GIT_PS1_SHOWDIRTYSTATE=true
export GIT_PS1_SHOWUNTRACKEDFILES=true
export GIT_PS1_SHOWUPSTREAM="auto"
The second one is modifying the PS1
var which is the definition of your prompt. As I didn't like the original Manjaro prompt I have it changed as follows:
if ${use_color} ; then
if [[ ${EUID} == 0 ]] ; then
PS1='\[\033[01;31m\][\u@\h\[\033[01;37m\]:\[\033[01;36m\]\w\[\033[01;37m\]$(__git_ps1 " (%s)")\[\033[01;31m\]]#\[\033[00m\] '
else
PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\]:\[\033[01;34m\]\w\[\033[01;37m\]$(__git_ps1 " (%s)")\[\033[01;32m\]]\$\[\033[00m\] '
fi
else
if [[ ${EUID} == 0 ]] ; then
PS1='[\u@\h:\w$(__git_ps1 " (%s)")]# '
else
PS1='[\u@\h:\w$(__git_ps1 " (%s)")]\$ '
fi
fi
These changes uses the default Manjaro var (use_color
) and are the same for my user as well as for root. Having the git-prompt
as part of the root prompt is kinda useless, but as I have set it up some day ago then I'm leaving it like that now.
The default Manjaro zsh
prompt already has a support for git-prompt (which is also lot cooler than the basic one that I was using in bash
) so I haven't edited anything in that matter in zsh
. I might edit the prompt itself in the future but as for now I'm leaving the default settings. If that happens I'll edit this doc as well.
Manjaro default .bashrc
has a list of 5 aliases that are by default commented out but I like having them uncommented. I also set them up in my .zshrc
file now. I'm putting these aliases below (and yes, I know that having the cp -i
as default cp
is kinda unsafe as it teaches you to not care when using cp
, but I'm having it only as the last resort):
alias cp="cp -i" # confirm before overwriting something
alias df='df -h' # human-readable sizes
alias free='free -m' # show sizes in MB
alias np='nano -w PKGBUILD'
alias more=less
Beside the above aliases in the default Manjaro .bashrc
you have this two settings which I find useful.
# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control. #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize
# Recursivly check for aliases
shopt -s expand_aliases
This part is explained in the part about the fzf
.
The default history behavior on Manjaro is that it remembers 10k commands (counting duplicates) and the file is updated only when exiting the terminal session (meaning that when you have two terminals open you don't have history from the first in the second).
However I prefer to have shared history between terminals and save more than 10k commands (I'm very often using the Ctrl+R to find the desired command). Set up for it differs in bash
and zsh
.
# longer bash history
export HISTSIZE=40000 # history size for one terminal
export HISTFILESIZE=200000 # whole history size
shopt -s histappend # when exit bash append history to a file
export PROMPT_COMMAND="history -a;history -n;$PROMPT_COMMAND" # append history to file every command (requeires above line to work)
# longer and shared history
export HISTSIZE=40000
export SAVEHIST=200000
setopt share_history
# aliases
## alias for colordiff
alias diff=colordiff
## ls with all files
alias la='ls -A'
## ll
alias ll='ls -alF'
## ll without hidden files
alias l='ls -CFlh'
## going upppp
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias ......="cd ../../../../.."
alias .......="cd ../../../../../.."
alias ........="cd ../../../../../../.."
## sudo last command
alias s='fc -e "sed -i -e \"s/^/sudo /\""'
Same as with cp
mentioned earlier I like having more secure version than the original rm
. However as rm
is a lot more destructive than cp
I'm not changing the default behavior for it, but I have an alias for del
. The same alias goes for zsh
and bash
.
## safe rm
alias del='rm -i'
If you're not a fan of vi
then it might be useful to export the EDITOR
variable with path to nano
to make it your default editor in terminal. You may do it by adding the following lines to your .bashrc
/.zshrc
:
# set nano as default
export VISUAL=nano
export EDITOR=nano
I really like using this shortcut when writing in a text editor and found myself trying to use it when entering commands in bash. It doesn't support it natively but you can turn it on with following commands.
# ctrl+backspace and ctrl+del; better put it in .inputrc without bind for systemwide support
if [[ $- == *i* ]]; then # check if shell is interactive
bind '"\C-h": backward-kill-word'
bind '"\e[3;5~": kill-word'
fi
SDDM is the display manager for KDE Plasma. Most of its settings are overridden by user config after login so in reality most SDDM configs are for the login screen. By default when you have multiple screens SDDM puts them in the order defined by hardware (mostly GPU, but other stuff such as the docking station can influence it as well). It puts displays in the very basic order one after another from left to right. Sometimes that's enough, sometimes you just don't care because the correct screen order is loaded just after you login in, however if you wanna fix that (and have a pretty consistent monitor setup) you can do it easily. It's explained in detail in this tutorial and here I will just put my config.
So, the first and obvious step it to set the correct display order after you login in. When you have your screens set up, you can run xrandr | grep ' connected'
to print all connected screens with its basic config and device names (which will be needed in the next step).
$ xrandr | grep ' connected'
eDP-1 connected 1920x1080+0+1080 (normal left inverted right x axis y axis) 309mm x 174mm
DP-3-1-5 connected primary 1920x1080+1920+474 (normal left inverted right x axis y axis) 531mm x 299mm
DP-3-1-6 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 521mm x 293mm
DP-3-2 connected 1920x1080+3840+474 (normal left inverted right x axis y axis) 527mm x 296mm
The next step is to create the Xsetup config file for SDDM - /usr/share/sddm/scripts/Xsetup
is the default location which might be already present in your distro (it was in my Manjaro at least). The content of this file is explained in the above-mentioned tutorial, but in short it should be the xrandr
command with parameters for each device. It should be put in one line but I split it by putting \
at the end of each line for better readability. The content of this file in my case is as follow:
#!/bin/sh
# Xsetup - run as root before the login dialog appears
xrandr \
--output DP-3-1-6 --mode 1920x1080 --pos 0x0 --rotate normal \
--output eDP-1 --mode 1920x1080 --pos 0x1080 --rotate normal \
--output DP-3-1-5 --mode 1920x1080 --pos 1920x474 --rotate normal \
--output DP-3-2 --mode 1920x1080 --pos 3840x474 --rotate normal
After that you might need to edit the SDD config file (/etc/sddm.conf
) to include the file you just created, but in my case, it was already specified as DisplayCommnand
. If you don't have it specified, you need to add the following lines to your config. Note: [XDisplay]
might be replaced by [X11]
depending on your system.
[XDisplay]
DisplayCommand=/usr/share/sddm/scripts/Xsetup
After rebooting the PC, you should see your config working.
After making the above changes the mouse cursor on SDDM became unnaturally big (I guess 36-48px). It might be also the result of the recently installed update tho. Anyway, to fix that you need to add the CursorSize
config into KDE settings for SDDM - /etc/sddm.conf.d/kde_settings.conf
. You can check your cursor size in System Settings
-> Appearance
-> Cursors
-> Size
(on the bottom near buttons). I believe the default size is 24px.
[Theme]
CursorSize=24