source: http://cb.vu/unixtoolbox.xhtml
http://sleepyhead.de
Unix Toolbox
This document is a collection of Unix/Linux/BSD commands and tasks which are useful for IT work or for advanced users. This is a practical guide with concise explanations, however the reader is supposed to know what s/he is doing.
Unix Toolbox revision 14.2
The latest version of this document can be found at http://cb.vu/unixtoolbox.xhtml. Replace .xhtml on the link with .pdf for the PDF version and with .book.pdf for the booklet version. On a duplex printer the booklet will create a small book ready to bind. This XHTML page can be converted into a nice PDF document with a CSS3 compliant application (see the script example). See also the about page.
Error reports and comments are most welcome - c@cb.vu Colin Barschel.
© Colin Barschel 2007-2009. Some rights reserved under Creative Commons.
System
Hardware | Statistics | Users | Limits | Runlevels | root password | Compile kernel | Repair grub
Running kernel and system information
# uname -a # Get the kernel version (and BSD version)
# lsb_release -a # Full release info of any LSB distribution
# cat /etc/SuSE-release # Get SuSE version
# cat /etc/debian_version # Get Debian version
четверг, 20 мая 2010 г.
среда, 19 мая 2010 г.
GNU Midnight Commander
GNU Midnight Commander User's Guide
M-a copy pwd to command line
- http://www.chm.tu-dresden.de/edv/mc/mc4.5/manual1.html#8
- M-o
- If the other panel is a listing panel and you are standing on a directory in the current panel, then the other panel contents are set to the contents of the currently selected directory (like Emacs' dired C-o key) otherwise the other panel contents are set to the parent dir of the current dir.
M-a copy pwd to command line
четверг, 13 мая 2010 г.
Best Vim Tips
http://vim.wikia.com/wiki/Best_Vim_Tips
Ctrl+X Ctrl+F = insert filename in current dir
C^+N = autocomplite word
C^r+" or C^r+ = paste in edit mode or to command line/search
C^x+C^l = autocomplite line
~/.vimrc
:%s/fred/joe/igc : general substitute command
:%s/\r//g : delete DOS Carriage Returns (^M)
:'a,'bg/fred/s/dick/joe/gc : VERY USEFUL
:s/\(.*\):\(.*\)/\2 : \1/ : reverse fields separated by :
# non-greedy matching \{-}
:%s/^.\{-}pdf/new.pdf/ : to first pdf)
:s/fred/a/g : substitute "fred" with contents of register "a"
CTRL-R CTRL-W : pull word under the cursor into a command line or search
:%s/^\(.*\)\n\1/\1$/ : delete duplicate lines
:help /\{-}
# multiple commands
:%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/
:%s/suck\|buck/loopy/gc : ORing
:s/__date__/\=strftime("%c")/ : insert datestring
Ctrl+X Ctrl+F = insert filename in current dir
C^+N = autocomplite word
C^r+" or C^r+
C^x+C^l = autocomplite line
~/.vimrc
set number set expandtab
set textwidth=79
set tabstop=8
set softtabstop=4
set shiftwidth=4
set autoindentsyntax onhttp://stackoverflow.com/questions/164847/what-is-in-your-vimrc :%s/fred/joe/igc : general substitute command
:%s/\r//g : delete DOS Carriage Returns (^M)
:'a,'bg/fred/s/dick/joe/gc : VERY USEFUL
:s/\(.*\):\(.*\)/\2 : \1/ : reverse fields separated by :
# non-greedy matching \{-}
:%s/^.\{-}pdf/new.pdf/ : to first pdf)
:s/fred/
CTRL-R CTRL-W : pull word under the cursor into a command line or search
:help /\{-}
# multiple commands
:%s/\f\+\.gif\>/\r&\r/g | v/\.gif$/d | %s/gif/jpg/
:%s/suck\|buck/loopy/gc : ORing
:s/__date__/\=strftime("%c")/ : insert datestring
bash sed recursive replace in all files
- find ./ -type f -exec sed -i ’s/string1/string2/g’ {} \;
- find ./ -type f | xargs sed -i ’s/string1/string2/g’
- grep -rl matchstring somedir/ | xargs sed -i ’s/string1/string2/g’
- grep -rl matchstring somedir/ | xargs sed -i ’s|string1|string2|g’
- sed -i ’s/oldText/newText/g’ `grep -ril ‘oldText’ *`
- rpl -x’.cpp’ -x’.h’ -pR “old-string” “new-string” *
find . -type f -print0 | xargs -0 perl -i.bak -pe 's/subdomainA\.example\.com/subdomainB.example.com/g'
s//g - g on the end will replace globally – all instances of string1
пятница, 30 апреля 2010 г.
mp3 id3 tag convert to utf8
http://wiki.linuxmce.org/index.php/Converting_MP3_Tags_To_UTF-8
mid3iconv
Utility mid3iconv is a part of Python-mutagen package. It is a tool which can do mass conversion of mp3 files. You can install python-mutagen from the universe repository:
sudo apt-get install python-mutagen
Convert MP3 Tags using mid3iconv
find . -name "*.mp3" -print0 | xargs -0 mid3iconv -e CP1251 -d
mid3iconv
Utility mid3iconv is a part of Python-mutagen package. It is a tool which can do mass conversion of mp3 files. You can install python-mutagen from the universe repository:
sudo apt-get install python-mutagen
Convert MP3 Tags using mid3iconv
find . -name "*.mp3" -print0 | xargs -0 mid3iconv -e CP1251 -d
суббота, 10 апреля 2010 г.
php header
http://www.jonasjohn.de/snippets/php/headers.htm
// See related links for more status codes
// Use this header instruction to fix 404 headers
// produced by url rewriting...
header('HTTP/1.1 200 OK');
// Page was not found:
header('HTTP/1.1 404 Not Found');
// Access forbidden:
header('HTTP/1.1 403 Forbidden');
// The page moved permanently should be used for
// all redrictions, because search engines know
// what's going on and can easily update their urls.
header('HTTP/1.1 301 Moved Permanently');
// Server error
header('HTTP/1.1 500 Internal Server Error');
// Redirect to a new location:
header('Location: http://www.example.org/');
// Redriect with a delay:
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
// you can also use the HTML syntax:
// < meta equiv="refresh" content="" >
// override X-Powered-By value
header('X-Powered-By: PHP/4.4.0');
header('X-Powered-By: Brain/0.6b');
// content language (en = English)
header('Content-language: en');
// last modified (good for caching)
$time = time() - 60; // or filemtime($fn), etc
header('Last-Modified: '.gmdate('D, d M Y H:i:s', $time).' GMT');
// header for telling the browser that the content
// did not get changed
header('HTTP/1.1 304 Not Modified');
// set content length (good for caching):
header('Content-Length: 1234');
// Headers for an download:
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="example.zip"');
header('Content-Transfer-Encoding: binary');
// load the file to send:
readfile('example.zip');
// Disable caching of the current document:
header('Cache-Control: no-cache, no-store, max-age=0, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Pragma: no-cache');
// set content type:
header('Content-Type: text/html; charset=iso-8859-1');
header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/plain'); // plain text file
header('Content-Type: image/jpeg'); // JPG picture
header('Content-Type: application/zip'); // ZIP file
header('Content-Type: application/pdf'); // PDF file
header('Content-Type: audio/mpeg'); // Audio MPEG (MP3,...) file
header('Content-Type: application/x-shockwave-flash'); // Flash animation
// show sign in box
header('HTTP/1.1 401 Unauthorized');
header('WWW-Authenticate: Basic realm="Top Secret"');
print 'Text that will be displayed if the user hits cancel or ';
print 'enters wrong login data';
четверг, 8 апреля 2010 г.
задачи в Помидорах
помидорное планирования:
http://lifehacker.ru/2009/06/09/izmerjajjte-zadachi-v-pomidorah-ehffektivnoe-planirovanie-proshhe-chem-vy-dumaete/
- Каждый Помидор состоит из 25 минут работы и пяти минут отдыха
- После каждых четырех Помидоров следует 15-30 минутный отдых
- Помидор неделим. Не существует половины помидора.
- Если Помидор начался — он должен прозвенеть.
- Если вам пришлось прервать работу не предусмотренным образом, Помидор должен быть заведен с начала. Такой помидор не учитывается (крестик не ставится).
- Если вы закончили задачу до того как Помидор прозвенел, следует анализировать как и что вы только что сделали до звонка.
- Защищайте свои Помидоры. Переносите звонки, назначайте встречи на другое время (и выделяйте на это Помидоры). Вы не должны давать резать ваш Помидор. Он неделим.
- Любую задачу длиннее 5-7 Помидоров следует разделить на несколько.
- Если задача явно займет меньше времени — объедините ее с подобными же и потратьте один Помидор на все вместе.
- Каждый следующий Помидор пойдет лучше!
http://lifehacker.ru/2009/06/09/izmerjajjte-zadachi-v-pomidorah-ehffektivnoe-planirovanie-proshhe-chem-vy-dumaete/
Подписаться на:
Сообщения (Atom)