30.01.2014 г.
Как да покажем системните параметри на linux от браузера.
Паврим файл кръстен index
#!/bin/bash
TITLE="System informatin for $HOSTNAME pc"
NOW=$(date +"%x %r %Z")
TIME_STAMP="Update on $NOW by $USER"
MOST_CPU="Most usage CPU process"
FREE_MEM="Pameta v momenta"
function show_uptime
{
echo "<h2>System uptime</h2>"
echo "<pre>"
uptime
echo
cat /etc/*release*
"</pre>"
}
function home_space
{
if [ "$(id -u)" = "0" ]; then
echo "<h2>Home Directory space by user</h2>"
echo "<pre>"
echo "Bytes Directory"
du -s /home/* | sort -nr
echo "</pre>"
fi
}
function most_cpu
{
ps -aux | head -n5
}
function freemem
{
free -m
}
###LOG
cat <<- _EOF_
<html>
<head>
<title>$TITLE</title>
<head>
<body>
<h1>$TITLE</h1>
<p>$TIME_STAMP</p>
$(show_uptime)
$(home_space)
<h1>$MOST_CPU</h1>
$(most_cpu)
<h1>$FREE_MEM</h1>
$(freemem)
</body>
</html>
_EOF_
2 Правим си файл: info.php
<DOCTYPT html>
<html>
<title>
<head>
</head>
<body>
<?php
$result=shell_exec("/var/www/index 2>&1");
echo ($result);
?>
</body>
<html>
Debian vi - > vim, конфигурационнен файл:
Debian vi - > vim, конфигурационнен файл:
apt-get install vim
nano ~/.bashrc - > alias vi = "vim"
vi /etc/vi/vimrc
" Use Vim settings
set nocompatible
fixdel
syntax enable
set ruler " displays the 'ruler' at the bottom-right of the screen
set number " precede each line with its line number.
set nowrap " no line wrapping;
set guioptions+=b " add a horizontal scrollbar to the bottom
"colorscheme zenburn
"--- search options ------------
set incsearch " show 'best match so far' as you type
set hlsearch " hilight the items found by the search
set ignorecase " ignores case of letters on searches
set smartcase " Override the 'ignorecase' option if the search pattern contains upper case characters
:highlight search guifg=yellow guibg=darkred
"--- indentation ---------------
set expandtab
set smarttab
set smartindent " smart indent of code - indent after opening '{',
"set autoindent " Copy indent from current line when starting a new line
set shiftwidth=4 " Number of spaces to use for each step of (auto)indent (used for the >>, << commands)
set tabstop=4 " Number of spaces that a <Tab> in the file counts for.
set softtabstop=4 " Backspace the proper number of spaces
set shiftround " Round indent to multiple of 'shiftwidth'
" comments are not placed in the first column. They stay at their current indent level
inoremap # #
"--- Keystrokes ----------------
" h and l wrap between lines, cursor keys wrap in insertion mode
set whichwrap=h,l,~,[,]
" page down with <SPACE>, pageup with - or <BkSpc>
noremap <Space> <PageDown>
noremap <BS> <PageUp>
" allow <BkSpc> to delete line breaks, start of insertion, and indents
set backspace=eol,start,indent
"--- windowing -----------------
" be able to scroll through opened files easily with ctrl+j/k
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
set wmh=0 "set other opened files to just show filename
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full
"--- python formatting help ---
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
"-- always set cwd to current buffer ---
" * helps a lot with multiple windows
function! CHANGE_CURR_DIR()
let _dir = expand("%:p:h")
exec "cd " . _dir
unlet _dir
endfunction
autocmd BufEnter * call CHANGE_CURR_DIR()
apt-get install vim
nano ~/.bashrc - > alias vi = "vim"
vi /etc/vi/vimrc
" Use Vim settings
set nocompatible
fixdel
syntax enable
set ruler " displays the 'ruler' at the bottom-right of the screen
set number " precede each line with its line number.
set nowrap " no line wrapping;
set guioptions+=b " add a horizontal scrollbar to the bottom
"colorscheme zenburn
"--- search options ------------
set incsearch " show 'best match so far' as you type
set hlsearch " hilight the items found by the search
set ignorecase " ignores case of letters on searches
set smartcase " Override the 'ignorecase' option if the search pattern contains upper case characters
:highlight search guifg=yellow guibg=darkred
"--- indentation ---------------
set expandtab
set smarttab
set smartindent " smart indent of code - indent after opening '{',
"set autoindent " Copy indent from current line when starting a new line
set shiftwidth=4 " Number of spaces to use for each step of (auto)indent (used for the >>, << commands)
set tabstop=4 " Number of spaces that a <Tab> in the file counts for.
set softtabstop=4 " Backspace the proper number of spaces
set shiftround " Round indent to multiple of 'shiftwidth'
" comments are not placed in the first column. They stay at their current indent level
inoremap # #
"--- Keystrokes ----------------
" h and l wrap between lines, cursor keys wrap in insertion mode
set whichwrap=h,l,~,[,]
" page down with <SPACE>, pageup with - or <BkSpc>
noremap <Space> <PageDown>
noremap <BS> <PageUp>
" allow <BkSpc> to delete line breaks, start of insertion, and indents
set backspace=eol,start,indent
"--- windowing -----------------
" be able to scroll through opened files easily with ctrl+j/k
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
set wmh=0 "set other opened files to just show filename
" have command-line completion <Tab> (for filenames, help topics, option names)
" first list the available options and complete the longest common part, then
" have further <Tab>s cycle through the possibilities:
set wildmode=list:longest,full
"--- python formatting help ---
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
"-- always set cwd to current buffer ---
" * helps a lot with multiple windows
function! CHANGE_CURR_DIR()
let _dir = expand("%:p:h")
exec "cd " . _dir
unlet _dir
endfunction
autocmd BufEnter * call CHANGE_CURR_DIR()
Компилиране на wine v 1.1.42, настройка на локалите
download wine 1.1.42
apt-get install bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev
sudo apt-get install lib32v4l-dev lib32ncurses5-dev lib32asound2-dev lib32z-dev ia32-libs-dev
./configure
make
make install
Ако не се чете правилно кирилицата на стартираната през wine програма:
LC_ALL=bg_BG.UTF-8 wine "C:\път_до_програмата\име.exe" или
LANG=bg_BG.CP1251 wine "C:\път_до_програмата\име.exe"
download wine 1.1.42
apt-get install bison flex gcc libc6-dev libfontconfig-dev libfreetype6-dev libglu-dev libgsm1-dev libice-dev libjpeg-dev libldap-dev libmpg123-dev libncurses5-dev libopenal-dev libpng-dev libsm-dev libssl-dev libusb-dev libx11-dev libxcomposite-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxml2-dev libxrandr-dev libxrender-dev libxslt-dev libxt-dev libxxf86vm-dev make libcapi20-dev liblcms-dev libsane-dev libhal-dev libdbus-1-dev valgrind prelink libcups2-dev
sudo apt-get install lib32v4l-dev lib32ncurses5-dev lib32asound2-dev lib32z-dev ia32-libs-dev
./configure
make
make install
Ако не се чете правилно кирилицата на стартираната през wine програма:
LC_ALL=bg_BG.UTF-8 wine "C:\път_до_програмата\име.exe" или
LANG=bg_BG.CP1251 wine "C:\път_до_програмата\име.exe"
Претърсва за най-често използваните команди в терминала от юзера, който изпълнява командата:
history | awk {print $2} | sort | uniq -c | sort -nr | head
print $2 - ще изпринти втората колона (първата е номера на командата).
sort - сортира записа, sort -nr - реверсивно сортиране
uniq -c - показва колко пъти е дадена командата
head - първите редове
history | awk {print $2} | sort | uniq -c | sort -nr | head
print $2 - ще изпринти втората колона (първата е номера на командата).
sort - сортира записа, sort -nr - реверсивно сортиране
uniq -c - показва колко пъти е дадена командата
head - първите редове
Абонамент за:
Публикации
(
Atom
)