This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
os:linux:tips [2020/06/28 17:58] admin created |
os:linux:tips [2020/08/10 23:07] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | Trucs, astuces et rappels livrés en vrac... | + | ====== Trucs & Astuces ====== |
+ | Ici, on trouve des trucs, des astuces et des rappels données en vrac...\\ | ||
**Si vous ne comprenez pas ce que vous faites, ne le faites pas ! | **Si vous ne comprenez pas ce que vous faites, ne le faites pas ! | ||
** | ** | ||
Line 8: | Line 9: | ||
To determine the values of the four described semaphore parameters, run: | To determine the values of the four described semaphore parameters, run: | ||
- | <code> | + | <sxh> |
# cat /proc/sys/kernel/sem | # cat /proc/sys/kernel/sem | ||
250 32000 32 128 | 250 32000 32 128 | ||
- | </code> | + | </sxh> |
These values represent SEMMSL, SEMMNS, SEMOPM, and SEMMNI. | These values represent SEMMSL, SEMMNS, SEMOPM, and SEMMNI. | ||
Alternatively, you can run: | Alternatively, you can run: | ||
- | <code> | + | <sxh> |
# ipcs -ls | # ipcs -ls | ||
- | </code> | + | </sxh> |
All four described semaphore parameters can be changed in the proc file system without reboot: | All four described semaphore parameters can be changed in the proc file system without reboot: | ||
- | <code> | + | <sxh> |
# echo 250 32000 100 128 > /proc/sys/kernel/sem | # echo 250 32000 100 128 > /proc/sys/kernel/sem | ||
- | </code> | + | </sxh> |
Alternatively, you can use sysctl(8) to change it: | Alternatively, you can use sysctl(8) to change it: | ||
- | <code> | + | <sxh> |
# sysctl -w kernel.sem="250 32000 100 128" | # sysctl -w kernel.sem="250 32000 100 128" | ||
- | </code> | + | </sxh> |
To make the change permanent, add or change the following line in the file **/etc/sysctl.conf**. This file is used during the boot process. | To make the change permanent, add or change the following line in the file **/etc/sysctl.conf**. This file is used during the boot process. | ||
- | <code> | + | <sxh> |
# echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf | # echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf | ||
- | </code> | + | </sxh> |
----- | ----- | ||
Line 39: | Line 40: | ||
Les imports sont réalisés au travers du service autofs \\ | Les imports sont réalisés au travers du service autofs \\ | ||
Le fichier /etc/auto.master a été configuré avec ajout de la ligne : | Le fichier /etc/auto.master a été configuré avec ajout de la ligne : | ||
- | <code>/import /etc/auto.import nfsvers=3 --timeout 5</code> | + | <sxh>/import /etc/auto.import nfsvers=3 --timeout 5</sxh> |
Un fichier /etc/auto.import definis les possibilités d'import : | Un fichier /etc/auto.import definis les possibilités d'import : | ||
- | <code> | + | <sxh> |
EPP -fstype=nfs,rw,udp,nosymlink PROnfs-vip:/export/sapmnt/EPP | EPP -fstype=nfs,rw,udp,nosymlink PROnfs-vip:/export/sapmnt/EPP | ||
ECP -fstype=nfs,rw,udp,nosymlink PROnfs-vip:/export/sapmnt/ECP | ECP -fstype=nfs,rw,udp,nosymlink PROnfs-vip:/export/sapmnt/ECP | ||
INTERFACES -fstype=nfs,rw,udp,nosymlink PROnfsvip:/export/sapmnt/INTERFACES | INTERFACES -fstype=nfs,rw,udp,nosymlink PROnfsvip:/export/sapmnt/INTERFACES | ||
- | </code> | + | </sxh> |
L’option nosymlink est indispensable pour permettre un accès au imports nfs sur le serveur nfs lui même sans utilisation directe de la ressource exportées. Si cette option n'est pas utilisée, cela se traduit par l'ouverture des fichiers présents sous /export/sapmnt lors de l'accès a un fichier par /import sur le serveur NFS. Ce comportement ne permet donc pas de basculer le package nfs d'un serveur a | L’option nosymlink est indispensable pour permettre un accès au imports nfs sur le serveur nfs lui même sans utilisation directe de la ressource exportées. Si cette option n'est pas utilisée, cela se traduit par l'ouverture des fichiers présents sous /export/sapmnt lors de l'accès a un fichier par /import sur le serveur NFS. Ce comportement ne permet donc pas de basculer le package nfs d'un serveur a | ||
l'autre car les fichier sont ouverts et qu'il n'est donc pas possible de démonter le FS pour le remonter sur un autre serveur du cluster. | l'autre car les fichier sont ouverts et qu'il n'est donc pas possible de démonter le FS pour le remonter sur un autre serveur du cluster. | ||
Line 58: | Line 59: | ||
• Start the pfs mount daemon and the pfs daemon: | • Start the pfs mount daemon and the pfs daemon: | ||
- | <code bash> | + | <sxh bash> |
shell> nohup pfs_mountd & | shell> nohup pfs_mountd & | ||
shell> nohup pfsd & | shell> nohup pfsd & | ||
- | </code> | + | </sxh> |
• Then create the directory to mount to and run the pfs_mount command: | • Then create the directory to mount to and run the pfs_mount command: | ||
- | <code bash> | + | <sxh bash> |
shell> mkdir /cdrom | shell> mkdir /cdrom | ||
shell> pfs_mount -o xlat=UNIX /path/to/isofile /cdrom | shell> pfs_mount -o xlat=UNIX /path/to/isofile /cdrom | ||
- | </code> | + | </sxh> |
__Version 11.31:__ | __Version 11.31:__ | ||
Line 74: | Line 75: | ||
• Create a new logical volume say ‘iso’ of size slightly greater than the size of your iso image in MB. You can do this from the admin tool-sam, or by using the following command. | • Create a new logical volume say ‘iso’ of size slightly greater than the size of your iso image in MB. You can do this from the admin tool-sam, or by using the following command. | ||
- | <code bash> | + | <sxh bash> |
shell>lvcreate -L size_of_your_iso -n iso /dev/vg00 | shell>lvcreate -L size_of_your_iso -n iso /dev/vg00 | ||
- | </code> | + | </sxh> |
• Write your iso to the new volume. Needless to say, you must have the required free space. | • Write your iso to the new volume. Needless to say, you must have the required free space. | ||
- | <code bash> | + | <sxh bash> |
shell>dd if=path/to/iso of=/dev/vg00/riso bs=64 | shell>dd if=path/to/iso of=/dev/vg00/riso bs=64 | ||
- | </code> | + | </sxh> |
• Now mount it on the directory of your choice, say /cdrom: | • Now mount it on the directory of your choice, say /cdrom: | ||
- | <code bash> | + | <sxh bash> |
shell>mount /dev/vg00/iso /cdrom | shell>mount /dev/vg00/iso /cdrom | ||
- | </code> | + | </sxh> |
=== On Solaris === | === On Solaris === | ||
Line 94: | Line 95: | ||
• Make the iso image accessible through the block device. (See the lofiadm man page for more details) | • Make the iso image accessible through the block device. (See the lofiadm man page for more details) | ||
- | <code bash> | + | <sxh bash> |
shell> lofiadm -a /path/to/iso/your_isao.iso | shell> lofiadm -a /path/to/iso/your_isao.iso | ||
- | </code> | + | </sxh> |
• Then mount it wherever you want to, say on /cdrom | • Then mount it wherever you want to, say on /cdrom | ||
- | <code bash> | + | <sxh bash> |
shell> mount -F hsfs -o ro /dev/lofi/1 /cdrom | shell> mount -F hsfs -o ro /dev/lofi/1 /cdrom | ||
- | </code> | + | </sxh> |
=== On Linux === | === On Linux === | ||
Line 108: | Line 109: | ||
• Use the following command to mount on the directory of your choice, say /mnt/myisodir | • Use the following command to mount on the directory of your choice, say /mnt/myisodir | ||
- | <code bash> | + | <sxh bash> |
mount -o loop myiso.iso /mnt/myisodir | mount -o loop myiso.iso /mnt/myisodir | ||
- | </code> | + | </sxh> |
----- | ----- | ||
Line 116: | Line 117: | ||
==== Machine virtuelle ou serveur physique ? ==== | ==== Machine virtuelle ou serveur physique ? ==== | ||
- | <code> | + | <sxh> |
# dmidecode -s system-product-name | # dmidecode -s system-product-name | ||
VMware Virtual Platform | VMware Virtual Platform | ||
- | </code> | + | </sxh> |
- | <code> | + | <sxh> |
# dmidecode -s system-product-name | # dmidecode -s system-product-name | ||
OptiPlex 760 | OptiPlex 760 | ||
- | </code> | + | </sxh> |
----- | ----- | ||
==== Vérifier les programmes utilisant xinetd ==== | ==== Vérifier les programmes utilisant xinetd ==== | ||
- | <code> | + | <sxh> |
egrep libwrap /usr/bin/* /usr/sbin/* | sort | egrep libwrap /usr/bin/* /usr/sbin/* | sort | ||
- | </code> | + | </sxh> |
----- | ----- | ||
Line 139: | Line 140: | ||
copier le répertoire isolinux du CD-Rom: | copier le répertoire isolinux du CD-Rom: | ||
- | <code> | + | <sxh> |
# cp -r /mnt/cdrom/isolinux cible | # cp -r /mnt/cdrom/isolinux cible | ||
# cd cible | # cd cible | ||
Line 147: | Line 148: | ||
-no-emul-boot -boot-load-size 4 \ | -no-emul-boot -boot-load-size 4 \ | ||
-boot-info-table -R -J -v -T cible/ | -boot-info-table -R -J -v -T cible/ | ||
- | </code> | + | </sxh> |
----- | ----- | ||
Line 153: | Line 154: | ||
==== Ajouter une imprimante réseau ==== | ==== Ajouter une imprimante réseau ==== | ||
- | <code> | + | <sxh> |
/usr/sbin/lpadmin -p net_printer -E -m printer.ppd -v socket://192.168.0.1 | /usr/sbin/lpadmin -p net_printer -E -m printer.ppd -v socket://192.168.0.1 | ||
- | </code> | + | </sxh> |
==== Mutualiser les connexions SSH ==== | ==== Mutualiser les connexions SSH ==== | ||
Ajouter dans le ~/.ssh/config : | Ajouter dans le ~/.ssh/config : | ||
- | <code> | + | <sxh> |
Host * | Host * | ||
ControlMaster auto | ControlMaster auto | ||
ControlPath ~/.ssh/master-%r@%h:%p | ControlPath ~/.ssh/master-%r@%h:%p | ||
- | </code> | + | </sxh> |
----- | ----- | ||
==== Montage cifs Cofiroute ==== | ==== Montage cifs Cofiroute ==== | ||
- | <code> | + | <sxh> |
mount -t cifs -o username=xxxx "\\\\sevres\\DSO\\DS3I" /mount_point | mount -t cifs -o username=xxxx "\\\\sevres\\DSO\\DS3I" /mount_point | ||
- | </code> | + | </sxh> |
==== Montage DFS CentOS ==== | ==== Montage DFS CentOS ==== | ||
Line 177: | Line 178: | ||
- | <code>yum install keyutils </code> | + | <sxh>yum install keyutils </sxh> |
add these lines to the end of /etc/request-key.conf: | add these lines to the end of /etc/request-key.conf: | ||
- | <code> | + | <sxh> |
create cifs.spnego * * /usr/sbin/cifs.upcall -c %k | create cifs.spnego * * /usr/sbin/cifs.upcall -c %k | ||
create dns_resolver * * /usr/sbin/cifs.upcall %k | create dns_resolver * * /usr/sbin/cifs.upcall %k | ||
- | </code> | + | </sxh> |
After that you can mount remote DFS shares as a normal samba share. | After that you can mount remote DFS shares as a normal samba share. | ||
Line 199: | Line 200: | ||
inodes from memory, causing that memory to become free. | inodes from memory, causing that memory to become free. | ||
- | <code> | + | <sxh> |
To free pagecache: | To free pagecache: | ||
echo 1 > /proc/sys/vm/drop_caches | echo 1 > /proc/sys/vm/drop_caches | ||
Line 206: | Line 207: | ||
To free pagecache, dentries and inodes: | To free pagecache, dentries and inodes: | ||
echo 3 > /proc/sys/vm/drop_caches | echo 3 > /proc/sys/vm/drop_caches | ||
- | </code> | + | </sxh> |
As this is a non-destructive operation and dirty objects are not freeable, the | As this is a non-destructive operation and dirty objects are not freeable, the | ||
user should run `sync' first. | user should run `sync' first. | ||
Line 212: | Line 213: | ||
==== Mesurer l'entropie disponible ==== | ==== Mesurer l'entropie disponible ==== | ||
- | <code> | + | <sxh> |
cat /proc/sys/kernel/random/entropy_avail | cat /proc/sys/kernel/random/entropy_avail | ||
- | </code> | + | </sxh> |
**/dev/urandom** est pseudo aléatoire, très pratique pour la plupart des usages, il permet de générer autant de nombres qu'on veut à un rythme soutenu. | **/dev/urandom** est pseudo aléatoire, très pratique pour la plupart des usages, il permet de générer autant de nombres qu'on veut à un rythme soutenu. | ||
Line 227: | Line 228: | ||
Dans le fichier .ssh/config présent dans votre $HOME, ajouter : | Dans le fichier .ssh/config présent dans votre $HOME, ajouter : | ||
- | <code> | + | <sxh> |
host nom_serveur2 | host nom_serveur2 | ||
Hostname IP serveur2 | Hostname IP serveur2 | ||
ProxyCommand ssh serveur1 nc %h %p 2> /dev/null | ProxyCommand ssh serveur1 nc %h %p 2> /dev/null | ||
- | </code> | + | </sxh> |
Vous pouvez ensuite utiliser ssh user@nom_serveur2 pour vous connecter à serveur2. On vous demandera le mot de passe du compte sur serveur1 puis le mot de passe sur serveur2. Si vous souhaitez utiliser un compte particulier pour vous connecter à serveur1 vous pouvez utiliser la commande suivante : | Vous pouvez ensuite utiliser ssh user@nom_serveur2 pour vous connecter à serveur2. On vous demandera le mot de passe du compte sur serveur1 puis le mot de passe sur serveur2. Si vous souhaitez utiliser un compte particulier pour vous connecter à serveur1 vous pouvez utiliser la commande suivante : | ||
- | <code> | + | <sxh> |
ProxyCommand ssh user@serveur1 nc %h %p 2> /dev/null | ProxyCommand ssh user@serveur1 nc %h %p 2> /dev/null | ||
- | </code> | + | </sxh> |
Le nom_serveur2 est un nom arbitraire. Vous pouvez mettre toto, titi, ... c'est comme vous voulez. | Le nom_serveur2 est un nom arbitraire. Vous pouvez mettre toto, titi, ... c'est comme vous voulez. | ||
Line 244: | Line 245: | ||
==== Checking read-only filesystems ==== | ==== Checking read-only filesystems ==== | ||
- | <code>awk '$4~/(^|,)ro($|,)/' /proc/mounts</code> | + | <sxh>awk '$4~/(^|,)ro($|,)/' /proc/mounts</sxh> |