{"id":541,"date":"2016-10-28T10:37:15","date_gmt":"2016-10-28T09:37:15","guid":{"rendered":"https:\/\/www.jjtronics.com\/wordpress\/?p=541"},"modified":"2016-11-09T11:31:38","modified_gmt":"2016-11-09T10:31:38","slug":"diverses-commandes-linux","status":"publish","type":"post","link":"https:\/\/www.jjtronics.com\/wordpress\/2016\/10\/28\/diverses-commandes-linux\/","title":{"rendered":"Diverses commandes linux"},"content":{"rendered":"<p>Voici un petit memo personnel de quelques commandes en vrac \u00e0 ajouter \u00e0 votre boite \u00e0 outils :&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>-DEBIAN like : Suppression d&rsquo;un packet mal install\u00e9 qui n\u00e9cessite une r\u00e9installation :&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">sudo dpkg --force-remove-reinstreq --remove $NomDuPacket<\/pre>\n<p>-LINUX : Compter le nombre de fichiers contenu dans un r\u00e9pertoire :&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">ls -1A |wc -l<\/pre>\n<p>-LINUX : Rechercher occurence toto dans tous les fichiers du r\u00e9pertoire courant :&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">find . -name \u2018*\u2019 -exec grep -Hsl \u2018toto\u2019 {} ;<\/pre>\n<p>-LINUX : activer un script dans init.d au boot du syst\u00e8me :&nbsp;<\/p>\n<pre class=\"lang:default decode:true \">update-rc.d $NomDuScrupt defaults<\/pre>\n<p>-LINUX : d\u00e9sactiver le d\u00e9marage d&rsquo;un script init.d au boot du syst\u00e8me :&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">update-rc.d -f $NomDuScript remove<\/pre>\n<p>&nbsp;<\/p>\n<p>-La CheatOgraphie :&nbsp;<\/p>\n<pre class=\"lang:default decode:true\">###Bash Commands\r\nuname -a \r\n#Show system and kernel\r\nhead -n1 \/etc\/issue \r\n#Show distribution\r\nmount \r\n#Show mounted filesystems\r\ndate \r\n#Show system date\r\nuptime \r\n#Show uptime\r\nwhoami \r\n#Show your username\r\nman command \r\n#Show manual for command\r\n<\/pre>\n<pre class=\"lang:default decode:true\">###Bash Shortcuts\r\nCTRL-c \r\n#Stop current command\r\nCTRL-z \r\n#Sleep program\r\nCTRL-a \r\n#Go to start of line\r\nCTRL-e \r\n#Go to end of line\r\nCTRL-u \r\n#Cut from start of line\r\nCTRL-k \r\n#Cut to end of line\r\nCTRL-r \r\n#Search history\r\n!! \r\n#Repeat last command\r\n!abc \r\n#Run last command starting with abc\r\n!abc:p \r\n#Print last command starting with abc\r\n!$ \r\n#Last argument of previous command\r\nALT-. \r\n#Last argument of previous command\r\n!* \r\n#All arguments of previous command\r\n^abc^123 \r\n#Run previous command, replacing abc with 123\r\n<\/pre>\n<pre class=\"lang:default decode:true\">###Bash Variables\r\nenv \r\n#Show environment variables\r\necho $NAME \r\n#Output value of $NAME variable\r\nexport NAME=value \r\n#Set $NAME to value\r\n$PATH \r\n#Executable search path\r\n$HOME \r\n#Home directory\r\n$SHELL \r\n#Current shell\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###IO Redirection\r\ncmd &lt; file\r\n#Input of cmd from file\r\ncmd1 &lt;(cmd2)\r\n#Output of cmd2 as file input tocmd1\r\ncmd &gt; file\r\n#Standard output (stdout) of cmd to file\r\ncmd &gt; \/dev\/null\r\n#Discard stdout of cmd\r\ncmd &gt;&gt; file\r\n#Append stdout to file\r\ncmd 2&gt; file\r\n#Error output (stderr) of cmd to file\r\ncmd 1&gt;&amp;2\r\n#stdout to same place as stderr\r\ncmd 2&gt;&amp;1\r\n#stderr to same place as stdout\r\ncmd &amp;&gt; file\r\n#Every output of cmd to file\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###Pipes\r\ncmd1 | cmd2\r\n#stdout of cmd1 to cmd2\r\ncmd1 |&amp; cmd2\r\n#stderr of cmd1 to cmd2<\/pre>\n<pre class=\"lang:default decode:true \">###Command Lists\r\ncmd1 ; cmd2\r\n#Run cmd1 then cmd2\r\ncmd1 &amp;&amp; cmd2\r\n#Run cmd2 if cmd1 is successful\r\ncmd1 || cmd2\r\n#Run cmd2 if cmd1 is not successful\r\ncmd &amp;\r\n#Run cmd in a subshell<\/pre>\n<pre class=\"lang:default decode:true \">###Directory Operations\r\npwd \r\n#Show current directory\r\nmkdir dir \r\n#Make directory dir\r\ncd dir \r\n#Change directory to dir\r\ncd .. \r\n#Go up a directory\r\nls \r\n#List files\r\n###ls Options\r\n-a Show all (including hidden)\r\n-R Recursive list\r\n-r Reverse order\r\n-t Sort by last modified\r\n-S Sort by file size\r\n-l Long listing format\r\n-1 One file per line\r\n-m Comma-separated output\r\n-Q Quoted output<\/pre>\n<pre class=\"lang:default decode:true \">###Search Files\r\ngrep pattern \r\n#files Search for pattern in files\r\ngrep -i \r\n#Case insensitive search\r\ngrep -r \r\n#Recursive search\r\ngrep -v \r\n#Inverted search\r\ngrep -o \r\n#Show matched part of\r\nfile only\r\nfind \/dir\/ -name name* \r\n#Find files starting with name in dir\r\nfind \/dir\/ -user name \r\n#Find files owned by name in dir\r\nfind \/dir\/ -mmin num \r\n#Find files modifed less than num minutes ago in dir\r\nwhereis command \r\n#Find binary \/ source \/ manual for command\r\nlocate file \r\n#Find file (quick search of system index)\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###File Operations\r\ntouch file1\r\n#Create file1\r\ncat file1 file2\r\n#Concatenate files and output\r\nless file1\r\n#View and paginate file1\r\nfile file1\r\n#Get type of file1\r\ncp file1 file2\r\n#Copy file1 to file2\r\nmv file1 file2\r\n#Move file1 to file2\r\nrm file1\r\n#Delete file1\r\nhead file1\r\n#Show first 10 lines of file1\r\ntail file1\r\n#Show last 10 lines offile1\r\ntail -F file1\r\n#Output last lines offile1 as it changes\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###Watch a Command\r\nwatch -n 5 'ntpq -p'\r\n#Issue the 'ntpq -p' command every 5 seconds and display output\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###Process Management\r\nps \r\n#Show snapshot of processes\r\ntop \r\n#Show real time processes\r\nkill pid \r\n#Kill process with id pid\r\npkill name \r\n#Kill process with name name\r\nkillall name \r\n#Kill all processes with names\r\nbeginning name<\/pre>\n<pre class=\"lang:default decode:true \">###Nano Shortcuts\r\n##Files\r\nCtrl-R \r\n#Read file\r\nCtrl-O \r\n#Save file\r\nCtrl-X \r\n#Close file\r\n##Cut and Paste\r\nALT-A \r\n#Start marking text\r\nCTRL-K \r\n#Cut marked text or line\r\nCTRL-U \r\n#Paste text\r\n##Navigate File\r\nALT-\/ \r\n#End of file\r\nCTRL-A \r\n#Beginning of line\r\nCTRL-E \r\n#End of line\r\nCTRL-C \r\n#Show line number\r\nCTRL-_ \r\n#Go to line number\r\n##Search File\r\nCTRL-W \r\n#Find\r\nALT-W \r\n#Find next\r\nCTRL- \r\n#Search and replace\r\n<\/pre>\n<pre class=\"lang:default decode:true \">###Screen Shortcuts\r\nscreen\r\n#Start a screen session.\r\nscreen -r\r\n#Resume a screen session.\r\nscreen -list\r\n#Show your current screen sessions.\r\n\r\n###Screen Shortcuts (cont)\r\nCTRL-A\r\n#Activate commands for screen.\r\nCTRL-A c\r\n#Create a new instance of terminal.\r\nCTRL-A n\r\n#Go to the next instance of terminal.\r\nCTRL-A p\r\n#Go to the previous instance of terminal.\r\nCTRL-A \"\r\n#Show current instances of terminals.\r\nCTRL-A A\r\n#Rename the current instance.\r\n<\/pre>\n<pre class=\"lang:default decode:true\">###File Permissions\r\nchmod 775 file\r\n#Change mode of file to 775\r\nchmod -R 600 folder\r\n#Recursively chmod folder to 600\r\nchown user:group file\r\n#Change file owner to user and group to group\r\n\r\n###File Permission Numbers\r\n#First digit is owner permission, second is group and third is everyone.\r\n#Calculate permission digits by adding numbers below.\r\n#4 read (r)\r\n#2 write (w)\r\n#1 execute (x)<\/pre>\n<p>&nbsp;<\/p>\n<p>Si vous en avez d&rsquo;autres que vous consid\u00e9rez utiles, n&rsquo;h\u00e9sitez pas \u00e0 me les envoyer en commentaire.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Voici un petit memo personnel de quelques commandes en vrac \u00e0 ajouter \u00e0 votre boite \u00e0 outils :&nbsp; &nbsp; -DEBIAN [&#038;hellip<\/p>\n","protected":false},"author":1,"featured_media":542,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[2,5],"tags":[87,100,110,106,111],"class_list":["post-541","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-linux-shell","tag-linux-2","tag-o","tag-os","tag-shell","tag-x"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/www.jjtronics.com\/wordpress\/wp-content\/uploads\/2016\/10\/Bash_Scripting.jpeg","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6YUVZ-8J","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/posts\/541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/comments?post=541"}],"version-history":[{"count":5,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/posts\/541\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/posts\/541\/revisions\/577"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/media\/542"}],"wp:attachment":[{"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/media?parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/categories?post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jjtronics.com\/wordpress\/wp-json\/wp\/v2\/tags?post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}