http://www.binarytides.com/linux-commands-hardware-info/
https://habrahabr.ru/company/mailru/blog/330782/ Linux admin lectures (rus)
http://entrproject.org/ do something when file changes
http://www.opennet.ru/tips/sml/58.shtml
https://sysdig.com/blog/linux-troubleshooting-cheatsheet/
https://habrahabr.ru/post/281601/
http://www.etalabs.net/compare_libcs.html
https://news.ycombinator.com/item?id=12327905 Parallel zip
https://leemendelowitz.github.io/blog/remove-carriage-return-control-character.html
tr '\r' '\n' < input > output
How to install packages in linux
https://habrahabr.ru/post/321468/
SIGNALS
http://www.linuxprogrammingblog.com/all-about-linux-signals?page=show
http://www.crankyotaku.com/2016/03/linux-programming-signal-basics.html
http://www.linuxvoice.com/core-technology-signals/
https://news.ycombinator.com/item?id=10919277
http://www.cons.org/cracauer/sigint.html
http://habrahabr.ru/company/ua-hosting/blog/273201/ setup VNC server
Books
Advanced Programming in the UNIX Environment (3rd Edition) (Addison-Wesley)
http://eli.thegreenplace.net/2012/08/13/how-statically-linked-programs-run-on-linux
http://littleosbook.github.io/book.pdf
http://0xax.gitbooks.io/linux-insides/
http://lwn.net/Articles/630727/ how program starts
https://idea.popcount.org/2012-12-11-linux-process-states/
http://sysdigcloud.com/fascinating-world-linux-system-calls/
http://habrahabr.ru/post/253811/ malloc mmap sbrk
https://logtrust.atlassian.net/wiki/display/LD/File+monitoring+via+rsyslog
http://www.digilife.be/quickreferences/qrc/linux%20system%20call%20quick%20reference.pdf
http://www.advancedlinuxprogramming.com/alp-folder/
http://blog.petersobot.com/pipes-and-filters
http://man7.org/tlpi/index.html
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Developer_Guide/
http://www.linuxbase.org/betaspecs/fhs/fhs/index.html
http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/
TMPFS
to get 2Gb of space for files in RAM, edit /etc/fstab to add the following line:
tmpfs /var/ramspace tmpfs defaults,size=2048M 0 0
/var/ramspace is now the place to store your files in memory.
CRON
http://thaweatherman.pythonanywhere.com/ CRON STRING BUILDER
http://www.cronchecker.net/
http://unixwiz.net/tools/lockrun.html
https://github.com/zomo/cronwrap
https://news.ycombinator.com/item?id=10402221
http://dev-random.net/linux-lockfile-explained-how-to-use-them-the-easy-or-hard-way/
Process supervisor
https://en.wikipedia.org/wiki/Process_supervision
http://www.gnu.org.ua/software/pies/ PIES vs python's
https://pypi.python.org/pypi/supervisor
http://jtimberman.housepub.org/blog/2012/12/29/process-supervision-solved-problem/
http://lwn.net/Articles/604287/ Anatomy of system call
Administration:
http://www.ibm.com/developerworks/linux/library/l-customize-monitor-linux/
http://habrahabr.ru/company/centosadmin/blog/235131/
http://www.openlogic.com/wazi/bid/323631/Yum-tips-for-taking-charge-of-package-management-in-CentOS
http://www.openlogic.com/wazi/bid/250674/An-introduction-to-the-Linux-Logical-Volume-Manager
http://www.openlogic.com/wazi/bid/324755/Manage-Linux-services-with-Webmin
http://www.centos.org/docs/5/html/Deployment_Guide-en-US/ch-proc.html
service network restart
ls /proc/partitions
http://www.jovicailic.org/2012/10/how-to-install-lamp-apache-mysql-and-php-on-centos/
http://www.jovicailic.org/2012/07/how-to-enable-general-query-log-in-mysql-under-linux/
Open ports
lsof -i -P | grep -i listen
Python 54746 mlubinsky 3u IPv4 0xea9aea308f54ba1 0t0 TCP *:5000 (LISTEN)
RAID
http://habrahabr.ru/post/212269/ RAID
http://habrahabr.ru/post/212443/ RAID
http://habrahabr.ru/post/199532/
http://habrahabr.ru/post/168981/
http://habrahabr.ru/post/182786/ install RedHat without installator
http://habrahabr.ru/post/166019/ links
http://linux.die.net/man/5/proc
http://habrahabr.ru/post/186944/ System Monitor C++
http://0xc0dec.org/2011/06/16/cpp_linux_cpu_load/ C++
http://www.pixelbeat.org/cmdline.html
http://cb.vu/unixtoolbox.xhtml
http://www.linuxfromscratch.org/lfs/downloads/stable/LFS-BOOK-7.1-NOCHUNKS.html
http://www.ibm.com/developerworks/ru/library/l-lpic1-v3-101-2/index.html Linux boot process
http://www.ibm.com/developerworks/ru/library/l-lpic1-v3-104-7/index.html File system
structure
https://blogs.oracle.com/ksplice/entry/solving_problems_with_proc
http://www.advancedlinuxprogramming.com/
http://blog.sanctum.geek.nz/series/unix-as-ide/
http://www.ibm.com/developerworks/aix/library/au-unixtext/index.html
http://www.thegeekstuff.com/2010/09/linux-file-system-structure/
http://www.linuxprogrammingblog.com/blog
UNIX programming: RPC, pthreads
http://www.cs.cf.ac.uk/Dave/C/
http://habrahabr.ru/company/ideco/blog/145883/
SIGNALS
http://www.linuxprogrammingblog.com/all-about-linux-signals?page=11 SIGNALS
http://thisismiller.github.io/blog/CPython-Signal-Handling/
http://ph7spot.com/musings/introduction-to-unix-signals-and-system-calls
http://www.thegeekstuff.com/2012/03/catch-signals-sample-c-code/
http://pubs.opengroup.org/onlinepubs/009696899/functions/xsh_chap02_04.html#tag_02_04
http://www.reddit.com/r/cpp/comments/1dysmp/is_it_possible_to_stop_a_program_from_the_command/
http://www.linuxprogrammingblog.com/all-about-linux-signals
http://habrahabr.ru/post/141206/
Generally, you should use kill -15 before kill -9 to give the target process a chance to clean up after itself. (Processes can't catch or ignore SIGKILL, but they can and often do catchSIGTERM.) If you don't give the process a chance to finish what it's doing and clean up, it may leave corrupted files (or other state) around that it won't be able to understand once restarted.
http://unix.stackexchange.com/questions/8916/when-should-i-not-kill-9-a-process
kill -0 <pid> to test if a process is alive.
https://news.ycombinator.com/item?id=7135325
get current IP address
from command line:
curl ifconfig.me
http://ru-linux.livejournal.com/2614694.html screen
^z
bg
disown -a
PIPES
http://www.crankyotaku.com/2016/04/linux-programming-basics-of-pipes.html
If nobody is reading from pipe, you will eventually fill the pipe buffer (which is about 64k), and the writing will stop. It's a bigger queue than most of us would expect when compared to generator expressions, but it can and does create back pressure while making reads efficient.
Anybody know of a way to increase the buffer size of pipes? I've experienced cases where piping a really fast program to a slow one caused them both to go slower as the OS pauses first program writing when pipe buffer is full. This seemed to ruin the caching for the first program and caused them both to be slower even though normally pipes are faster as you're not touching disk.
Both mbuffer and pv by default contain fairly large in-memory buffers for pipe data, and accept parameters for particularly large buffers.
suspend the process with ctl-Z.
background with bg.
disown -h %1.
disown - bash built in.
You know how you always start that mega long rsync in an ssh session from your laptop and then realize you have to go offline halfway through? You forgot to start it in screen or nohup, didn't you? You can pause it (ctrl+z), background it (bg), and then disown it so it is protected from SIGHUP when you quit your ssh session. Bash (and, to be fair, zsh and others have copied much of this) has some wonderful job control features most people are completely oblivious of - even veterans of 20 years. Check this page out for more
http://vincebuffalo.com/2013/08/08/the-mighty-named-pipe.html
http://www.unixwiz.net/techtips/remap-pipe-fds.html
http://blog.petersobot.com/pipes-and-filters
https://news.ycombinator.com/item?id=6517847
DNS http://coding.smashingmagazine.com/2011/05/25/introduction-to-dns-explaining-the-dreaded-dns-delay/
ifconfig (on Windows: ipconfig/all )
IP address: hostname -i
cat /etc/resolv.conf
pipe into browser
http://habrahabr.ru/post/147525/
SUSE
http://www.cyberciti.biz/faq/novell-sles-suse-installing-software-packages-rpm-files/
*.noarch.rpm means that the package will work on any architecture
http://www.linuxtopia.org/online_books/opensuse_guides/opensuse11.1_reference_guide/
http://doc.opensuse.org/products/draft/SLES/SLES-admin_sd_draft/cha.sw_cl.html
zypper up (update all)
zypper in packagename (install)
zypper se packagename (search)
zypper sl (list repos)
zypper lr
zypper addrepo --help
$ ls -l /etc/zypp/repos.d/ -- list of repos
$ cat /etc/zypp/repos.d/SLES11-SP1-Updates.repo
[SLES11-SP1-Updates]
name=SLES11-SP1-Updates
enabled=0
autorefresh=0
baseurl=http://repo:50000/repo/in/SLES11-SP1-Updates/sle-11-x86_64/
type=NONE
keeppackages=0
$ cat /etc/zypp/repos.d/GIT.repo
[GIT]
name=GIT
enabled=1
autorefresh=0
baseurl=http://download.opensuse.org/repositories/devel:/tools:/scm/SLE_11_SP1/
type=rpm-md
priority=80
keeppackages=0
SUDO versus SU
http://superuser.com/questions/29/whats-the-difference-between-the-commands-su-s-and-sudo-s
https://www.linux.com/learn/tutorials/567884-start-fine-tuning-sudo-on-linux
/etc/sudoers
sudo - username
sudo su
sudo -s
sudo -i
To run a single command as the root user with su
su -c 'command'
This is similar to running a command with sudo, but you’ll need the root account’s password instead of your current user account’s password.
http://simiancreased.wordpress.com/2010/06/18/linux-command-sudo-vs-su/
http://superuser.com/questions/29/whats-the-difference-between-the-commands-su-s-and-sudo-s
you can use "su" to switch to any user account.
Unlike su, sudo changes your permissions for only a single command.
Very significant use for sudo is to enable ordinary users to execute commands that normally require root privileges without knowing the root password. sudo can be configured to allow certain people or groups to execute certain commands. With proper use it is possible to create users that have much more power than normal users and much less power than root.
SUDO
sudo -s su -
/etc/sudoers
mike ALL=(ALL) NOPASSWD: ALL
joe ALL=NOPASSWD:/usr/sbin/unshare /var/data/reports
If joe uses the share or unshare command for the /var/data/reports directory, he will not be prompted for a password, but for any other directory, he will both be asked for a password and be denied.
Find Linux version
cat /etc/issue
cat /etc/*-release
SUSE Linux Enterprise Server 11 (x86_64)
VERSION = 11
PATCHLEVEL = 1
LSB_VERSION="core-2.0-noarch:core-3.2-noarch:core-4.0-noarch:core-2.0-x86_64:core-3.2-x86_64:core-4.0-x86_64"
Setting development environment
http://www.youtube.com/watch?v=eagC7PcGcCk&feature=youtu.be
http://reinout.vanrees.org/weblog/2012/02/15/laptop-automation.html
https://github.com/ttsiodras/dotvim
BEST SMALL LINUX TIPS
http://www.quora.com/Linux/What-are-some-time-saving-tips-that-every-Linux-user-should-know
http://techblog.rosedu.org/making-your-shell-life-easier.html
http://www.reddit.com/r/linux/comments/mi80x/give_me_that_one_command_you_wish_you_knew_years/
http://news.ycombinator.com/item?id=3257393
http://www.commandlinefu.com/commands/browse/sort-by-votes
http://shebang.brandonmintern.com/tips-for-remote-unix-work-ssh-screen-and-vnc
http://www.die.net/ Linux man pages
http://iportnov.blogspot.com/2011/10/gnulinux.html
http://www.linuxjournal.com/content/readers-choice-awards-2010
http://www.iakovlev.org Linix programming books
http://lbrandy.com/blog/2010/11/memory-mapped-io-for-fun-and-profit/
INSTALL PACKAGES
yast -l
rpm -qa получение софтовых пакетов установленных на машину
yast -i sysstat
#!/bin/bash mfree=`grep MemFree /proc/meminfo | awk '{print $2}'` mcach=`grep ^Cached /proc/meminfo | awk '{print $2}'` lavg1=`awk '{print $1}' < /proc/loadavg` lavg15=`awk '{print $3}' < /proc/loadavg`
Apache
yast2 > network services > HTTP server
¦Document Root ¦"/srv/www/htdocs"
¦Directory ¦"/srv/www/htdocs"...
¦Alias ¦/icons/ "/usr/share/apache2/icons/"
¦Directory ¦"/usr/share/apache2/icons"...
¦ScriptAlias ¦/cgi-bin/ "/srv/www/cgi-bin/"
¦Directory ¦"/srv/www/cgi-bin"...
¦mod_userdir.c ¦
¦Include ¦/etc/apache2/conf.d/*.conf
¦Include ¦/etc/apache2/conf.d/apache2-manual?conf
¦Server Name ¦coenewdb02
¦Server Administrator E-Mail¦root@coenewdb02
coenewdb02 in "/srv/www/htdocs", SSL disabled
vi /etc/apache2/listen.conf
#Listen 80
#Listen 443 - for https
Listen 0.0.0.0:8080
/etc/init.d/apache2 restart
cat /srv/www/htdocs/index.html <-homepage http://ls9306.wdf.sap.corp:8080/
ls -l /var/log/apache2/
total 24
-rw-r--r-- 1 root root 4376 2012-06-03 09:43 access_log
-rw-r--r-- 1 root root 8490 2012-06-03 09:43 error_log
-rw-r--r-- 1 root root 10 2012-06-03 09:43 rcapache2.out
For RedHat or Suse installation, the web server document root will be assumed
to be either /var/www/html or /srv/www/htdocs respectively
NFS
http://www.troubleshooters.com/linux/nfs.htm
http://knowledge76.com/index.php/NFS_How_To_Mount_Shares
On server:
Step #1) Start NFS and RPC services
/etc/init.d/nfsserver start
/etc/init.d/rpcbind start
Verifying that NFS is running: rpcinfo -p
Step#2) Add lines to /etc/exports
shared_local_folder_here IP_here(rw,no_root_squash) another_IP_here(rw,no_root_squash)
Step #3) Execute
exportfs -ra
There are files /etc/hosts.allow and /etc/hosts.deny
On client
Step #1) add into /etc/fstab
server_here:/shared_folder_here /local_folder nfs hard,intr,timeo=600,nolock,proto=tcp,rsize=32768,wsize=32768 0 0
Step #2) Execute
mount -a
If does not work look in /var/log/messages
For temporary mount use this command:
mount server_here:/shared_foder_here /local_folder_here
Automounter
http://linux.die.net/man/5/autofs
http://docs.oracle.com/cd/E19455-01/806-0916/6ja8539g7/index.html
cat /etc/auto.master
-------------------------
/net /etc/mount.map --timeout 60 nolock
/area51 /etc/mount.area51.map --timeout 60
/etc/mount.map
/etc/mount.area51.map
service autofs restart
/etc/init.d/autofs restart
mounting ISO disk
mount -o loop my.iso /mnt/disk
umount /mnt/disk
df -h
mount
shutdown -ry 0
switch terminal with CTRL+ALT+F2
back to graphical Alt+F7
echo $DISPLAY
export DISPLAY =:0.0
xhost +
access control disabled, client can connect from any host
How to make каталог, находящийся в оперативной памяти.
Разумеется, данные стираются при перезагрузке, но для временного хранения файлов,
к которым необходим быстрый доступ (и на чтение, и на запись), решение отличное
mkdir /mnt/tmpfs
mount -t tmpfs -o size=1G /mnt/tmpfs/
df -h /mnt/tmpfs
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.0G 0 1.0G 0% /mnt/tmpfs
http://sourceforge.net/projects/console/ Tabs in Windows console
X11 tiling windows managers:
http://adereth.github.io/blog/2013/10/02/why-you-should-try-a-tiling-window-manager/
http://www.nongnu.org/stumpwm/index.html
http://habrahabr.ru/blogs/linux/134800/#habracut
http://en.wikipedia.org/wiki/Tiling_window_manager
disown vs nohup vs screen
http://blog.ksplice.com/2011/03/disown-zombie-children-and-the-uninterruptible-sleep/
http://blogs.fruxant.com/sebas/sebas.php/2010/05/20/ubuntu_how_to_leave_a_program_running_af
http://superuser.com/questions/96660/how-can-i-keep-a-process-alive-after-closing-the-putty-session
http://serverfault.com/questions/24425/can-i-nohup-screen-an-already-started-process
Hardware info
hwinfo - it is better then lspci, lsusb and freakin' everything else in this field.
cat /proc/cpuinfo
physical id : 0
core id : 1
cpu cores : 2
If you have two CPUs in cpuinfo with the same physical id and core id, than – hallo, hyperthreading! When you have all CPUs with different physical ids, than you have SMP, and when you have CPUs with one physical id and different core ids – you have one multicore CPU.
grep “physical id” /proc/cpuinfo |sort -u|wc -l #number of processors
mpstat
Количество физических процессоров
grep 'physical id' /proc/cpuinfo | sort -u | wc -l
Количиство Ядер в каждом из процесоров
grep 'core id' /proc/cpuinfo | sort -u | wc -l
getconf -a
man getconf
getconf _NPROCESSORS_ONLN;
VNC
vncserver –geometry 1200x1000 :8
You will require a password to access your desktops.
Would you like to enter a view-only password (y/n)? n
xauth: creating new authority file /root/.Xauthority
New 'X' desktop is coe-he-81:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/coe-he-81:1.log
On Windows there is RealVNC, TightVNC
http://shebang.brandonmintern.com/tips-for-remote-unix-work-ssh-screen-and-vnc
http://www.nomachine.com/ Client and Server
http://computingplugs.com/index.php/Installing_FreeNX_server_and_NX_Open_Source_Components
X stack explained
http://blog.mecheye.net/2012/06/the-linux-graphics-stack/
http://habrahabr.ru/post/148954/
Belkin KVM switch
http://synergy2.sourceforge.net/
SCP
scp [options] [[user@]host1:]filename1 ... [[user@]host2:]filename2
scp -r dvader@deathstar.com:somedir somedir
When using wildcards (e.g., * and ? ) to copy multiple files from a remote system, be sure to enclose the filenames in quotes. This is because the Unix shell, not the scp command, expands unquoted wildcards.
File descriptors: 1 for stdout, 2 for stderr, 0 for stdin
ls -al 1>file1.txt 2>file2.txt
Save the output to a file and at the same time echo everything to the screen:
ls -al | tee blah.txt
Redirect standard error to point to the same place as stdout and then we pipe the whole mess to tee in order to both save and echo at the same time:
ls -al 2>&1 | tee blah.txt
command 2>&1 > file # <---- do not use this http://en.wikipedia.org/wiki/Redirection_%28computing%29
command > file 2>&1 # use this
Soft and hard links
Hard links may not normally point to directories and they cannot link paths on different volumes. This has the effect of creating multiple names for the same file, causing an aliasing effect: if the file is opened by one of its names, and changes are made to its content, then these changes will also be visible when the file is opened by an alternative name.
By contrast, a soft link on such file systems is not a link to a file itself, but to a file name; this also creates aliasing, but in a different way.
An hard link refers directly to the physical location of another file (an inode to be precise).
A hard link has some limitations: it cannot refer to a directory and cannot cross file system boundaries. It means that you can only create hard links to the same file system where the hard link is located.
When the source of the link is moved or removed, the hard link still refer to the source.
Symbolic link are created with the ln command. For instance, to create a link to source_file:
A symbolic link refers to a symbolic path indicating the location of the source file. You can see it as a link to a path (itself refering to an inode).
A symbolic link is less limited. It can refer to a directory and can cross file system boundaries.
However, when the source of the link is moved or removed, the symbolic link is not updated.
Symbolic link are created with the ln command. For instance, to create a symbolic link to source_file:
The deletion of a link (hard or symbolic) can be achieved with the rm or unlink commands:
Hard Links : 1. All Links have same inode number. 2. ls -l command shows all the links with the link column (Second) shows No. of links. 3. Links have actual file contents 4.Removing any link just reduces the link count but doesn't affect other links.
http://ru-linux.livejournal.com/2878030.html#commentsSoft Links(Symbolic Links) : 1.Links have different inode numbers. 2. ls -l command shows all links with second column value 1 and the link points to original file. 3. Link has the path for original file and not the contents. 4.Removing soft link doesn't affect anything but removing original file the link becomes dangling link which points to non-existant file.
You can create hard links only for files and not for directories. A symbolic link merely contains a text string that is interpreted and followed by the operating system as a path to another file or directory.
It is a file on its own and can exist independently of its target. If a symbolic link is deleted, its target remains unaffected. If the target is moved, renamed or deleted, any symbolic link that used to point to it continues to exist but now points to a non-existing file.
Symbolic links pointing to non-existing files are sometimes called broken, orphaned, dead or dangling.
On many systems today, the ls command is aliased to ls --color=auto
Without color, you need more information, such as that provided by a long listing using ls -l
In the first column of output, you see the first character is an 'l' (lower-case L) for symbolic links
Using find to locate symlinks:
$ find foo -type l
Symlinks do not prevent a file from being deleted; if the target file is moved or deleted, then the symlink will be broken. For this reason, many systems use colors in directory listings, often pale blue for a good link and red for a broken one.
Soft links, or symlinks, merely point to another file or directory by name rather than by inode. Soft links can cross file system boundaries.
Deleting a soft link does not delete the target file or directory, and deleting the target file or directory does not automatically remove any soft links.
You will get an error if you attempt to create hard links that cross file systems or that are for directories.
You use the ln command with the -s option to create soft links. Soft links use file or directory names, which may be relative or absolute.
http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-104-6/index.html
Linking
http://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking/
http://lwn.net/Articles/276782/
http://habrahabr.ru/post/192264/
Дальше подключаются функции из libdl.so и поиск нужно библиотеки идет с учетом
строк в файле /etc/ld.so.conf, /etc/ld.so.preload, переменных LD_LIBRARY_PATH и
LD_PRELOAD и в кэше /etc/ld.so.cache, и некоторых других, зависящих от системы и glibc, условий.
Напомню, ld.so.cache формируется утилитой ldconfig, с учетом путей указанных в
/etc/ld.so.conf. Порядок обхода путей поиска совпадает с последовательностью,
указанной в этом файле.
LD_PRELOAD
http://jvns.ca/blog/2014/11/27/ld-preload-is-super-fun-and-easy/
http://www.catonmat.net/blog/simple-ld-preload-tutorial-part-2/
http://adamjsho.blogspot.co.uk/2013/11/subverting-library-calls-with-ldpreload.html
http://blog.mmalecki.com/2013/07/17/using-ld-preload.html
http://habrahabr.ru/post/199090/ LD_PRELOAD
http://news.ycombinator.com/item?id=4375493
http://www.linuxforu.com/2011/10/gnu-binutils-collection-of-binary-tools/http://zachsaw.blogspot.com/2012/10/gcc-linker-library-flag-order.html
http://shmat-razum.blogspot.com/2010/12/blog-post.html
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html
http://www.macieira.org/blog/2012/01/sorry-state-of-dynamic-libraries-on-linux/http://cseweb.ucsd.edu/~gbournou/CSE131/the_inside_story_on_shared_libraries_and_dynamic_loading.pdf
http://www.linuxforu.com/2011/12/loading-library-files-in-cpp/http://techblog.rosedu.org/library-management.html
http://www.lurklurk.org/linkers/linkers.html
http://habrahabr.ru/post/150327/
http://www.geeksforgeeks.org/working-with-shared-libraries-set-2/
http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-102-3/index.html
http://www.reddit.com/r/programming/comments/9367k/in_linux_whats_the_difference_between_an_object/
SHARED LIBRARIES:
http://blog.markloiseau.com/2013/01/linux-shared-object-tutorial/#more-1855
http://www.ibm.com/developerworks/linux/library/l-setup-sharedlibs-pr/index.html
http://amir.rachum.com/blog/2016/09/17/shared-libraries/
https://lwn.net/Articles/631631/
http://www.cyberciti.biz/tips/linux-shared-library-management.htmlhttp://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html
http://www.akkadia.org/drepper/dsohowto.pdf
Applications in Linux are linked to an external function in one of two ways: either statically linked at build time, with static libraries (lib*.a) and having the library code include in the application's executable file, or dynamically linked at runtime with shared libraries (lib*.so)
http://habrahabr.ru/blogs/cpp/132300/
Two types of executable programs:
- Statically linked executables contain all the library functions that they need to execute; all library functions are linked into the executable.
- Dynamically linked executables; ldd command shows the shared library dependencies
How does the dynamic loader know where to look for executables?
There is a configuration file in /etc. In fact, there are two configuration files, /etc/ld/so/conf and /etc/ld.so.cache. Older systems may have all entries in /etc/ld/so/conf and not include entries from the /etc/ld.so.conf.d directory.
The ldconfig command creates the necessary links and cache to recently used shared libraries in /etc/ld.so.cache.
The dynamic loader uses the cached information from ld.so.cache to locate files that are to be dynamically loaded and linked.
If you change ld.so.conf (or add new included files to ld.so.conf.d), you must run the ldconfig command (as root) to rebuild your ld.so.cache file.
If you're running an older application that needs a specific older version of a shared library, you might want to override the default search paths used by the loader.
Just as you can set the PATH variable to specify a search path for executables,
You can set the LD_LIBRARY_PATH variable to a colon-separated list of directories that should be searched for shared libraries before the system ones specified in ld.so.cache.
For example:
export LD_LIBRARY_PATH=/usr/lib/oldstuff:/opt/IBM/AgentController/lib
If you have a compelling reason to add a path to many programs, you can also change the system's default search path.
The dynamic linker is controlled through /etc/ld.so.conf, which contains a list of directories to search by default.
Any paths specified in LD_LIBRARY_PATH will be searched before the paths listed in ld.so.conf, so users can override these settings.
To prevent users (and programmers) from needing to track library numbers and updates, the system comes with a large number of symbolic links.
In general, the pattern is that libexample.so will be a link to libexample.so.N
For every major version number supported, libexample.so.N will be a link in turn to libexample.so.N.M
If you specify -lexample to the linker, it looks for libexample.so which is a symbolic link to a symbolic link to the most recent version.
In a traditional static library, the code generated is usually bound together into a library file with a name ending in .a and then it's passed to the linker.
In a dynamic library, the library file's name generally ends in .so.
A normal static library is in a format created by the ar utility, which is basically a very simple-minded archive program, similar to tar but simpler.
In contrast, shared libraries are generally stored in more complicated file formats.
When linking a program, you can specify additional paths to search at runtime. In gcc the syntax is -Wl,-R/path
You can use ldd to list all the dynamic link lib dependencies: ldd /path/to/your/app However this shows direct and indirect (i.e. those needed by other libraries) dependencies, so you can tell what are just the direct dependencies by using readelf: readelf -d /path/to/your/app The direct dependencies are the libraries listed as NEEDED. Linking to different versions of a dynamic library On Linux there's loads of [dynamic ".so"] libraries in places like /usr/lib. The libraries have version numbers; Major version indicates major (API) changes, whilst the minor version typically relates to bug fixes. These version numbers are firstly enshrined with the library using a special symbol (SONAME) - which is assigned on library creation (using the -soname arg to ld). Also libraries are named with their version numbers libsomething.so.2.3. You can verify this using: objdump -p libsomething.so.2.3* | grep SONAME So if you're developing and you want to link to specific version what do you do? Well basically there's no neat trick to get the linker (ld) to link a specific version at compile time :( so you can either: Link using the full path to the specific library version Create a softlink/symlink (ending in ".so" - with NO version) to the specific library version ldconfig does do some stuff related creating links for libraries but as explained here it won't create the plain ".so" necessary for development - these are usually included as part of a "dev" (usually suffixed by "-dev") package on your system (be it Debian or Red Hat or whatever).
Compiling 32-bit apps on 64-bit Linux
$ gcc -m32 hello.c -o hello
$ file hello
hello: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.8, not stripped
Programmers fonts:
Consolas:
1
1
2
1
ln source_file link
ln -s source_file link
rm link
unlink link
Linux Distributions
http://www.scientificlinux.org/ http://linuxmint.com/ http://distrowatch.com/
Linux under Windows: http://www.colinux.org/ http://wubi-installer.org/
http://www.linuxjournal.com/content/andlinux-seamlessly-run-linux-applications-windows
http://www.404techsupport.com/2010/08/25/multiboot-usb-simplifies-taking-your-it-toolbox-with-you/
$ mkdir ~/.fonts
$ (cd ~/.fonts && unzip ~/Downloads/Consolas\ font.zip && fc-cache)
http://fixedsys.moviecorner.de/?p=download2&l=1