Project „New Search Engine“
Linux - Commands
Before running of a program it is
necessary to add its pathname into the directory PATH (just C++?).
Clear memory caches
sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"
Disks, directories and files properties
df
ls –l directory/* | wc –l
du –s directory
Searching
phejl@ph-zfs0:~$ grep -r --max-count=1 -o "wedos.projects.mediafactory" /data/hledac/files/www_pages/*
Rename many files in directory
find . -name 'jsapi' -print0 | xargs -0 rename 's/jsapi/jsapi_2/
#!/bin/bash
for i in `find . -print | grep jsapi`; do mv $i ${i}_2; done
Replace text in many files in directory
for
file in $(grep -il "Hello" *.txt)
do
sed -e "s/Hello/Goodbye/ig" $file > /tmp/tempfile.tmp
mv /tmp/tempfile.tmp $file
done
for z in `find . -type f -name "*.html" -o -name "*.htm"`;
do
sed -e 's@abc@xyz@g' $z>temp;
mv temp $z && rm temp;
done
#!/bin/bash
for fl in `grep -rl xxx.xxx.xxx.xxx * | xargs`; do
echo $fl
mv $fl $fl.old
sed 's/xxx.xxx.xxx.xxx/xxx.xxx.xxx.xxx/g' $fl.old > $fl
rm -f $fl.old
done
Monitoring of system (load)
http://www.linuxzone.cz/modules/tisk_clanku-nw.phtml?ids=9&idc=279
Reboot
shutdown -r now
Write rights
chmod -R a+w,g+w,a+x jmeno_souboru_nebo_adresare
Batches Downloaders:
cd /home/phejl/mini/batches/batches_ubuntu_data/downloaders#
chmod a+x *.sh
Threads
http://www.zive.cz/clanky/poznavame-c-a-microsoft-net-48-dil--uvod-do-pouziti-vlaken/sc-3-a-127580/default.aspx
Bashes
Paralell running of commands or processes:
process1 & process2 & process3 &
read -p "Press Enter to continue "
sleep 1
echo This is comment (remark)
Run program using mono
mono-2.10 mono /home/phejl/mini/programs/c_sharp/linux/Fronter/Fronter /bin/Release/Fronter.exe
Links
http://www.google.cz/#hl=cs&xhr=t&q=linux+commands
http://www.computerhope.com/unix.htm#04
http://www.oreillynet.com/linux/cmd/
http://www.pixelbeat.org/cmdline.html
http://www.debianhelp.co.uk/commands.htm
http://www.linuxconfig.org/linux-commands
Names
Names of commands, directories, files etc. are case sensitive.
Password
passwd
Arrow up, arrow down
Movement in commands (previous, next)
sudo
Command to perform commands, also under other (system, root) identity.
update
sudo apt-get update
Directories, running of programs
/usr/bin/
/applications/programming/
/usr/lib/mono
/usr/lib/mono
/usr/lib/monodevelop/bin/monodevelop.exe
/opt
Which processes run
http://www.computerhope.com/unix/ups.htm
http://www.cyberciti.biz/faq/show-all-running-processes-in-linux/
ps
ps aux | less
pas aux | name
-A: select all processes
a: select all processes on a terminal, including those of other users
x: select processes without controlling tys
Task: see every process on the system
# ps -A
# ps -e
Task: See every process except those running as root
# ps -U root -u root -N
Task: See process run by user vivek
# ps -u vivek
Finds number of running process:
pidof name
Kill process
http://www.computerhope.com/unix/ukill.htm
http://linux.about.com/library/cmd/blcmdl_kill.htm
kill [-s] [-l] %pid
Unable to lock directory
http://www.google.cz/#sclient=psy&hl=cs&q=linux+error+could+not+get+lock+%2Fvar%2Fcache%2Fapt%2Farchives%2Flock
http://www.linuxquestions.org/questions/linux-software-2/var-cache-apt-archives-lock-error-457486/
See which process holds it:
lsof | grep "/var/cache/apt/archives/lock"
mkdir -p /var/cache/apt/archives/lock
touch /var/cache/apt/archives/lock
this helps:
sudo rm /var/cache/apt/archives/lock
Downloading
git
wget
Unpacking
tar
List file
cat name
Find
http://www.computerhope.com/unix/ufind.htm
find /usr/bin –name ‘mono’
find /usr/bin –name ‘mono*’
find /usr/bin –name ‘MonoDevelop.exe’
find /usr/bin –name ‘MonoDevelop.*’
Take care: names are case sensitive.
Copy
http://www.computerhope.com/unix/ucp.htm
sudo cp file1.txt nadir
Copies the file1.txt in the current directory to the newdir directory.
sudo cp /home/public_html/mylog.txt /home/public_html/backup/mylog.bak
Copies the mylog.txt file in the public_html directory into the public_html/backup directory as mylog.bak. The files are identical however have different names.
sudo cp *.txt nadir
Copy all files ending in .txt into the newdir directory.
sudo cp -r /home/hope/files/* /home/hope/backup
Delete (remove)
http://www.computerhope.com/unix/urmdir.htm
sudo rmdir directory
http://www.computerhope.com/unix/urm.htm
sudo rm –r -f directory
sudo rm –r -f file
Remove all in directory file without prompting.
Rename
http://www.computerhope.com/issues/ch000846.htm#3
http://linux.about.com/library/cmd/blcmdl1_rename.htm
http://www.oreillynet.com/linux/cmd/cmd.csp?path=r/rename
sudo rename from to where
sudo mv from where
renames, if my exists
Install
http://linux.about.com/library/cmd/blcmdl1_install.htm
install name -version
sudo apt-get install name
aptitude install name
Which version of Ubuntu?
lsb_release –a
sudo lsb_release –a
My version of Ubuntu
Release: 10.10
Codename: maverick
Gui
Install GNOME desktop:
sudo apt-get install ubuntu-desktop
If you wan to install a graphical desktop manager without some of the desktop addons like Evolution and OpenOffice, but continue to use the server flavor kernel use the following command
sudo aptitude install --no-install-recommends ubuntu-desktop
If you want to install light weight desktop install xfce using the following command
sudo apt-get install xubuntu-desktop
If you want to install KDE desktop use the following command
sudo apt-get install kubuntu-desktop
PATH
Setting
Initial setting in Uuntu by Mr. Panoch
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
Setting in Ubuntu according to Mr. Panoch, completed by mysem with directory for programs and files in mini directory (C++)
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
My additions:
/home/phejl/mini/programs:/home/phejl/mini/programs
/home/phejl/mini/programs:/home/phejl/mini/programs/c_sharp/Hlodacz/Hlodacz/bin/Debug
/opt/mono-2.8
PATH=/usr/bin:/bin:/usr/local/bin:/usr/X11R6/bin
from sh
PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:
from csh
setenv PATH /usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:
for bash shell
export PATH=$PATH:/usr/sbin/:/usr/local/bin
for tcsh or csh
set PATH = ($PATH /usr/sbin /usr/local/bin)
extension of PATH
PATH=$PATH:/home/phejl/mini/programs
initial petting from shell
export PATH=/home/foo
listing
echo PATH
Properties of programs and files
The file's executable bits still need to be set regardless of user, see manual pages for chmod for details
example:
chmod 777 program.bin
chmod 777 file.bin
sets rwx permissions for all users
chmod a+x program.bin
To see permissions
ls -l program.bin
ls -l file.bin
ls –all
which g++ - shows, in which directory the program is placed
c++, g++ programs are in directory: /usr/bin
g++ libraries are in: /usr/include/c++/4.4
vim – download and install
hg clone https://vim.googlecode.com/hg/vim
cd vim/src
make
mono – install
http://www.integratedwebsystems.com/2011/03/monodevelop-2-4-and-2-6-beta-install-script-for-ubuntu-fedora/
Mono
2.10 (instaluje to Mono 2.10.5)
sudo rmdir –r /usr/lib/mono-2.10
sudo mkdir /usr/lib/ mono-2.10
sudo cd /usr/lib/mono-2.10
sudp wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.10.sh
sudo chmod 755 install_mono-2.10.sh
sudo ./install_mono-2.10.sh
http://www.integratedwebsystems.com/2011/08/install-mono-2-10-3-on-ubuntu-using-bash-script/
sudo mkdir /usr/lib/mono-2.10
sudo cd mono-2.10
sudo wget
--no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.10.sh
sudo chmod 755
install_mono-2.10.sh
sudo bash install_mono-2.10.sh
http://www.integratedwebsystems.com/2011/01/mono-2-8-2-script-updated-for-ubuntu-and-fedora/
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.8.2.sh
chmod 755 install_mono-2.8.2.sh
./install_mono-2.8.2.sh
http://www.hbyconsultancy.com/blog/install-asp-net-3-5-environment-for-ubuntu-maverick-10-10.html
First we need to install the necessary packages :
$ sudo apt-get install monodevelop mono-devel monodevelop-database mono-debugger mono-xsp2 libapache2-mod-mono mono-apache-server2 apache2
The Apache mod_mono module is enabled after this by default, I just disable this and enable mod_mono_auto instead for Auto Configuration :
$ sudo a2dismod mod_mono
$ sudo a2enmod mod_mono_auto
Finally we’ll have to edit the mod_mono_auto.conf and add default locations :
$ sudo -b gedit /etc/apache2/mods-available/mod_mono_auto.conf
Then add in the end :
MonoPath default "/usr/lib/mono/3.5"
MonoServerPath default /usr/bin/mod-mono-server2
AddMonoApplications default "/:/var/www"
We restart Apache again
$ sudo /etc/init.d/apache2 restart
Now let’s create a simple hello world and give it a try :
$ sudo -b gedit /var/www/index.aspx
And enter the code below, or any other sample
<%@ Page Language="C#" %>
<html>
<head>
<title>Sample Calendar</title>
</head>
<asp:calendar showtitle="true" runat="server">
</asp:calendar>
Then fire your fox at http://localhost/index.aspx and you should see the default calendar, Easy ?
Mono 10.1. install:
https://github.com/nathanb/iws-snippets/tree/master/mono-install-scripts/ubuntu
https://github.com/nathanb/iws-snippets/blob/master/mono-install-scripts/ubuntu/install_mono-2.10.1.sh
See d:/mini/install/install_mono_2_10_1.sh
Mono - run
The command line way is "mono appfilename.exe". Or you could also
open it through the explorer, by left or right clicking the exe, depending on
your desktop type / settings. On Ubuntu Gnome, I used to do: right click / open
with / mono. You could also set Mono as the default program to run exe files.
If you want to start the exe without having to type mono
<applicationname> do: apt-get install binfmt-support.
A word of caution: This also enables wine applications to run without wine
<applicationname>.
Mono-2-10.1
mono-2.10 mono program
Pokorny Robin:
Pokud budete chtít z konzole něco pouštět přes mono 2.10.1 zadejte před příkaz mono-2.10, tedy např "mono-2.10 mono -V" Případně můžete zadat "source mono-2.10-environment" a vše se bude spouštět s mono 2.10.1.
Nepodařilo se mi to nastavit jako
mono-2.10.1, proto jsem vytvořil v /opt adresář se zálohou, kam jsem přesunul
původní obsah adresáře. Doufám, že to nevadí.
Nathan Bridgewater
mono-setup.sh:
#!/bin/bash
MONO_PREFIX=/opt/mono-2.10
GNOME_PREFIX=/usr
export DYLD_LIBRARY_FALLBACK_PATH=$MONO_PREFIX/lib:$DYLD_LIBRARY_FALLBACK_PATH
export LD_LIBRARY_PATH=$MONO_PREFIX/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=$MONO_PREFIX/include:$GNOME_PREFIX/include
export ACLOCAL_PATH=$MONO_PREFIX/share/aclocal
export PKG_CONFIG_PATH=$MONO_PREFIX/lib/pkgconfig:$GNOME_PREFIX/lib/pkgconfig
export PATH=$MONO_PREFIX/bin:$PATH
PS1="[mono] \w @ "
compile test:
7za x help.7z
cd help
source mono-setup.sh
cd test
make
mono bin/test.exe "weburl"
Monodevelop - install
http://www.howtogeek.com/howto/ubuntu/install-monodevelop-on-ubuntu-linux/
sudo apt-get install mono mono-gmcs mono-gac mono-utils monodevelop
monodoc-browser monodevelop-nunit monodevelop-versioncontrol
Asi fungují jen některé části z výše uvedeného.
http://www.howtogeek.com/howto/linux/installing-monodevelop-from-source-on-ubuntu/
sudo apt-get install mono-devel build-essential mono-gmcs libmono-dev libpango1.0-dev libgtk2.0-dev libgtksourceview2.0-cil libgecko2.0-cil monodoc libmono-system-runtime2.0-cil libmono-cairo2.0-cil gettext
Now you’ll want to download, extract and untar the latest source code into a directory of your choice. (You’ll want to make sure 0.16 is still the latest)
sudo wget http://go-mono.com/sources/monodevelop/monodevelop-0.16.tar.bz2
newer:
sudo wget http://ftp.novell.com/pub/mono/sources/monodevelop/monodevelop-2.4.tar.bz2
newest:
sudo wget http://ftp.novell.com/pub/mono/sources/monodevelop/monodevelop-2.5.90.tar.bz2
sudo bunzip2 monodevelop-2.5.90.tar.bz2
sudo tar xvf monodevelop-2.5.90.tar
cd monodevelop-2.5.90
Now we can start the compilation, and you’ll notice that the ./configure line passes in the prefix option so that it will install in the correct directory.
./configure –prefix=`pkg-config –variable=prefix mono`
make
sudo make install
At this point MonoDevelop should be installed. You can launch it with Alt+F2 by entering monodevelop into the run box.
$ git clone git@github.com:mono/monodevelop.git
If you don't have developer access, you can always use the read-only url:
$ git clone git://github.com/mono/monodevelop.git
Mono and Monodevelop install
http://www.linuxquestions.org/questions/linux-software-2/installing-monodevelop-787522/
See d:/mini/install/ install_mono_2_10_2_and_monodevelop_2_5_90.sh
.NET – install
sudo apt-get install .net
Install MonoDevelop 2.4.2 or 2.6 Beta on Ubuntu & Fedora:
http://www.integratedwebsystems.com/2011/03/monodevelop-2-4-and-2-6-beta-install-script-for-ubuntu-fedora/
Monodevelop 2.6.1 beta = 2.5.90
sudo rmdir –r /usr/lib/monodevelop-2.6
sudo mkdir /usr/lib/monodevelop-2.6
sudo cd /usr/lib/monodevelop-2.6
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_monodevelop-2.5.90.sh
chmod 755 install_monodevelop-2.5.90.sh
./install_monodevelop-2.5.90.sh
Monodevelop - run
Pokorny Robin:
Nastavení .NET Runtimes se mi přes konzoli nepovedlo,
nejspíš se musí nastavit přímo v aplikaci (Tools/Preferences/.NET Runtimes).
Přes dávku v NX – Places - /usr/lib/monodevelop-2.6/monodevelop_launcher.sh
File managers
mc
bsc
krusader
nautilus
Text editors
vim
gedit
logout
logout
help
help
manuál
man command
e.g.:
man chmod
Batches
extension: .sh
bash
sudo bash
shell
Remarks
To execute a
program,, the atribute "executable" must be set on.
Apache
/etc/init.d/apache2 start
/etc/init.d/apache2 stop
See also C++ - commands Linux.