[article_overview]
After performing a fresh install or upgrade of Debian Lenny, you may want to customize the server to make management of the server easier.
[/article_overview]
But first,
basics of package management in Debian.
There are many tools in Debian to install, remove, search for programs - also know as packages.
dpkg is a low level tool, similar to Fedora/Redhat rpm.
apt-get is mid level tool which has some dependency checking.
Dependency checking ensures that all required files for a package get installed and do not conflict with other packages.
Aptitude is a mid-high level tool which has better dependency checking.
There are also guis such as synaptic which could be considered high level tools, but the focus here is the command line.
common commands
update Debian repository of software aka packages
update currently installed packages
search for packages
1
|
aptitude search <package name>
|
install packages
1
|
aptitude install <package package>
|
uninstall package; configuration and log files will be left over
1
|
aptitude remove <package>
|
uninstall package removing configuration files
1
|
aptitude purge <package>
|
show the files in package
1
|
aptitude show <package>
|
When you search the web, you may find references to apt-get and apt-cache.
They are lower level package utilities which work, but should be replaced with aptitude.
1
2
|
apt-get install <package>
apt-cache search <package name | package description>
|
dpkg is yet a lower level package manager which does provide some functions not found in aptitude.
List installed packages.
This can be useful before performing a format re-install.
Customize your command line editor.
Vim is the focus here, but nano and emac are good command line editors too.
Add what you like to the bottom
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
" customize vi, vim
set nocompatible " use VIM defaults (much better!)
set noautoindent " autoindenting off
set noerrorbells " Hearing beep every 2 seconds isn't my idea of fun
set background=dark " syntax highlight color maps
syntax on " turn on sytax highlighting
set backspace=indent,eol,start " backspacing over everything in insert mode
set backup " keep backup file after written
set backupdir=/var/tmp " directory of backup files
set writebackup " write a backup when writing over a file
set nocindent " set C style indenting off, I don't write C!
set cmdheight=2 " command line height
set comments=b:#,b:\",n:> " define command separated list of comment characters
set cpoptions=ces$ " compatible options
set formatoptions=tcql " set the options for comment formatting
set history=50 " keep 50 lines of command line history
set ignorecase " ignore case in search patterns
set smartcase " ignore ignorecase when pattern contains uppercase
set incsearch " do incremental searching
set joinspaces " two spaces after "." for join command
set laststatus=2 " occasions to show status line, 2=always.
set magic " change special characters used in search patterns
"set mouse=a " make sure mouse is used in all cases.
"set mousemodel=extend " set the model of mouse
set nohlsearch " don't highlight my searching please
set number " display line numbers
set ruler " ruler display in status line
set shortmess=o " overwrite writing message with read so less
set showcmd " display incomplete commands
set showmatch " show matching brackets
set showmode " show mode at bottom of screen
set smarttab
set softtabstop=4
set tabstop=4 " number of space <tab> counts for
set expandtab " fill tabs with spaces
set shiftwidth=4 " shift width size
hi User1 term=underline cterm=bold ctermfg=White ctermbg=Blue guifg=#ccffff guibg=#0000aa
set statusline=%1*%F%m%r%h%w%=%(%c%V\ %l/%L\ %P%)
"set textwidth=78 " max length of line for inserting text
"set verbose=9
set viminfo='20,\"500,h " read/write a .viminfo file, don't store more than
" 500 lines of registers, disable hlsearch
set wildmenu " show menu of last commands
set wildmode=list:longest,full " longest string, list alternatives, full match
"set nowrap " turn wrapping on for display
set winaltkeys=menu " allow only menus with ALT key, otherwise use maps.
"set wrapmargin=6 " number of characters from right side to begin wrap
set wrapscan " search around end of file
" When editing a file, always jump to the last cursor position
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal! g'\"" | endif
endif
|
other settings:
http://www.google.com/search?q=.vimrc
Enhance your command line using bash shell
The file /etc/bash.bashrc contains global command line options
The file /root/.bashrc and /home/users/<user>/.bashrc contains shell options per user which overwrite changes in /etc/bash.bashrc
Bash completion allows for completion of file paths, commands, etc
1
|
aptitude install bash-completion
|
Make /etc/bash.bashrc global
Add to the bottom (yes that is a leading period; it means include aka source)
Add bash completion for all users (using bash)
Uncomment the lines
1
2
3
4
|
# enable bash completion in interactive shells
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
|
Logout/login or source the config file
1
|
source /etc/bash.bashrc
|
Type a command and press tab to get a list of available options
Type a command and press tab to complete file paths
Add Date And Time To Bash History file
Add to the bottom
1
2
3
4
5
6
|
export HISTTIMEFORMAT='%F %T ' # time entry for .bash_history
export HISTCONTROL=ignoredups # eliminate continuous occurrences duplicates
export HISTSIZE=7000
shopt -s histappend # append to history, don.t overwrite it
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -r; $PROMPT_COMMAND"
|
Logout/login or source the config file
1
|
source /etc/bash.bashrc
|
To list previous commands
To execute a command in history list, say line 20
To view history
reference: http://www.debianadmin.com/how-to-add-date-and-time-to-your-bash-history-file.html
Add some color to file listing to make identifying files/dirs easier via ls
Add to the bottom
1
2
3
4
5
6
7
8
9
10
11
|
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
|
Logout/login or source the config file
1
|
source /etc/bash.bashrc
|
Change the default prompt to provide more information
1
|
PS1="${debian_chroot:+($debian_chroot)}\[\e]2;\u@\H \w\a\e[32;1m\](\u)[\w]\$\[\e[0m\] "
|
Logout/login or source the config file
1
|
source /etc/bash.bashrc
|
reference: http://www.gentoo.org/doc/en/articles/prompt-magic.xml
Changing the default message of the day with Debian 5 Lenny.
Useful if you users log into multiple machines during the day.
1
2
3
4
5
6
7
8
|
Linux debian 2.6.26-1-686 #1 SMP Sat Jan 10 18:29:31 UTC 2009 i686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
|
Remove or add what you want
Reboot for the change to take effect
reference: http://www.electrictoolbox.com/changing-default-motd-debian-lenny/
Search for files quickly by name
1
|
aptitude install mlocate
|
Update locates database of files (run daily by cron)
Search for a file
1
2
3
4
5
6
7
8
|
locate bashrc
/etc/bash.bashrc
/etc/skel/.bashrc
/root/.bashrc
/usr/share/base-files/dot.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/bash.bashrc
/usr/share/doc/adduser/examples/adduser.local.conf.examples/skel/dot.bashrc
|
The "– MARK –" in Debian log file /var/log/syslog
The tick "- MARK -" can be (somewhat) useful on a server to indicate that syslog is still working and to make scrolling through the syslog visually easier.
1
|
vi /etc/default/syslogd
|
Reduce the "- MARK -" to every 60 minutes instead of the default 20 minutes
Change 60 to 0 to disable the tick
Restart syslogd
1
|
invoke-rc.d sysklogd restart
|
Other useful command line aka terminal commands
https://help.ubuntu.com/community/UsingTheTerminal
files changed:
1
2
3
4
5
|
/etc/vim/vimrc
/etc/bash.bashrc
/etc/profile
/etc/motd.tail
/etc/default/syslogd
|
10