background preloader

SysAdmin

Facebook Twitter

Bash One-Liners Explained, Part III: All about redirections. This is the third part of the Bash One-Liners Explained article series.

Bash One-Liners Explained, Part III: All about redirections

In this part I'll teach you all about input/output redirection. I'll use only the best bash practices, various bash idioms and tricks. I want to illustrate how to get various tasks done with just bash built-in commands and bash programming language constructs. See the first part of the series for introduction. After I'm done with the series I'll release an ebook (similar to my ebooks on awk, sed, and perl), and also bash1line.txt (similar to my perl1line.txt). Also see my other articles about working fast in bash from 2007 and 2008: Let's start.

Part III: Redirections Working with redirections in bash is really easy once you realize that it's all about manipulating file descriptors. File descriptors always point to some file (unless they're closed). Assuming your terminal is /dev/tty0, here is how the file descriptor table looks like when bash starts: 1. How to hide commands typed in a Linux shell? Increase your available swap space with a swap file.

You've finally configured every aspect of your Linux system.

Increase your available swap space with a swap file

All of your devices function, and everything is configured just the way you like it. At least you think so, until you start running out of memory when you have OpenOffice.org and lots of browser tabs open simultaneously. You realize you should have specified a larger swap partition during your install. Does this mean you have to install again from scratch? Happily, no. There's always more than one way to maintain your Linux system. To start off, see how much swap space you already have. Filename Type Size Used Priority /dev/hda2 partition 128044 92472 -1 The numbers under "Size" and "Used" are in kilobytes. Manipulating Strings. Extracts substring from $string at $position.

Manipulating Strings

If the $string parameter is "*" or "@", then this extracts the positional parameters, starting at $position. Extracts $length characters of substring from $string at $position. The position and length arguments can be "parameterized," that is, represented as a variable, rather than as a numerical constant. Example 10-2. Generating an 8-character "random" string If the $string parameter is "*" or "@", then this extracts a maximum of $length positional parameters, starting at $position. Software architect Kristof Kovacs. Just a list of 20 (now 28) tools for the command line.

Software architect Kristof Kovacs

Some are little-known, some are just too useful to miss, some are pure obscure -- I hope you find something useful that you weren't aware of yet! Use your operating system's package manager to install most of them. (Thanks for the tips, everybody!) Dstat & sar iostat, vmstat, ifstat and much more in one. Comment trouver quelle page provoque une augmentation du CPU de votre serveur. Mon serveur faisait des piques au niveau CPU avec MySQL sans que je puisse déterminer avec précision quel était le problème.

Comment trouver quelle page provoque une augmentation du CPU de votre serveur

Google. Security technologies on Microsoft environnement: Purger les mots de passes enregistrés. Par bonheur pour l'utilisateur lambda (parfois moins pour l'administrateur) qui parfois a du mal à retenir sa pléthore de mot de passe il existe une fonctionnalité utile dans certaines applications qui permet de se souvenir pour son mot de passe : Malheureusement quand ce dernier change le mot de passe associé sous Windows 7 c'est un vrai cauchemar pour retrouver la fameuse fenêtre de gestion de ces derniers.

Security technologies on Microsoft environnement: Purger les mots de passes enregistrés

Il existe une commande pour accéder à cette dernière directement et ainsi "sauver" l'utilisateur qui doit accéder à une donnée importante pour une réunion. La sauvegarde MySQL. Cher journal, J'ai enfin trouvé une manière de sauvegarder et de restaurer une base MySQL de plusieurs Go qui soit efficace dans les deux sens.

La sauvegarde MySQL

Pour les bases Sauvegarde: mysqldump --single-transaction --quick -B $db | gzip > $db.sql.gzRestauration zcat $db.sql.gz. Script to restore. Ansible >> Advanced System Orchestration. Pousser en prod tous les jours, toujours, tout le temps - CrEv's log. Il y a quelques temps j'ai écris un petit article à propos du fait de pousser du code en production tous les jours : « Ne pas pousser en prod le vendredi.

Pousser en prod tous les jours, toujours, tout le temps - CrEv's log

FAUX ! ». Comme expliqué en introduction, cet article était en partie en réaction au fait de voir tout le monde s'extasier devant le fait de ne pas pousser en production le vendredi. Bon, faut croire que cet article vous a pas mal intéressé, mais je note surtout une bonne dose de mauvaise fois dans certaines réactions, voir tout simplement une sacré incompréhension. Et on peut aussi ajouter des pseudo-raisons pour tenter de justifier de ne pas pousser en production le vendredi. D'ailleurs, puisque certains voulaient croire que personne ne faisait ça pour de vrai, un autre billet vous listait un certain nombre d'exemples de déploiement continu, entre autre chez flickr, github, facebook, etsy.

Mais bon, faut croire que je vis dans un monde de bisounours.

Ansible

Synology. Nginx. IP. GNU/Linux. Mac OS X. OVH.