<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Archives des Linux - La programmation sur le web</title>
	<atom:link href="https://programmation.surleweb-france.fr/category/programmation/linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://programmation.surleweb-france.fr/category/programmation/linux/</link>
	<description>La programmation gratuite pour tous</description>
	<lastBuildDate>Sun, 28 Aug 2022 15:01:20 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2023/08/cropped-19518430-icone-de-programmation-pour-votre-site-web-mobile-presentation-et-conception-de-logo-gratuit-vectoriel.jpg?fit=32%2C32&#038;ssl=1</url>
	<title>Archives des Linux - La programmation sur le web</title>
	<link>https://programmation.surleweb-france.fr/category/programmation/linux/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">176210735</site>	<item>
		<title>Windows, une interface graphique pour Linux</title>
		<link>https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/</link>
					<comments>https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/#respond</comments>
		
		<dc:creator><![CDATA[Zigomato]]></dc:creator>
		<pubDate>Sun, 28 Aug 2022 15:01:20 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[windows]]></category>
		<category><![CDATA[wsl]]></category>
		<guid isPermaLink="false">https://programmation.surleweb-france.fr/?p=1483</guid>

					<description><![CDATA[<p>Voici comment mettre en place une interface graphique pour son WSL, Windows Subsystem Linux</p>
<p class="continue-reading-button"> <a class="continue-reading-link" href="https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/">Continuer la lecture<i class="crycon-right-dir"></i></a></p>
<p>L’article <a href="https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/">Windows, une interface graphique pour Linux</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Depuis maintenant plusieurs années, <a href="https://docs.microsoft.com/fr-fr/windows/wsl/about" target="_blank" rel="noreferrer noopener">WSL pour Windows Subsystem Linux</a> permet d&rsquo;avoir une distribution Linux sur son poste Windows.</p>



<p>Mes pc sont quasiment tous sur Windows mais très fréquemment, j&rsquo;ai besoin d&rsquo;outils seulement disponibles sur Linux (principalement Ubuntu) ou bien les choses que je cherche à faire son plus simple dessus.</p>



<p>WSL a été pour moi une grande nouvelle. Plus besoin de passer par un autre poste pour faire deux ou trois tests. Maintenant, tout est accessible depuis Windows. Enfin, tout si je n&rsquo;ai seulement besoin de Ubuntu en ligne de commande.</p>



<p>Nous allons voir comment obtenir une interface graphique de WSL.</p>



<h2 class="wp-block-heading">Installation de WSL</h2>



<p>J&rsquo;imagine que si tu souhaites avoir une interface graphique, cela signifie que tu as déjà l&rsquo;installation qui a été faite et que ton système Linux est accessible en ligne de commande, sinon, je t&rsquo;invite à suivre l&rsquo;<a href="https://lecrabeinfo.net/installer-wsl-windows-subsystem-for-linux-sur-windows-10.html" target="_blank" rel="noreferrer noopener">installation sur cette page</a>.</p>



<h2 class="wp-block-heading">Mise à jour de WSL</h2>



<p>Une fois ton installation finalisée avec un utilisateur et son mot de passe. Commences par une petite mise à jour : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt-get update &amp;&amp; Sudo apt-get full-upgrade -y</pre>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="900" height="395" src="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-11.png?resize=900%2C395&#038;ssl=1" alt="" class="wp-image-1484" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-11.png?w=914&amp;ssl=1 914w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-11.png?resize=300%2C132&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-11.png?resize=768%2C337&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-11.png?resize=150%2C66&amp;ssl=1 150w" sizes="(max-width: 900px) 100vw, 900px" /><figcaption>Mise à jour en cours</figcaption></figure>
</div>


<h2 class="wp-block-heading">Installer un serveur X</h2>



<p>Commencer par installer un logiciel comme VcXsrv (ou similaire), tu peux le trouver ici en <a href="https://sourceforge.net/projects/vcxsrv/" target="_blank" rel="noreferrer noopener">téléchargement</a>.</p>



<p>Une fois installer, ouvrir l&rsquo;outil, tu auras le choix entre plusieurs fenêtrages :</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" decoding="async" width="498" height="392" src="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-12.png?resize=498%2C392&#038;ssl=1" alt="" class="wp-image-1485" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-12.png?w=498&amp;ssl=1 498w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-12.png?resize=300%2C236&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-12.png?resize=150%2C118&amp;ssl=1 150w" sizes="(max-width: 498px) 100vw, 498px" /></figure>
</div>


<p><strong>Multiple windows</strong> permettra de voir le système LInux dans différentes fenêtre, <strong>One large windows</strong>, dans une grande.</p>



<p>Une fois le serveur lancé, un beau fond noir, oui, pour l&rsquo;instant, nous n&rsquo;avons pas encore d&rsquo;interface à afficher.</p>



<h3 class="wp-block-heading">Quelle version de WSL ?</h3>



<p>En fonction de votre système Windows, il se peut qu&rsquo;un ajout doit être fait.</p>



<p>Dans le Powershell, vérifies ta version WSL : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">wsl -l -v</pre>



<p>Pour ma part, je suis en version 1 :</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" decoding="async" width="287" height="72" src="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-13.png?resize=287%2C72&#038;ssl=1" alt="" class="wp-image-1486" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-13.png?w=287&amp;ssl=1 287w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-13.png?resize=150%2C38&amp;ssl=1 150w" sizes="(max-width: 287px) 100vw, 287px" /></figure>
</div>


<p>Tu peux tenter une mise à jour de la version en faisant (modifies le nom de la distribution en fonction de la tienne) :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="powershell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">wsl --set-version Ubuntu 2</pre>



<p>Malheureusement, mon PC ne me le permet pas. Nous allons modifier un fichier dans WSL.</p>



<p>Modifies le fichier <strong>/etc/bash.bashrc</strong> en ajoutant à la fin : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">export DISPLAY=:0</pre>



<p>Puis redémarres WSL.</p>



<h2 class="wp-block-heading">Test de l&rsquo;affichage</h2>



<p>Nous allons tester le fonctionnement de notre serveur. Assures toi que ton serveur a bien été lancé et qu&rsquo;il a un beau fond noir</p>



<p>Commences par installer sur WSL cet éditeur :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt-get install vim-gtk</pre>



<p>Puis dans wsl, tapes :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">gvim</pre>



<p>A présent, tu dois avoir l&rsquo;éditeur qui s&rsquo;est lancé dans ta fenêtre de ton serveur :</p>


<div class="wp-block-image">
<figure class="aligncenter size-full"><img data-recalc-dims="1" loading="lazy" decoding="async" width="900" height="551" src="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?resize=900%2C551&#038;ssl=1" alt="" class="wp-image-1487" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?w=1016&amp;ssl=1 1016w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?resize=300%2C184&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?resize=768%2C470&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?resize=150%2C92&amp;ssl=1 150w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-14.png?resize=327%2C201&amp;ssl=1 327w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure>
</div>


<h2 class="wp-block-heading">Installation d&rsquo;une interface graphique</h2>



<p>Bon, un fond noir, ce n&rsquo;est pas top, on va installer une interface graphique, on va reprendre celle de gnome.</p>



<p>Dans WSL, faites un petit :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt-get install xfec4</pre>



<p>Une fois l&rsquo;installation finie (cela peut prendre beaucoup de temps), toujours dans WSL, tapes :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="bash" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">xfec4-session</pre>



<p>Tu devrais obtenir ceci :</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img data-recalc-dims="1" loading="lazy" decoding="async" width="900" height="506" src="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?resize=900%2C506&#038;ssl=1" alt="" class="wp-image-1492" srcset="https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?resize=1024%2C576&amp;ssl=1 1024w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?resize=150%2C84&amp;ssl=1 150w, https://i0.wp.com/programmation.surleweb-france.fr/wp-content/uploads/2022/08/image-15.png?w=1366&amp;ssl=1 1366w" sizes="auto, (max-width: 900px) 100vw, 900px" /></figure>
</div>


<h2 class="wp-block-heading">Conclusion</h2>



<p>Te voilà avec un petit système sous linux disposant d&rsquo;une interface graphique.</p>
<p>L’article <a href="https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/">Windows, une interface graphique pour Linux</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmation.surleweb-france.fr/windows-une-interface-graphique-pour-linux/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1483</post-id>	</item>
		<item>
		<title>Informations sur le temps d&#8217;une tâche</title>
		<link>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/</link>
					<comments>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/#respond</comments>
		
		<dc:creator><![CDATA[Zigomato]]></dc:creator>
		<pubDate>Fri, 19 Mar 2021 17:24:23 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Raspberry]]></category>
		<category><![CDATA[commande]]></category>
		<category><![CDATA[durée]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[pv]]></category>
		<category><![CDATA[raspberry]]></category>
		<category><![CDATA[tâche]]></category>
		<category><![CDATA[temps]]></category>
		<guid isPermaLink="false">https://programmation.surleweb-france.fr/?p=823</guid>

					<description><![CDATA[<p>Ce paquet est PV pour Pipe Viewer, Il peut être inséré dans n'importe quel pipe normal, entre deux processus pour donner une indication visuelle de la rapidité avec laquelle les données transitent..</p>
<p class="continue-reading-button"> <a class="continue-reading-link" href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Continuer la lecture<i class="crycon-right-dir"></i></a></p>
<p>L’article <a href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Informations sur le temps d&rsquo;une tâche</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Voici un petit paquet pouvant être utile afin d&rsquo;avoir des informations sur l&rsquo;exécution du tâche lancée dans le terminal.</p>



<p>Ce paquet est PV pour Pipe Viewer, Il peut être inséré dans n&rsquo;importe quel pipe normal, entre deux processus pour donner une indication visuelle de la rapidité avec laquelle les données transitent..</p>



<h2 class="wp-block-heading">Installation du paquet</h2>



<p>Pour l&rsquo;installer, rien de plus simple, à partir du terminal (sur un debian ou dérivé) :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo apt-get install pv</pre>



<p>L&rsquo;installation ne prend que quelques secondes.</p>



<h2 class="wp-block-heading">Utilisation de PV</h2>



<p>Utilisation : pv [OPTIONS] [FICHIER]&#8230;<br>Concatène FICHIER(s), ou l&rsquo;entrée standard, sur la sortie standard<br>avec monitorage.<br>De manière simple, c&rsquo;est équivalent à la commande <strong>cat</strong> avec une barre de progression<br>-p, &#8211;progress affiche la barre de progression<br>-t, &#8211;timer affiche le temps écoulé<br>-e, &#8211;eta affiche l&rsquo;heure approximative de l&rsquo;achèvement de<br>la tâche<br>-r, &#8211;rate affiche le taux de tranfert des données<br>-a, &#8211;average-rate show data transfer average rate counter<br>-b, &#8211;bytes affiche le nombre d&rsquo;octets transférés<br>-f, &#8211;force imprime vers la sortie d&rsquo;erreur même si ce n&rsquo;est<br>pas un terminal<br>-n, &#8211;numeric imprime en pourcentage, pas les informations<br>visuelles<br>-q, &#8211;quiet n&rsquo;afficher aucune information de transfert<br>-c, &#8211;cursor utiliser les séquences d&rsquo;échappements de<br>positionnement de curseur<br>-W, &#8211;wait ne rien afficher avant qu&rsquo;au moins un octet soit<br>tranféré<br>-s, &#8211;size TAILLE ajuste la taille estimée des données à TAILLE<br>octets<br>-l, &#8211;line-mode compte les lignes au lieu des octets<br>-i, &#8211;interval SEC mise-à-jour toute les SEC secondes<br>-w, &#8211;width LARGEUR présumer la largeur du terminal à LARGEUR<br>caractères<br>-H, &#8211;height HAUTEUR présumer la hauteur du terminal à HAUTEUR lignes<br>-N, &#8211;name NOM préfixer les informations visuelles avec NOM<br>-L, &#8211;rate-limit TAUX limite le taux de transfer à TAUX octets par<br>seconde<br>-B, &#8211;buffer-size OCTETS Utiliser une mémoire tampon de OCTETS octets<br>-R, &#8211;remote PID mettre-à-jour la configuration du processus PID<br>-h, &#8211;help afficher cette aide puis quitter<br>-V, &#8211;version afficher la version puis quitter</p>



<h2 class="wp-block-heading">Exemple d&rsquo;utilisation</h2>



<h3 class="wp-block-heading">Création d’une clé bootable</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">pv image.iso | dd of=/dev/sdb &amp;&amp; sync</pre>



<p>Qui rendra : </p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">1,46GiO 0:00:17 [  86MiB/s] [==============================================================================>] 100%            
3062144+0 enregistrements lus
3062144+0 enregistrements écrits
1567817728 bytes (1,6 GB, 1,5 GiB) copied, 13,8749 s, 113 MB/s</pre>



<h3 class="wp-block-heading">Sauvegarde d’une base de données MariaDB</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">mysqldump mybdd | pv > mybdd.sql</pre>



<h3 class="wp-block-heading">Création d’une archive</h3>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">tar -czf - dossier | pv > dossier.tar.gz</pre>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Voici un petit utilitaire qui même si il ne va pas te révolutionner la vie, te donnera une petite idée sur ce qui est en train de se passer</p>
<p>L’article <a href="https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/">Informations sur le temps d&rsquo;une tâche</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmation.surleweb-france.fr/informations-sur-le-temps-dune-tache/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">823</post-id>	</item>
		<item>
		<title>Linux, exécuter un script en admin</title>
		<link>https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/</link>
					<comments>https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/#respond</comments>
		
		<dc:creator><![CDATA[Zigomato]]></dc:creator>
		<pubDate>Mon, 18 May 2020 17:00:00 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programmation]]></category>
		<category><![CDATA[Raspberry]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[crontab]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[root]]></category>
		<category><![CDATA[sudo]]></category>
		<category><![CDATA[unix]]></category>
		<category><![CDATA[visudo]]></category>
		<guid isPermaLink="false">https://programmation.surleweb-france.fr/?p=392</guid>

					<description><![CDATA[<p>Méthode simple pour donner des droits root à un script</p>
<p class="continue-reading-button"> <a class="continue-reading-link" href="https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/">Continuer la lecture<i class="crycon-right-dir"></i></a></p>
<p>L’article <a href="https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/">Linux, exécuter un script en admin</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>J&rsquo;ai eu besoin d&rsquo;automatiser un script en bash unix sur mon Raspberry. Dans ce script, une des commandes nécessite les droits admin, en l’occurrence, mon script devait relancer le <a rel="noreferrer noopener" href="https://programmation.surleweb-france.fr/installer-serveur-web-complet/" target="_blank">serveur HTTP Apache</a> (<strong>sudo service apache2 restart</strong>).</p>



<p>Le but de ce script est de redémarrer le service, j&rsquo;ai constaté que mon site retourné une réponse vide. Malheureusement, je n&rsquo;arrive pas à trouver la cause, la solution temporaire est donc de vérifier l&rsquo;accessibilité du site et en cas d&rsquo;erreur, je redémarre le service.</p>



<p>Pour l&rsquo;automatisation, j&rsquo;utilise le <a rel="noreferrer noopener" href="https://doc.ubuntu-fr.org/cron" target="_blank">cron</a>.</p>



<h2 class="wp-block-heading">Donner le droit admin au script</h2>



<p>Une fois que ton script est créé et qu&rsquo;il est fonctionnel, par exemple <strong>/home/chez_moi/test_sudo.sh</strong>. Je ne prends pas volontairement un script.</p>



<p>Dans un terminal, entres :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo visudo</pre>



<p>Puis sur le modèle :</p>



<div class="wp-block-group"><div class="wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow">
<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">#Cmnd alias specification
Cmnd_Alias REF_SCRIPT=/home/chez_moi/test_sudo.sh</pre>



<p>Et à la fin du fichier, ajoutes :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">%root ALL=(ALL) NOPASSWD:REF_SCRIPT</pre>
</div></div>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>le %root peut être à remplacer par %admin, REF_SCRIPT est une référence que tu choisis. </p><p>La syntaxe « Cmnd_Alias » est importante.</p><cite>Zigomato</cite></blockquote>



<p>Tu enregistres et tu sors.</p>



<h2 class="wp-block-heading">Automatiser avec le cron</h2>



<p>Je ne ferai pas de cours sur le cron, je vais juste te montrer comment ajouter ton script test, dans un terminal, saisis :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">sudo crontab -e</pre>



<p>Puis à la fin du fichier, ajoutes :</p>



<pre class="EnlighterJSRAW" data-enlighter-language="shell" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">*/30 * * * * bash /home/chez_moi/test_sudo.sh</pre>



<p>Une fois que tu fermes, tout est bien pris en compte.</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>Voilà la petite astuce pour donner les droits à un seul script sans passer par des utilisateurs.</p>



<p class="has-small-font-size">A été vu sur <a rel="noreferrer noopener" href="https://forum.ubuntu-fr.org/viewtopic.php?id=358786" target="_blank">forum.ubuntu-fr.org</a> et sur <a href="https://linux-attitude.fr/post/utilisation-de-sudo" target="_blank" rel="noreferrer noopener">Linux-attitude.fr</a>.</p>
<p>L’article <a href="https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/">Linux, exécuter un script en admin</a> est apparu en premier sur <a href="https://programmation.surleweb-france.fr">La programmation sur le web</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://programmation.surleweb-france.fr/linux-executer-un-script-en-admin/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">392</post-id>	</item>
	</channel>
</rss>
